使用lVM进行快照

当使用lvcreate命令拍摄一个逻辑卷的快照时,我发现像这样:

lvcreate –name test –snapshot –size = 2M / dev / VolGroup / lv_root

我很困惑这里的“尺寸”究竟是什么意思? 如果是创build快照的总大小,快照如何适合2Mb?

LVM快照只需要与原始LV不同的空间。 因此,如果您创build1.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.