How to Rollback a LVM Volume to its Snapshot.

The native Logical Volume Manager (LVM) on Linux also provides a very
easy way of rolling back a logical volume to its previously taken snapshot. This
gives us flexibility of returning to a good state of the disk (volume) in case
if some configuration or similar things goes wrong (but not like complete
filesystem crash). For an example you want to test a new software or package,
you can take a snapshot of the volume before installing the package, then test
your package, in case if you are not happy with the results, rollback to the
snapshot. Here is how we can rollback:

First you need to check if your kernel supports snapshot merge feature, for which you need to run dmsetup targets command and look for
snapshot-merge in the ouptut:

[[email protected] ~]# dmsetup targetssnapshot-merge   v1.1.0snapshot-origin  v1.7.1
snapshot         v1.10.0
mirror           v1.12.0
striped          v1.4.1
linear           v1.1.0
error            v1.0.1

To take a snapshot of a LVM volume:

[[email protected] ~]# lvcreate -s -n <snapshot name> -L <size of snapshot> <lvm volume for which to take snapshot >

NOTE: snapshot size can vary depending on your requirement but a minimum
recommended size is 30% of the logical volume for which you are taking the
snapshot but if you think that you might end up changing all the data in logical
volume then make the snapshot size same as logical volume

For Example: To
create a 50 MB snapshot of a logical volume "/dev/vg0/lv0" :

[[email protected] ~]# lvcreate -s -n snap0 -L 50M /dev/vg0/lv0

Now you do all the changes you want to do on your logical volume and when
you want to safely rollback, umount the logical volume (and the snapshot as
well, if you had it mounted) and run the following commands:

[[email protected] ~]# umount  <logical volume path>
[[email protected] ~]# lvconvert --merge <snapshot path>

If the above lvconvertcommand gives some warning as "Can‘t merge
over open origin volume"
then you also need to deactivate and activate the
logical volume with following command:

[[email protected] ~]# lvchange -an <logical volume path>
[[email protected] ~]# lvchange -ay <logical volume path>

For example: To revert back to snap0 snapshot, which I took above
for /dev/vg0/lv0 :

[[email protected] ~]# umount  /dev/vg0/lv0
[[email protected] ~]# lvconvert --merge /dev/vg0/snap0

Thats it. Now mount your logical volume back and you will realize that
this volume has been roll backed and the snapshot volume has been deleted too
.

时间: 2024-10-05 05:06:06

How to Rollback a LVM Volume to its Snapshot.的相关文章

准备 LVM Volume Provider - 每天5分钟玩转 OpenStack(49)

Cinder 真正负责 Volume 管理的组件是 volume provider. Cinder 支持多种 volume provider,LVM 是默认的 volume provider.Devstack 安装之后,/etc/cinder/cinder 已经配置好了 LVM,如下图所示: 上面的配置定义了名为“lvmdriver-1”的 volume provider,也称作 back-end.其 driver 是 LVM,LVM 的 volume group 名为“stack-volume

Snapshot Volume 操作 - 每天5分钟玩转 OpenStack(58)

Snapshot 可以为 volume 创建快照,快照中保存了 volume 当前的状态,以后可以通过 snapshot 回溯.snapshot 操作实现比较简单,流程图如下: 向 cinder-api 发送 snapshot 请求 cinder-api 发送消息 cinder-volume 执行 snapshot 操作 下面我们详细讨论每一个步骤. 向 cinder-api 发送 snapshot 请求 客户(可以是 OpenStack 最终用户,也可以是其他程序)向 cinder-api 发

LVM学习

LVM Logical Volume Manager Volume management creates a layer of abstraction over physical storage, allowing you to create logical storage volumes. Logical volumes provide the following advantages over using physical storage directly: Flexible capacit

NFS Volume Provider(Part II) - 每天5分钟玩转 OpenStack(63)

上一节我们将 NFS volume provider 配置就绪,本节将创建 volume. 创建 volume 创建 NFS volume 操作方法与 LVM volume 一样,唯一区别是在 volume type 的下拉列表中选择“nfs”. 点击“Create Volume”,cinder-api,cinder-scheduler 和 cinder-volume 共同协作创建 volume “nfs-vol-1”.这个流程与 LVM volume 一样. 下面我们重点分析 cinder-v

LVM快照备份与恢复

简介 最近在做数据备份方面的工作,用到两个工具,一个是dd,而另一个是lvm的快照(snapshot).由于数据比较大,直接是用dd非常耗时,而lvm的快照可以在几秒内轻松搞定,而且可以达到实时的效果,但是使用lvm快照的代价就是以空间换取时间. 下面我们就先来了解下原理: LVM中snapshot通过"写时复制"(copy on write) 来实现,即当一个snapshot创建的时候,仅拷贝原始卷里数据的元数据(meta-data):创建的时候,并不会有数据的物理拷贝,因此snap

LVM快照(snapshot)备份

转载自:http://wenku.baidu.com/link?url=cbioiMKsfrxlzrJmoUMaztbrTelkE0FQ8F9qUHX7sa9va-BkkL4amvzCCAKg2hBv5ZmYL_ERp3Wprd1jVxG-333s6tCJn2LGqCAvFmJ6dXC Logical VolumeManager (LVM)提供了对任意一个LogicalVolume(LV)做“快照”(snapshot)的功能,以此来获得一个分区的状态一致性备份. 在某一个状态下做备份的时候,可能

Creating LVM Logical Volumes

Creating LVM logical volumes involves creating the three layers in the LVM architecture. You first have to take care of the physical volume (PV), then you need to create the volume group (VG) and assign physical volumes to it. As the last step, the l

安装centos6.7——以LVM方式

一.进入安装页面,选择第一项,并按下Enter 二.移动方向键,选择,Skip 三.单击Next,进入到下面两个页面,一概选择默认,点击Next 四.选择Basic Storage Devices ,点击Next 五.选择Yes 六.可以更改Hostname,然后点击Next 七.时区选择Asia/Shanghai,然后点击Next 八.输入密码,点击Next 九.选中Free磁盘,点击Create按钮 十.如下图,点击Create 十一.如下图,选择选项,点击OK 十二.点击Create,进入

lvm(逻辑卷管理)的魅力

近来,随着课程的深入,开始接触到lvm逻辑卷.由开始的不懂,到现在的半知半懂,慢慢的感受到了lvm逻辑卷由内而外散发出的魅力.作为一个小白,为了能更好地学习和理解lvm逻辑卷的知识,特趁着难得的休息时间,总结一下自己所学的关于lvm逻辑卷的知识,有错误的地方,请各位大神指正,共同学习! 本人认为lvm逻辑卷主要有两大魅力: 1.逻辑卷的边界是可变化的. 2.lvm支持快照(snapshot). 各位看官别着急,且听小生慢慢说来: 前言 首先,让我们思考一个问题:为什么会出现LVM技术? 本人是这