zeldor.biz

Linux, programming and more

Copyright © 2023
Log in

Create LVM Snapshot

May 27, 2011 by Igor Drobot Leave a Comment

I want to show you how to create a LVM snapshot on the fly, before you install some nasty updates.

I have my KVM virtual machine (/dev/vg0/Webserver) and want to upgrade it, before I go on, I want to create a LVM snapshot. In worst case it can change back to this state.

1
lvcreate -L 5000 -s -n "7.9_wheezy" /dev/vg0/devel.drobot.de

lvcreate -L 5000 -s -n "7.9_wheezy" /dev/vg0/devel.drobot.de

– L 5000 is the size in MB
-s flag is to create a snapshot
-n 7.9_wheezy is the name of new logical volume

If something goes wrong, go back to previously created snapshot:

1
2
3
lvchange -a n /dev/vg0/devel.drobot.de
lvconvert --merge /dev/vg0/7.9_wheezy
lvchange -a y /dev/vg0/devel.drobot.de

lvchange -a n /dev/vg0/devel.drobot.de lvconvert --merge /dev/vg0/7.9_wheezy lvchange -a y /dev/vg0/devel.drobot.de

Attention!
If you delete your origin volume your snapshot will be automatically deleted!

Filed Under: Debian, Linux Tagged With: lvchange, lvconvert, lvcreate, LVM, restore lvm, Snapshot