我不小心删除了所有逻辑卷lvremove
。重新启动后,lvm 备份丢失(live CD),因此我无法使用vgcfgrestore
.testdisk
可以通过分析找到分区,所以它们仍然存在。有没有办法恢复逻辑卷?
TestDisk 6.14, Data Recovery Utility, July 2013
Christophe GRENIER <[email protected]>
http://www.cgsecurity.org
Disk /dev/mapper/Manjaro - 999 GB / 931 GiB - 1952782336 sectors
Partition Start End Size in sectors
> MS Data 264190 82675709 82411520 [ManjaroRoot]
MS Data 61442046 1739163645 1677721600 [ManjaroHome]
P MS Data 1762396158 1844807677 82411520 [ManjaroRoot]
P Linux Swap 1936631800 1936631815 16
dmsetup ls
Manjaro (254:0)
[root@manjaro ~]# dmsetup table Manjaro
0 1952782336 crypt aes-xts-plain 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0 8:4 4096
pv显示-v
Scanning for physical volume names
--- Physical volume ---
PV Name /dev/mapper/Manjaro
VG Name ManjaroVG
PV Size 931.16 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 238376
Free PE 238376
Allocated PE 0
PV UUID 3Vv8c2-O0fr-jOgd-QIBR-WBMY-RGBf-rujHnF
vg显示-v
Finding all volume groups
Finding volume group "ManjaroVG"
--- Volume group ---
VG Name ManjaroVG
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 16
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 931.16 GiB
PE Size 4.00 MiB
Total PE 238376
Alloc PE / Size 0 / 0
Free PE / Size 238376 / 931.16 GiB
VG UUID VWNJNN-iaBv-cLuu-1AAb-nS00-SogZ-z6qDU0
--- Physical volumes ---
PV Name /dev/mapper/Manjaro
PV UUID 3Vv8c2-O0fr-jOgd-QIBR-WBMY-RGBf-rujHnF
PV Status allocatable
Total PE / Free PE 238376 / 238376
lv显示-v
Finding all logical volumes
尝试打造LV
[root@manjaro ~]# dmsetup create ManjaroRoot --table "264190 82411520 linear 8:4 4096"
device-mapper: reload ioctl on ManjaroRoot failed: Invalid argument
Command failed
[root@manjaro ~]# dmsetup create ManjaroRoot --table "264190 82411520 linear 8:4 4096" --readonly
device-mapper: reload ioctl on ManjaroRoot failed: Invalid argument
Command failed
[root@manjaro ~]# dmsetup create ManjaroRoot --table "264190 100 linear 8:4 4096" --readonly
device-mapper: reload ioctl on ManjaroRoot failed: Invalid argument
Command failed
[root@manjaro ~]# dmsetup create ManjaroRoot --table "0 100 linear 8:4 4096" --readonly
[root@manjaro ~]# lvscan
[root@manjaro ~]# dumpe2fs -h /dev/mapper/ManjaroRoot
dumpe2fs 1.42.9 (28-Dec-2013)
dumpe2fs: Bad magic number in super-block while trying to open /dev/mapper/ManjaroRoot
Couldn't find valid filesystem superblock.
越来越近
[root@manjaro ~]# dmsetup create ManjaroRoot --table "0 82411520 linear /dev/mapper/Manjaro 264190" --readonly
[root@manjaro ~]# dumpe2fs -h /dev/mapper/ManjaroRoot
dumpe2fs 1.42.9 (28-Dec-2013)
Filesystem volume name: ManjaroRoot
Last mounted on: /
Filesystem UUID: b5cbe2bf-54cf-46c3-96ed-047ad7e77bcf
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 2575440
Block count: 10301440
Reserved block count: 488035
Free blocks: 2771298
Free inodes: 2140018
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 1021
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 8176
Inode blocks per group: 511
Flex block group size: 16
Filesystem created: Mon Nov 17 06:33:51 2014
Last mount time: Wed Jan 7 15:40:24 2015
Last write time: Wed Jan 7 15:40:24 2015
Mount count: 37
Maximum mount count: -1
Last checked: Mon Nov 17 06:33:51 2014
Check interval: 0 (<none>)
Lifetime writes: 62 GB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 28
Desired extra isize: 28
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: bf1a643c-f34a-456d-bb88-4ea72a94239c
Journal backup: inode blocks
dumpe2fs: A block group is missing an inode table while reading journal inode
安装
[root@manjaro ~]# mount "/dev/mapper/ManjaroHome" "/run/media/manjaro/ManjaroHome"
mount: /dev/mapper/ManjaroHome is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/mapper/ManjaroHome,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
... dmesg 中没有什么新内容
Thunar 尝试了以下操作——也出错了,但至少 dmesg 中有一些东西:
[root@manjaro ~]# mount -t "ext4" -o "uhelper=udisks2,nodev,nosuid" "/dev/mapper/ManjaroHome" "/run/media/manjaro/ManjaroHome"
mount: /dev/mapper/ManjaroHome is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/mapper/ManjaroHome,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
消息
[Wed Jan 21 06:10:04 2015] EXT4-fs (dm-2): VFS: Can't find ext4 filesystem
答案1
如果 LV 没有碎片(在 LVM 级别)并且是简单(线性)卷,那么恢复 LV 应该很容易;它也可能适用于精简配置,但我对此并不熟悉。您只需按照与以前相同的顺序和相同的大小创建它们即可。
我不熟悉testdisk
。如果它告诉您已找到的卷的大小,那么您无需自己查找。
它有助于理解如何dmsetup
工作。我的系统的一个例子:
> dmsetup ls
[...]
linux2-test (254:4)
> dmsetup table linux2-test
0 106496 linear 8:8 384
前 384 个扇区包含 LVM 元数据。如果该卷已被删除,testdisk
则应显示ext4
从扇区 384 开始的卷。然后您可以设置临时设备映射器设备:
> dmsetup create restore-lv-1 --table "0 100 linear 8:8 384" --readonly
扇区数(本示例中为 100)首先未知,因此您可以选择几乎任何值,但它不得超过底层块设备的大小。您可以使用 100 这样的小值,因为您只需要超级块。然后从临时设备读取文件系统大小:
> dumpe2fs -h /dev/mapper/restore-lv-1
dumpe2fs 1.41.14 (22-Dec-2010)
[...]
Block count: 53248
[...]
Block size: 1024
[...]
该卷的大小为 53248*1024=54525952,即 106496 个 512 字节扇区。如果文件系统覆盖了整个 LV(通常是这种情况),那么这也是设备大小。下一个LV的偏移量应该是106496+384=106880。通过此偏移量,您可以重复此过程。
如果您创建一个新的 LV,您应该检查dmsetup table
它是否具有预期的偏移量和长度。