There is a difference between the data in the first block of a persistent vs transient dmsetup
snapshot device:
Given these devices:
$ losetup
NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO
/dev/loop1 0 0 0 0 /home/var/ravi/tmp/issue/snap-dev 0
/dev/loop0 0 0 0 0 /home/var/ravi/tmp/issue/base-dev 0
And an initially zeroed-out snapshot device backing file:
$ od -xc snap-dev
0000000 0000 0000 0000 0000 0000 0000 0000 0000
\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
*
3751613000
Here's what happens when using the non-persistent N
flag:
$ sudo dmsetup -v create snapdev --table '0 8 snapshot /dev/loop0 /dev/loop1 N 1'
Name: snapdev
State: ACTIVE
Read Ahead: 256
Tables present: LIVE
Open count: 0
Event number: 0
Major, minor: 254, 5
Number of targets: 1
$ od -xc snap-dev
0000000 0000 0000 0000 0000 0000 0000 0000 0000
\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
*
3751613000
Note that the backing file is unchanged - it's all still \0
bytes.
Now, trying again with the P
flag for persistence:
$ sudo dmsetup remove snapdev
$ sudo dmsetup -v create snapdev --table '0 8 snapshot /dev/loop0 /dev/loop1 P 1'
Name: snapdev
State: ACTIVE
Read Ahead: 256
Tables present: LIVE
Open count: 0
Event number: 0
Major, minor: 254, 5
Number of targets: 1
$ od -xc snap-dev
0000000 6e53 7041 0001 0000 0001 0000 0001 0000
S n A p 001 \0 \0 \0 001 \0 \0 \0 001 \0 \0 \0
0000020 0000 0000 0000 0000 0000 0000 0000 0000
\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
*
3751613000
In this case, the first bytes of the device are SnAp\001
.
My guess is that persistent data is stored in the first block or blocks of the snapshot device itself.