How to create a read-only snapshot in LVM, and then rollback to it after some work?

imz -- Ivan Zakharyaschev

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?
stribika

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

--merge

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How large should an LVM snapshot be?

how to snapshot thin provisioned lvm

LVM snapshot - performance for write-only data

lvm: create snapshot between volume groups

How to take webcam snapshot after some interval in stealth mode in react?

How to rollback a specific directory in ZFS snapshot?

How to "keep" data from an LVM snapshot?

LVM snapshot: Failed to wipe snapshot exception store, udev doesn't create the partition before lvm tries to wipe it

How to load list only after FutureBuilder gets snapshot.data?

How to make some Django Inlines Read Only

How to read only some sections of a config file

Spring hibernate , how to call some method after transaction commit or transaction rollback

Rollback root snapshot in BTRFS

sqlite - rollback to a snapshot

How to pause MySQL before taking an LVM/ZFS snapshot?

How to create a read-only array in java?

How to create a file that only sudo can read?

How do I run async work on text field changes but only after some seconds when the user is done changing the field?

LVM Snapshot Storage Requirements

Snapshot size in lvm

Django rollback transaction after perform_create

How to add some operations on transaction rollback

How to create a snapshot of a physical disk?

How to create and rotate Automatic Snapshot?

how to create snapshot routine in AWS

How to create a Rollback log which generates automatically after each day using java.util.logging.Logger?

How to read only some column families from Cloud Bigtable?

How to read only some lines from a large file in python?

How to grant read access to only some resources in an Azure subscription?