使用 lVM 拍摄快照

使用 lVM 拍摄快照

在使用 lvcreate 命令拍摄逻辑卷快照时,我发现以下内容:

lvcreate --name 测试 --snapshot --size=2M /dev/VolGroup/lv_root

我搞不清楚这里的“大小”到底是什么意思?如果它是要创建的快照的总大小,那么 / 的快照如何能容纳在 2Mb 中?

答案1

LVM 快照所需的空间与原始 LV 不同。因此,如果您创建 1.0GB 卷的 LVM 快照,则快照大小将为 0(嗯,我想除了一些元数据)。如果您要更改原始 LV 上的数据,比如说您下载了一个 200MB 的文件,则 LVM 快照将为 200MB。如果您将快照大小设置为 2MB,则该快照现在将无法使用,因为它无法写入剩余的 198MB。

摘自手册:

       -s, --snapshot
          Create  a snapshot logical volume (or snapshot) for an existing,
          so called original logical volume (or origin).   Snapshots  pro-
          vide  a  'frozen  image' of the contents of the origin while the
          origin can still be updated. They enable consistent backups  and
          online  recovery of removed/overwritten data/files. The snapshot
          does not need the same amount of storage the origin  has.  In  a
          typical  scenario,  15-20% might be enough. In case the snapshot
          runs out of storage, use lvextend(8) to  grow  it.  Shrinking  a
          snapshot  is  supported by lvreduce(8) as well. Run lvdisplay(8)
          on the snapshot in order to check how much data is allocated  to
          it.   Note  that a small amount of the space you allocate to the
          snapshot is used to track the locations of the chunks  of  data,
          so  you  should  allocate  slightly more space than you actually
          need and monitor the rate at which the snapshot data is  growing
          so you can avoid running out of space.

相关内容