Which size for snapshot volume for a *safe* backup?
Hi!
I want to use LVM snapshots to create consistent backups.
Given an original logical volume of size "n" Bytes (or chunks or extents or whatever you need for calculating it), how large in Bytes/chunks/extents must the appropriate snapshot volume be in order to retain the complete original logical volume in case the latter gets completely overwritten?
For testing, I used a 320 k logical volume on a VG on a PV comprising of a 1 MiB loop-back file of and created an equally sized snapshot volume.
While the snapshot worked perfectly with only overwriting half the original volume, it bailed out when overwriting the whole original volume; accessing the snapshot volume with "dd" after that overwrite produced the following:
Buffer I/O error on device dm-6, logical block 0 (blocks 0-15)
So, obviously,
snapshot volume size = original volume size
is not sufficient to hold a complete change of the original volume.
Btw.: There's a bug in "lvscan", it still displayed the snapshot as being "ACTIVE", while in fact (at least that's what I concluded), it was "INACTIVE" due to the lack of space, as shown using "lvdisplay".
Oh, and another small bug:
For a file with 256 kiB bound to a loop device, pvcreate says correctly:
/dev/loop/0: Size must exceed minimum of 1024 sectors. Failed to setup physical volume "/dev/loop/0"
But for files smaller than that (like 512 bytes), it erronously prints:
Device /dev/loop/0 not found
Best regards
Marc-Jano
Quoted 4 lines · Marc-Jano Knopp
But for files smaller than that (like 512 bytes), it erronously prints:
Device
/dev/loop/0not found
Maybe should be changed to:
Device /dev/loop/0 not found (or ignored by filters).
Tiny devices are filtered out at a low level in the code as it is never valid for lvm2 to scan them to see if they are PVs.
This was added for devices with extended partitions.
# blockdev --getsize /dev/hda4 2
Alasdair
Signature · 1 line
[email protected]
Quoted 3 lines · Marc-Jano Knopp
So, obviously,
snapshot volume size = original volume size
is not sufficient to hold a complete change of the original volume.
Correct - there's a little bit of metadata required too to map each piece of data back into the right location.
Quoted 3 lines
Btw.: There's a bug in "lvscan", it still displayed the snapshot as being "ACTIVE", while in fact (at least that's what I concluded), it was "INACTIVE" due to the lack of space, as shown using "lvdisplay".
The 'lvs' attributes should be accurate (and lvdisplay too I think). lvscan doesn't check properly and needs fixing, thanks.
Alasdair
Signature · 1 line
[email protected]
Quoted 7 lines · Alasdair G Kergon
Quoted 3 lines · Marc-Jano Knopp
So, obviously,
snapshot volume size = original volume size
is not sufficient to hold a complete change of the original volume.Correct - there's a little bit of metadata required too to map each piece of data back into the right location.
Thought so, just wasn't sure if it gets stored inside the volume or in an extra file or device.
I have noticed that lvdisplay <snapshot volume> prints:
Allocated to snapshot: 5.00%
But as I don't know the inner workings of LVM, I preferred not to take this value for all variants of logical volumes for granted, but instead ask here in this list for exact numbers.
[lvscan displays inactive snapshot volume as active]
Quoted 2 lines
The 'lvs' attributes should be accurate (and lvdisplay too I think). lvscan doesn't check properly and needs fixing, thanks.
http://www.gotfuturama.com/Multimedia/EpisodeSounds/2ACV14/10.mp3
:-)
Best regards
Marc-Jano