LVM Snapshot Question

Latest response

Hi guys,

thanks again for helping me out.

I am always confused when it comes to creating lvm snapshot. What size should you give to an lvm snapshot ? Should space be available in the volume group in order to create a snapshot? Should the snapshot size be the same as its source lv ?

Lets take this example:

existing lv = lvroot : 10G
VG = vg_sos = 20M free

How will you create a snapshot of the lvroot lvm ?

Thank you

Arrey

Responses

Hi Arrey,
Check out
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Logical_Volume_Manager_Administration/snapshot_volumes.html

Regarding the size, that is difficult question to have a single answer for. It really depends on the rate of change on the volume. I.e. if you have a 10GB root_vol for / and you patch the OS which modifies 700MB then that will be the size of the SNAPSHOT (plus some minor overhead, I believe). What is crucial to note is the snapshot becomes invalid if it runs out of space (which makes sense).

I believe the snapshot does indeed reside in the same Volume Group.

# lvs
  LV       VG         Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  LogVol00 VolGroup00 -wi-ao  32.00G 

Thanks James.

So if take a snapshot and apply updates to the OS, does the snapshot automatically grow? If this is the case, how then can you revert back to a point in time ? if the update messed up the OS, how do you revert back using the snapshot if the updates also applied to the snapshot?

Thanks

I actually don't know. Which you made me wonder about a few things. Most importantly incremental updates. I.e. attach the snapshot, update the file (point A, we'll say), update file again (now point B), and then update again (now point C) which breaks something. Can you only roll-back to point B? Also - now I am wondering if it is a file-level snapshot. I.e. can you rollback a single file, or do you have to rollback the entire volume. I believe you can mount the snapshot separately and retrieve the file that way.

I have some reading to do! Another great topic Arrey!

What has always pondered me though is this: How to role back the entire OS to a previous point in time before an update messed things up.

In solaris they have Live Update/Upgrade: you can create a boot environment (BE) (copy of the entire OS), patch that BE , set it to activate on reboot. If something goes wrong, we activate the previous BE. Everything comes back to normal. With that we can mount the patched BE and figure out what the causes issue.

Is there anything thing similar in RHEL?

snapshot does not automatically grow.

To revert back , use --merge option of lvconvert command :
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Logical_Volume_Manager_Administration/snapshot_merge.html

snapshot size can vary depending on your requirement. if you think that you might end up changing all the data in logical volume then make the snapshot size same as logical volume.

Regards
Ajit Mote