5 \h'-\w'\fB\\$1\ \fP'u'\fB\\$1\ \fP\c
7 .TH lvm-rmsnap 8 "6 November 2011" "distorted.org.uk backup"
9 lvm-rmsnap \- remove an LVM snapshot, despite LVM bugs
17 tool removes an LVM snapshot volume. The command
19 .BI "lvm-rmsnap " vgname / lvname
21 does what you'd hope, in an ideal world,
23 .BI "lvremove \-f " vgname / lvname
27 doesn't prompt if the snapshot is active. There are LVM bugs which
28 prevent you from deactivating the snapshot, and this tool is intended to
29 be used in noninteractive scripts.)
31 Unfortunately, the world is not ideal, and trying to remove snapshots
32 using current versions of LVM runs into a collection of nasty race
37 is to remove snapshots despite these bugs. It acts as a `nanny' for
39 carefully tracking all of the toys, and putting them back in the pram.
41 The following command-line options are accepted.
44 Print a help message to standard output and exit with status zero.
47 Print the program's version number to standard output and exit with
51 Print to standard error information about what the program is doing and
52 what things it's found out. This may be useful if you're trying to find
58 Don't actually perform corrective actions. This is pretty useless
61 You probably don't want to use this unless you're testing
64 The basic problem with
66 is that, partway through, it discovers that some device it was about to
67 fiddle with is currently in use by some other process \(en usually
70 rule \(en and then gives up, leaving things in a messed-up state.
71 There's an elaborate and wobbly synchronization protocol which involves
72 passing System V semaphore set ids through the kernel and is meant to
73 make stuff like this not go wrong, but it does anyway.
77 is to remove a snapshot despite these bugs. Usually, repeating the
79 attempt will succeed, though there's often debris of various kinds to be
80 cleared away. Here's a list of the things that
84 If you're very unlucky, then LVM will leave the snapshot origin volume
85 suspended, which will cause a subsequent
87 attempt to wedge itself (and block any other processes trying to do I/O
90 resumes the volume before retrying.
94 can leak `cookies', which are really System V semaphore sets. These use
95 up kernel memory, and can't be automatically garbage-collected (this is
96 a well-known mistake in the System V IPC design). So
98 keeps track of the cookies used, and releases them if
102 Setting up a snapshot involves a little juggle: a new
104 device is created, exactly like the origin volume; and then the origin
105 volume is changed to be a
107 volume pointing at the new device. When
111 device can be left behind. So
113 detects this situation and removes it, after checking that it really
114 isn't needed for anything.
116 If you know of an LVM snapshot-removal bug which this won't work around
117 then please let the author know.
124 Mark Wooding, <mdw@distorted.org.uk>