What are the commands to use in LVM in case I want to:

  1. create a read-only snapshot of a volume;
  2. (do some experiments in the volume);
  3. and then rollback the volume to the snapshot?

1 Answer 1


I think you are looking for lvconvert --merge. From the man page:


Merges a snapshot into its origin volume. To check if your kernel supports this feature, look for snapshot-merge in the output of dmsetup targets. If both the origin and snapshot volume are not open the merge will start immediately. Otherwise, the merge will start the first time either the origin or snapshot 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 specified on the commandline or a @tag may be used to specify multiple snapshots be merged to their respective origin.

Assume you have a logical volume vg0/system which contains your / filesystem.

# create a read-only snapshot
lvcreate -pr --snapshot --name system_snapshot vg0/system
# upgrade or something
# if it fails, reboot and do this from a livecd
lvconvert --merge vg0/system_snapshot
# reboot again and you have your old system back

The reboots are only needed because in this scenario you can't unmount the filesystem. If it's not the / fs, unmount is enough.

Keep in mind that the snapshot will deleted after the merge.

  • Thanks for the answer! And if one doesn't give the -pr (--permission r) option to lvcreate, will the snapshot be read-only by default? (Does LVM allow writable snapshots at all? If yes, an alternative scenario could be possible, where the temporary experiments wouldn't be visible in the main volume, but would be performed in the temporary writable snapshot.) Aug 22, 2011 at 23:29
  • 1
    The default is RW.
    – stribika
    Aug 23, 2011 at 18:38
  • 5
    You shouldn't do the merge from a live CD , you can issue the command and after reboot it would merge automatically.
    – Hanan
    Dec 4, 2011 at 10:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .