我做了一件愚蠢的事情,通过发出以下命令来删除逻辑卷。
lvremove -f /dev/cl_dhcppc4/home
然而,我立即从备份文件中恢复了lvm。
vgcfgrestore --file /etc/lvm/archive/cl_dhcppc4_00001-1231497433.vg cl_dhcppc4
但我无法安装这个逻辑卷并访问其中的数据。我可以看到 lvm 和相应的 fdisk。结果如下。
[root@localhost lk]# lvdisplay -m
--- Logical volume ---
LV Path /dev/cl_dhcppc4/swap
LV Name swap
VG Name cl_dhcppc4
LV UUID d0JfQW-CmGW-9gC8-C3I9-HH0c-x3EA-ZRu3qT
LV Write Access read/write
LV Creation host, time dhcppc4, 2016-05-16 10:43:13 +0530
LV Status available
# open 0
LV Size 7.75 GiB
Current LE 1984
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Segments ---
Logical extents 0 to 1983:
Type linear
Physical volume /dev/sda2
Physical extents 0 to 1983
--- Logical volume ---
LV Path /dev/cl_dhcppc4/home
LV Name home
VG Name cl_dhcppc4
LV UUID r1OcXu-JpSL-1pv5-oDPw-k9Q3-3ioS-hIeDnb
LV Write Access read/write
LV Creation host, time dhcppc4, 2016-05-16 10:43:13 +0530
LV Status available
# open 0
LV Size 873.21 GiB
Current LE 223541
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Segments ---
Logical extents 0 to 223540:
Type linear
Physical volume /dev/sda2
Physical extents 1984 to 225524
--- Logical volume ---
LV Path /dev/cl_dhcppc4/root
LV Name root
VG Name cl_dhcppc4
LV UUID MZTJcW-909k-cyjf-e3ls-K8hl-lYNm-Gk97kA
LV Write Access read/write
LV Creation host, time dhcppc4, 2016-05-16 10:43:16 +0530
LV Status available
# open 1
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Segments ---
Logical extents 0 to 12799:
Type linear
Physical volume /dev/sda2
Physical extents 225525 to 238324
我需要从 LV 路径 /dev/cl_dhcppc4/home 恢复数据。 Fdisk 给我以下结果。
[root@localhost lk]# fdisk -l
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x000e45e4
Device Boot Start End Blocks Id System
/dev/sda1 2048 1026047 512000 83 Linux
/dev/sda2 * 1026048 1953523711 976248832 8e Linux LVM
Disk /dev/mapper/cl_dhcppc4-root: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/cl_dhcppc4-swap: 8321 MB, 8321499136 bytes, 16252928 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/cl_dhcppc4-home: 937.6 GB, 937598910464 bytes, 1831247872 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
如果我尝试挂载磁盘,则会出现 nfs、ext3 文件类型的文件系统类型错误。
[root@localhost lk]# mount /dev/mapper/cl_dhcppc4-home /hd
mount: /dev/mapper/cl_dhcppc4-home is write-protected, mounting read-only
mount: unknown filesystem type '(null)'
[root@localhost lk]# mount -t nfs /dev/mapper/cl_dhcppc4-home /hd
mount.nfs: remote share not in 'host:dir' format
[root@localhost lk]# mount -t ext3 /dev/mapper/cl_dhcppc4-home /hd
mount: wrong fs type, bad option, bad superblock on /dev/mapper/cl_dhcppc4-home,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
请帮助从这个混乱中恢复数据。我在这张磁盘上有一些重要的数据。
答案1
@Bigon为了检索数据,我自己尝试并发出了一些可能改变 LVM 拓扑的命令。我在 lvremove 和 vgcfgrestore 之间的历史记录如下。 Commnad 86 删除了 LVM,并且命令 153 被正确检索。但在这期间我创建了一些lvm并删除了它们。
86 lvremove -f /dev/cl_dhcppc4/home
87 lvscan
88 lvremove -f /dev/cl_dhcppc4/home
89 fdisk -l
90 mount /dev/sda2 /dev/sda2
91 lvscan
92 mount
94 lvdisplay cl_dhcppc4
100 lvcreate --extents EFROM-ETO --zero n --name customer007 YOUR-VG-NAME /dev/yourpv:PFROM-PTO
101 lvcreate --extents EFROM-ETO --zero n --name test007 test007 /dev/sda2:PFROM-PTO
102 lvcreate --help
103 lvcreate /dev/sda2
104 fdisk -l
105 pvs
106 lvdisplay cl_dhcppc4
110 lvdisplay
111 dmsetup ls
112 dmsetup table cl_dhcppc4-home
113 dmsetup table cl_dhcppc4-root
116 pvcreate /dev/sda2
117 pvcreate -ff /dev/sda2
118 vgcreate vgpool /dev/sda2
119 pvcreate -ff /dev/sda2
120 pvs
121 sh /etc/rd.d/rc.lvm2 start
122 vgscan
123 vgchange --available n
124 lvcreate -L 3G -n cl_dhcppc4 vgpool
125 lvcreate -L 3G -n lvstuff cl_dhcppc4
129 lvcreate -l 20 -n logical_vol1 cl_dhcppc4
130 lvdisplay
131 lvremove /dev/cl_dhcppc4/lvstuff
132 lvremove /dev/cl_dhcppc4/logical_vol1
152 vgcfgrestore –file /etc/lvm/archive/cl_dhcppc4_00001-1231497433.vg
153 vgcfgrestore –file /etc/lvm/archive/cl_dhcppc4_00001-1231497433.vg cl_dhcppc4
lsblk 未显示受影响文件系统 cl_dhcppc4-home 的 FSTYPE 和 UUID。
[root@localhost lk]# lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
├─sda1 xfs acc94e95-aff5-44dc-acd6-e53ab9b85970
└─sda2 LVM2_member V3EMqc-bTyq-v8fz-vZfU-bUvv-torq-lEitpO
├─cl_dhcppc4-root xfs 6d107d35-4ba3-4f08-97ca-ac33338cf97c /
├─cl_dhcppc4-swap swap f452dcca-9254-42e4-bee6-dc9c760ade58
└─cl_dhcppc4-home
sr0
答案2
我觉得不太好闻。我不认为FS在这里还能用。您可能需要以其他方式恢复数据,也许看看https://help.ubuntu.com/community/DataRecovery