LVM Snapshot Create / Merge / Rollback#

Example use-case: Snapshot Gitlab VM disk before running an upgrade.

Check volume groups and logical volumes:

vgs
lvs

Given a volume named git, create a snapshot called git_snap:

lvcreate --size 8G --snapshot --name git_snap /dev/vg0/git

Now you can run the update process, e.g. https://blog.hukudo.de/admin/how-to-upgrade-ubuntu-from-16.04-to-18.04.html

COMMIT#

virsh shutdown --mode acpi --domain git
virsh list

lvchange -an /dev/vg0/git
lvremove /dev/vg0/git_snap
lvchange -ay /dev/vg0/git

virsh start git

ROLLBACK#

virsh shutdown --mode acpi --domain git
virsh list

lvchange -an /dev/vg0/git
lvconvert --merge /dev/vg0/git_snap
lvchange -ay /dev/vg0/git

virsh start git

Status#

Check the snapshot’s status:

watch lvdisplay /dev/vg0/git

It may take a while until the following output of lvdisplay disappears:

  LV snapshot status     source of
                         git_snap [active]