Linux

從 LVM 下損壞的 ext4 分區恢復數據 - fsck 還是先修復壞塊?

  • September 20, 2015

我在筆記本上使用 Linux。我的筆記本最近掉在地上,現在我正試圖從損壞的硬碟中保存盡可能多的數據。我可以從 Linux live CD 啟動筆記本。

**長話短說:**一個 ext4 分區不可掛載,但我可以嘗試通過 fsck.ext4 修復它。我也可以嘗試先嘗試恢復硬碟上的壞塊(可能是通過 SpinRite)。我先做什麼?

詳細資訊:

這是我的驅動器:

# fdisk -l

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000080

  Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        3824    30716248+   7  HPFS/NTFS
/dev/sda2            3825       19449   125507812+  83  Linux
/dev/sda3           19450       19457       64260   83  Linux

讓我們忘記 /dev/sda1 NTFS 分區,這並不重要。第三個分區 /dev/sda3 只是 /boot,也不重要。第二個 /dev/sda2 是 LVM 的物理空間(見下文)。

邏輯組 /dev/group1/arch 由 dm-crypt LUKS 加密,我無法打開它,那裡的數據可能失去。邏輯組 /dev/group1/data 和 /dev/group1/data2 是 ext4 卷。我可以掛載 /dev/group1/data2 ( mount -t ext4 -o ro,noload /dev/group1/data2 /mnt/data2 ) 並在外部驅動器上備份數據。但我無法掛載/dev/group1/data:

# mount -t ext4 -o ro,noload /dev/group1/data /x/data
mount: wrong fs type, bad option, bad superblock on /dev/mapper/group1-data,
      missing codepage or helper program, or other error
      In some cases useful info is found in syslog - try
      dmesg | tail  or so

fsck 不起作用:

# fsck.ext4 -n /dev/group1/data
e2fsck 1.41.11 (14-Mar-2010)
fsck.ext4: Attempt to read block from filesystem resulted in short read while trying to open /dev/group1/data
Could this be a zero-length partition?

dumpe2fs 也沒有找到超級塊:

# dumpe2fs /dev/group1/data
dumpe2fs 1.41.11 (14-Mar-2010)
dumpe2fs: Attempt to read block from filesystem resulted in short read while trying to open /dev/group1/data
Couldn't find valid filesystem superblock.

我唯一能做的就是嘗試找到超級塊通常在哪裡:

# mkfs.ext4 -n /dev/group1/data
mke2fs 1.41.11 (14-Mar-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
5242880 inodes, 20971520 blocks
1048576 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
640 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
   32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
   4096000, 7962624, 11239424, 20480000

…並使用以下超級塊之一啟動 fsck:

# fsck.ext4 -n -b 229376 /dev/group1/data
e2fsck 1.41.11 (14-Mar-2010)
One or more block group descriptor checksums are invalid.  Fix? no

Group descriptor 0 checksum is invalid.  IGNORED.
Group descriptor 1 checksum is invalid.  IGNORED.
Group descriptor 2 checksum is invalid.  IGNORED.
Group descriptor 3 checksum is invalid.  IGNORED.
Group descriptor 4 checksum is invalid.  IGNORED.
Group descriptor 5 checksum is invalid.  IGNORED.
...
Group descriptor 637 checksum is invalid.  IGNORED.
Group descriptor 638 checksum is invalid.  IGNORED.
Group descriptor 639 checksum is invalid.  IGNORED.
/dev/group1/data contains a file system with errors, check forced.
Resize inode not valid.  Recreate? no

Pass 1: Checking inodes, blocks, and sizes
...here I pressed Ctrl-C...

所以 - 它顯示了很多錯誤,但它似乎會嘗試修復(如果我使用 fsck.ext4 -y 而不是 fsck.ext4 -n 當然)。

其他選項 - 我的 frind 有 SpinRite 6 啟動 CD,它被告知是修復壞塊的最佳程序之一。

所以我的問題是——我應該

  1. 首先嘗試使用 SpinRite 修復壞塊,然後嘗試 fsck.ext4 -y(或者甚至更好地將整個原始分區轉儲到外部硬碟上的一個大文件中,製作副本,將副本掛載為環回,然後嘗試 fckk.ext4 -y)
  2. 嘗試先 fsck.ext4 -y 希望之後 ome 數據可以讀取,將這些數據備份到外部硬碟上(然後最終嘗試 SpinRite)?
  3. 還是做其他事情?

非常感謝任何提示。

LVM結構:

# pvdisplay 
 --- Physical volume ---
 PV Name               /dev/sda2
 VG Name               group1
 PV Size               119.69 GiB / not usable 2.22 MiB
 Allocatable           yes (but full)
 PE Size               4.00 MiB
 Total PE              30641
 Free PE               0
 Allocated PE          30641
 PV UUID               0k3Zl5-Q7BD-rb8J-9jTZ-2uii-GSGd-B339JB

# vgdisplay 
 --- Volume group ---
 VG Name               group1
 System ID             
 Format                lvm2
 Metadata Areas        1
 Metadata Sequence No  10
 VG Access             read/write
 VG Status             resizable
 MAX LV                0
 Cur LV                4
 Open LV               1
 Max PV                0
 Cur PV                1
 Act PV                1
 VG Size               119.69 GiB
 PE Size               4.00 MiB
 Total PE              30641
 Alloc PE / Size       30641 / 119.69 GiB
 Free  PE / Size       0 / 0   
 VG UUID               kKhvri-OVpL-uhCP-T4an-qXIJ-4XL0-kn9Ifi



# lvdisplay 
 --- Logical volume ---
 LV Name                /dev/group1/swap
 VG Name                group1
 LV UUID                wpDink-01q0-peLc-29at-5kgP-YO3a-8bNrb7
 LV Write Access        read/write
 LV Status              available
 # open                 0
 LV Size                1.50 GiB
 Current LE             384
 Segments               1
 Allocation             contiguous
 Read ahead sectors     auto
 - currently set to     256
 Block device           252:0

 --- Logical volume ---
 LV Name                /dev/group1/arch
 VG Name                group1
 LV UUID                S1TZkr-y62z-dOuc-D38G-nuCH-1ilc-y2jqMa
 LV Write Access        read/write
 LV Status              available
 # open                 0
 LV Size                15.00 GiB
 Current LE             3840
 Segments               1
 Allocation             contiguous
 Read ahead sectors     auto
 - currently set to     256
 Block device           252:1

 --- Logical volume ---
 LV Name                /dev/group1/data
 VG Name                group1
 LV UUID                2R4LNv-sHPh-E7ES-goIF-5nUz-tQyj-GOiwvC
 LV Write Access        read/write
 LV Status              available
 # open                 0
 LV Size                80.00 GiB
 Current LE             20480
 Segments               1
 Allocation             contiguous
 Read ahead sectors     auto
 - currently set to     256
 Block device           252:2

 --- Logical volume ---
 LV Name                /dev/group1/data2
 VG Name                group1
 LV UUID                4VqpZj-uOBi-OAIZ-1IXA-G6mj-Qgfb-c6RYqw
 LV Write Access        read/write
 LV Status              available
 # open                 1
 LV Size                23.19 GiB
 Current LE             5937
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto
 - currently set to     256
 Block device           252:3

我要做的第一件事是使用 liveCD 中的 ddrescue 來製作驅動器的備份映像。如果驅動器受到物理損壞,則有可能在有限的時間內完全失效。然後,製作該圖像的副本以進行處理。

從那裡,我沒有你沒有嘗試過的建議。其他比我聰明的人將不得不在那裡幫助你。

引用自:https://serverfault.com/questions/167029