Wednesday, August 17, 2016

Linux : Snapshot

Create snapshot

lvcreate -s -n snaplvol1 -l 100 vg0/vol1
100 means extents, usually 4M per extents

Then you make system changes.

If changes go well:
Remove snapshot

lvremove -f vg0/snaplvol1

If changes do not go well:
Rollback to snapshot (abort change)

lvconvert --merge vg0/snaplvol1

If this volume is in use, it will be merged during next reboot.


Cancel Snapshot Merge
If at this point, you don't want to rollback to previous snapshot after the next reboot:

Before reboot:

grep description /etc/lvm/archive/vg0*.vg

Find the file with the following output

description = "Created *before* executing 'lvconvert --merge vg0/snaplvol1'"

Then run vgcfgrestore with this file

vgcfgrestore --file /etc/lvm/archive/vg0xxxxxxx.vg

Then reboot

No comments:

Post a Comment