Reverting to a previous snapshot using Linux LVM
Reverting to a previous snapshot has been possible for over a year!!!!! How did I miss that ?? This has for a long time been one of my only real criticisms of LVM and I just discovered that it was quietly committed into the kernel back in 2.6.33 The command used to do the revert is contained within lvconvert. From the lvconvert man page: --merge Merges a snapshot into its origin volume. To check if your ker‐ nel supports this feature, look for 'snapshot-merge' in the out‐ put of 'dmsetup targets'. If both the origin and snapshot vol‐ ume are not open the merge will start immediately. Otherwise, the merge will start the first time either the origin or snap‐ shot are activated and both are closed. Merging a snapshot into an origin that cannot be closed, for example a root filesystem, is deferred until the next time the origin volume is activated. When merging starts, the resulting logical volume will have the origin's name, minor number and UUID. While the merge is in progress, reads or writes to the origin appear as they were directed to the snapshot being merged. When the merge finishes, the merged snapshot is removed. Multiple snapshots may be spec‐ ified on the commandline or a @tag may be used to specify multi‐ ple snapshots be merged to their respective origin. A quick check using the command ‘dmsetup targets’ shows that it is definitely in my kernel so I thought I would give it a quick run through and test it a lot. I created a testing logical volume and then put some data on it, took a snapshot, changed the data and then reverted to the snapshot. Here is what I did.