How to delete an LVM snapshot

On December 21, 2009, in Hosting, Linux, by tov

Problem: Centos did not boot after a failure with an LVM snapshot.

It got stuck at:

Setting up Logical Volume Management: (part of rc.sysinit)

Solution:

Boot:
1) grub “e” (to edit the first line)
2) append “init = /bin/bash” to kernel parameters
3) boot (Enter, “b”)

(append “Single” should work as well but it didn’t as far as I remember)

Console
1) mount / -o remount (enables rw mode)
2) vi /etc/lvm/lvm.conf
3) replace
locking_dir = “/var/lock/lvm”
by
locking_dir = “/tmp”
(this is because “lvremove” does not recognize the –ignorelockingfailure parameter)
4) cd /sbin
5) ./lvm.static lvdisplay –ignorelockingfailure (not sure if this param is necessary after editing lvm.conf)
6) Find the snapshot path: /dev/your_volumegroup/your_logical_volume_snapshot
7) remove: ./lvm.static lvremove /dev/your_volumegroup/your_logical_volume_snapshot
8) reboot
9) be happy as it works now!

10) ask yourself if you should have re-edited lvm.conf…

I have forgotten to do so but as “/tmp” is more or less recommended in lvm.conf.

Hope that helps either people or me (in future).