RHEL 7 - LVM Snapshots

Latest response

LVM snapshots are a dream; it's amazing to be able to just take a snapshot, do something risky (eg. yum update or delete something), and then if terrible things happen, just merge the snapshot & restart to go back where you started. It also makes taking consistent backups easier. LVM snapshots require some free space on the volume group, something which I rarely ever see in the countless servers I maintain which were installed by other admins; and it's not trivial to add free space later. I get the impression that not many people are aware of this feature in Linux.

I was hoping Red Hat would encourage this feature in RHEL7 by leaving some gigabytes free in the volume group during the automatic partitioning, but unfortunately it seems to have gone the other way; even during the manual partitioning, it minimizes the Volume Group size regardless of the available space on the drive, making it not possible to take snapshots. One has to click on "Modify" next to "Volume Group", set the "Size policy" to "As large as possible", and then click on Update Settings (forgetting the last step is easy, and it's weird that things like changing the filesystem type or mount point does not require clicking "Update Settings" and only the LVM part does).

I was just hoping Red Hat would encourage snapshots by leaving some space free during automatic partitioning, or even just make it easier to leave space in the VG. I suppose hoping for it to give a warning message (as it does when the swap partition is missing) during manual partitioning to leave some space in the VG for snapshots is a bit of a stretch, but I think this small (but I suppose, to some, obtrusive) change would really result in a whole lot more admins using snapshots, making their lives easier.

Responses

Hi Rizvi, thanks for the feedback. LVM snapshots are definitely useful functionality. I'll see if I can track down someone familiar with this feature to comment here.

It would, certainly, be a pow pow powerful feature!

Well well well, fancy seeing you here ;)

This would be a great feature!

Just to be clear, the feature already exists in RHEL 6. My request was to only make it better known and design the installer partitioning defaults around it, so that more people can use it.

So if you had say 10GB of free space in your volume group, you can take a snapshot:
lvcreate --snapshot --name RootSnapshot --size 6G /dev/YourVG/YourRootLV
and repeat for every LV that is needed if any (distributing the size as needed).
Then do say a yum update, but to test it you can add a comment to /etc/hosts. Then if you want to revert to the old snapshot, just do a :
lvconvert --merge /dev/YourVG/RootSnapshot
and reboot, you will go back to where you started. If you snapshot a non-root volume, you don't even have to restart if the mount point isn't being used. If you don't want to revert, just delete the snapshot (which is important as the server I/O performance will be sub-optimal with snapshots):
lvremove /dev/YourVG/RootSnapshot

Snapshots are also useful to take more-consistent-than-live backups as well.

I'm with you 100%

I use snapshots frequently, and I've always wondered why RedHat makes you jump through hoops during the install process to save some unused diskspace for them.

Alternately, the way that Tru64 UNIX handles snapshots (by using freespace within the filesystem itself rather than unused disk space external to the filesystem) works well, too. Under Tru64, as long as your filesystem is not full, you can take a snapshot of it, even if you didn't do anything to prepare for that during the install.

I agree with you , snapshots are very helpfull , i did roll back to previous state many times and taking snapshots only possible with used disk space in VG.

what if there is no free space in VG or all disk used and nothing can be added to VG to get free space ( shrinking other VG add to rootvg ) , is there any other way for performing snapshot
? or just leave it as you cant get any free space.

i mean unused disk space*

To consider the LVM snapshots for file system backup, the performance seems to be really slow for file system which has snapshot because of Copy-On-Write.