我已经为逻辑卷创建了快照,如下所示:
sudo lvcreate -v -s -L 100M -n lv2_snap /dev/vg1/lv2
我能够安装该快照,检查文件,看起来不错。
然后,对快照进行磁盘转储:
sudo dd if=/dev/vg1/lv2_snap of=lv2_snap.dd
之后,我尝试从磁盘转储中恢复:
sudo dd if=lv2_snap.dd of=/dev/vg1/lv2_snap
然后我尝试安装lv2_snap
,我得到了
can't ready superblock.
sudo mount /dev/vg1/lv2_snap snap_recover/
mount: /home/wxue/snap_recover: can't read superblock on /dev/mapper/vg1-lv2_snap
。
尝试从备份中恢复超级块不起作用:
sudo mke2fs -n /dev/vg1/lv2_snap
mke2fs 1.44.6 (5-Mar-2019)
Creating filesystem with 512000 1k blocks and 128016 inodes
Filesystem UUID: 5078cdaa-b0fc-42ca-a173-94c4dcc0a739
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
sudo e2fsck -b 8193 /dev/vg1/lv2_snap
e2fsck 1.44.6 (5-Mar-2019)
e2fsck: Invalid argument while trying to open /dev/vg1/lv2_snap
如何从 dd 文件恢复?
添加 lvm 版本:
$sudo lvm version
LVM version: 2.02.176(2) (2017-11-03)
Library version: 1.02.145 (2017-11-03)
Driver version: 4.39.0
Configuration: ./configure --build=x86_64-linux-gnu --prefix=/usr --includedir=${prefix}/include --mandir=${prefix}/share/man --infodir=${prefix}/share/info --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libdir=${prefix}/lib/x86_64-linux-gnu --libexecdir=${prefix}/lib/x86_64-linux-gnu --runstatedir=/run --disable-maintainer-mode --disable-dependency-tracking --exec-prefix= --bindir=/bin --libdir=/lib/x86_64-linux-gnu --sbindir=/sbin --with-usrlibdir=/usr/lib/x86_64-linux-gnu --with-optimisation=-O2 --with-cache=internal --with-clvmd=corosync --with-cluster=internal --with-device-uid=0 --with-device-gid=6 --with-device-mode=0660 --with-default-pid-dir=/run --with-default-run-dir=/run/lvm --with-default-locking-dir=/run/lock/lvm --with-thin=internal --with-thin-check=/usr/sbin/thin_check --with-thin-dump=/usr/sbin/thin_dump --with-thin-repair=/usr/sbin/thin_repair --enable-applib --enable-blkid_wiping --enable-cmdlib --enable-cmirrord --enable-dmeventd --enable-dbus-service --enable-lvmetad --enable-lvmlockd-dlm --enable-lvmlockd-sanlock --enable-lvmpolld --enable-notify-dbus --enable-pkgconfig --enable-readline --enable-udev_rules --enable-udev_sync
$uname -a
Linux WVM 5.0.0-21-generic #22-Ubuntu SMP Tue Jul 2 13:27:33 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
答案1
关于逻辑卷的更多信息,我尝试使用精简池和缓存
sudo lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
cache vg1 Cwi---C--- 100.00m
cache1 vg1 Cwi---C--- 100.00m
lv2 vg1 owi-aotz-- 500.00m thin-pool 4.97
lv2_snap vg1 swi-I-s--- 100.00m lv2 100.00
lv3 vg1 Vwi-a-tz-- 500.00m thin-pool 0.00
lv4 vg1 -wi-a----- 500.00m
lvol0 vg1 -wi-a----- 4.00m
lvol2 vg1 Cwi---C--- 100.00m
thin-pool vg1 twi-aotz-- 500.00m 4.97 11.23
lv 转换也失败,如下所示:
sudo lvconvert --merge /dev/vg1/lv2_snap
Unable to merge invalidated snapshot LV "lv2_snap".
这是我发现的,我无法恢复到快照逻辑卷,我必须创建一个新的逻辑卷,然后恢复它。
sudo lvcreate -L 500M -n lv5 vg1
WARNING: Sum of all thin volume sizes (1000.00 MiB) exceeds the size of thin pools (no free space in volume group).
WARNING: You have not turned on protection against thin pools running out of space.
WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
Logical volume "lv5" created.
$sudo dd if=lv2snap.dd of=/dev/vg1/lv5
sudo mount /dev/1024000+0 records in
1024000+0 records out
524288000 bytes (524 MB, 500 MiB) copied, 17.9297 s, 29.2 MB/s
$sudo mount /dev/vg1/lv5 snap_recover/