如何从损坏的raid系统挂载磁盘?

Ton*_*ark 17 raid debian rescue data

我有一个可怕的情况,我必须在救援 Debian Linux 中从损坏的突袭系统中恢复数据。我只想以只读方式将它们全部挂载到 /mnt/rescue 以便能够将 VMWare GSX 映像复制到另一台机器并稍后将它们迁移到 ESXi。相关命令的输出如下。

fdisk -l

Disk /dev/sda: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 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: 0x0005e687

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         523     4200997   fd  Linux raid autodetect
/dev/sda2             524         785     2104515   fd  Linux raid autodetect
/dev/sda3             786      182401  1458830520   fd  Linux raid autodetect

Disk /dev/sdb: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 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: 0x00014fc7

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         523     4200997   fd  Linux raid autodetect
/dev/sdb2             524         785     2104515   fd  Linux raid autodetect
/dev/sdb3             786      182401  1458830520   fd  Linux raid autodetect

Disk /dev/md0: 4301 MB, 4301717504 bytes
2 heads, 4 sectors/track, 1050224 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/md0 doesn't contain a valid partition table

Disk /dev/md1: 2154 MB, 2154954752 bytes
2 heads, 4 sectors/track, 526112 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/md1 doesn't contain a valid partition table
Run Code Online (Sandbox Code Playgroud)

我试图按如下方式安装磁盘。

mount -o ro /dev/sda1 /mnt/rescue
Run Code Online (Sandbox Code Playgroud)

然后我得到以下错误。

mount: unknown filesystem type 'linux_raid_member'
Run Code Online (Sandbox Code Playgroud)

猜测文件系统也不顺利。

mount -o ro -t ext3 /dev/sda1 /mnt/rescue/
mount: /dev/sda1 already mounted or /mnt/rescue/ busy
Run Code Online (Sandbox Code Playgroud)

所以我尝试创建一个虚拟设备如下。

mdadm -A -R /dev/md9 /dev/sda1
Run Code Online (Sandbox Code Playgroud)

这将导致以下消息。

mdadm: cannot open device /dev/sda1: Device or resource busy
mdadm: /dev/sda1 has no superblock - assembly aborted
Run Code Online (Sandbox Code Playgroud)

现在我迷路了,我不知道如何恢复磁盘并取回数据。以下是所有 3 个磁盘的 mda --examine 输出(我认为应该是 3x raid1 磁盘)。

/开发/ sda1:

          Magic : a92b4efc
        Version : 0.90.00
           UUID : 6708215c:6bfe075b:776c2c25:004bd7b2 (local to host rescue)
  Creation Time : Mon Aug 31 17:18:11 2009
     Raid Level : raid1
  Used Dev Size : 4200896 (4.01 GiB 4.30 GB)
     Array Size : 4200896 (4.01 GiB 4.30 GB)
   Raid Devices : 3
  Total Devices : 2
Preferred Minor : 0

    Update Time : Sun Jun  2 00:58:05 2013
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0
       Checksum : 9070963e - correct
         Events : 19720


      Number   Major   Minor   RaidDevice State
this     1       8        1        1      active sync   /dev/sda1

   0     0       0        0        0      removed
   1     1       8        1        1      active sync   /dev/sda1
   2     2       8       17        2      active sync   /dev/sdb1
Run Code Online (Sandbox Code Playgroud)

/开发/ sda2:

          Magic : a92b4efc
        Version : 0.90.00
           UUID : e8f7960f:6bbea0c7:776c2c25:004bd7b2 (local to host rescue)
  Creation Time : Mon Aug 31 17:18:11 2009
     Raid Level : raid1
  Used Dev Size : 2104448 (2.01 GiB 2.15 GB)
     Array Size : 2104448 (2.01 GiB 2.15 GB)
   Raid Devices : 3
  Total Devices : 2
Preferred Minor : 1

    Update Time : Sat Jun  8 07:14:24 2013
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0
       Checksum : 120869e1 - correct
         Events : 3534


      Number   Major   Minor   RaidDevice State
this     1       8        2        1      active sync   /dev/sda2

   0     0       0        0        0      removed
   1     1       8        2        1      active sync   /dev/sda2
   2     2       8       18        2      active sync   /dev/sdb2
Run Code Online (Sandbox Code Playgroud)

/开发/ sda3:

          Magic : a92b4efc
        Version : 0.90.00
           UUID : 4f2b3b67:c3837044:776c2c25:004bd7b2 (local to host rescue)
  Creation Time : Mon Aug 31 17:18:11 2009
     Raid Level : raid5
  Used Dev Size : 1458830400 (1391.25 GiB 1493.84 GB)
     Array Size : 2917660800 (2782.50 GiB 2987.68 GB)
   Raid Devices : 3
  Total Devices : 2
Preferred Minor : 2

    Update Time : Sat Jun  8 14:47:00 2013
          State : clean
 Active Devices : 1
Working Devices : 1
 Failed Devices : 1
  Spare Devices : 0
       Checksum : 2b2b2dad - correct
         Events : 36343894

         Layout : left-symmetric
     Chunk Size : 64K

      Number   Major   Minor   RaidDevice State
this     1       8        3        1      active sync   /dev/sda3

   0     0       0        0        0      removed
   1     1       8        3        1      active sync   /dev/sda3
   2     2       0        0        2      faulty removed

cat /proc/mdstat
Personalities : [raid1]
md2 : inactive sda3[1](S) sdb3[2](S)
      2917660800 blocks

md1 : active raid1 sda2[1] sdb2[2]
      2104448 blocks [3/2] [_UU]

md0 : active raid1 sda1[1] sdb1[2]
      4200896 blocks [3/2] [_UU]
Run Code Online (Sandbox Code Playgroud)

md2 似乎已损坏,它可能是我的 VMWare 映像的raid。

我想通过将 md2 挂载到 RAID 之外来访问来自 md2 的数据(活动磁盘上的数据,即 /dev/sda3)。

只是执行是个好主意吗

mdadm --manage /dev/md2 --remove /dev/sda3 
Run Code Online (Sandbox Code Playgroud)

(它甚至可以工作,因为 fdisk 看不到 md2)?

我应该通过运行重新组装其他突袭 md0 和 md1

mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1
Run Code Online (Sandbox Code Playgroud)

?

更新 0:我无法组装 md0 和 md2。

root@rescue ~ # mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1
mdadm: cannot open device /dev/sda1: Device or resource busy
mdadm: /dev/sda1 has no superblock - assembly aborted
root@rescue ~ # mdadm --assemble /dev/md2 /dev/sda3 /dev/sdb3
mdadm: cannot open device /dev/sda3: Device or resource busy
mdadm: /dev/sda3 has no superblock - assembly aborted
Run Code Online (Sandbox Code Playgroud)

无法使用 mount -t auto 挂载。

root@rescue ~ # mount -t auto -o ro /dev/md0 /mnt/rescue/
/dev/md0 looks like swapspace - not mounted
mount: you must specify the filesystem type
root@rescue ~ # mount -t auto -o ro /dev/md2 /mnt/rescue/
mount: you must specify the filesystem type
Run Code Online (Sandbox Code Playgroud)

挂载 /dev/md1 有效,但上面没有 VMWare 数据。

root@rescue /mnt/rescue # ll
total 139M
-rw-r--r-- 1 root root 513K May 27  2010 abi-2.6.28-19-server
-rw-r--r-- 1 root root 631K Sep 16  2010 abi-2.6.32-24-server
-rw-r--r-- 1 root root 632K Oct 16  2010 abi-2.6.32-25-server
-rw-r--r-- 1 root root 632K Nov 24  2010 abi-2.6.32-26-server
-rw-r--r-- 1 root root 632K Dec  2  2010 abi-2.6.32-27-server
-rw-r--r-- 1 root root 632K Jan 11  2011 abi-2.6.32-28-server
-rw-r--r-- 1 root root 632K Feb 11  2011 abi-2.6.32-29-server
-rw-r--r-- 1 root root 632K Mar  2  2011 abi-2.6.32-30-server
-rw-r--r-- 1 root root 632K Jul 30  2011 abi-2.6.32-33-server
lrwxrwxrwx 1 root root    1 Aug 31  2009 boot -> .
-rw-r--r-- 1 root root 302K Aug  4  2010 coffee.bmp
-rw-r--r-- 1 root root  89K May 27  2010 config-2.6.28-19-server
...
Run Code Online (Sandbox Code Playgroud)

更新1:

我试图停止 md2 和 md0 并再次组装。

mdadm -S /dev/md0

root@rescue ~ # mount -t auto -o ro /dev/md0 /mnt/rescue/
/dev/md0 looks like swapspace - not mounted
mount: you must specify the filesystem type

mdadm -S /dev/md2

root@rescue ~ # mount -t auto -o ro /dev/md2 /mnt/rescue/
mount: you must specify the filesystem type
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

更新 2:

由于以下错误消息,无法从一张磁盘进行组装。

root@rescue ~ # mdadm -S /dev/md2
root@rescue ~ # mdadm --assemble /dev/md2 /dev/sda3
mdadm: /dev/md2 assembled from 1 drive - not enough to start the array.

root@rescue ~ # mdadm -S /dev/md2
mdadm: stopped /dev/md2
root@rescue ~ # mdadm --assemble /dev/md2 /dev/sdb3
mdadm: /dev/md2 assembled from 1 drive - not enough to start the array.
Run Code Online (Sandbox Code Playgroud)

即使新的raid也失败了。

root@rescue ~ # mdadm -S /dev/md9
mdadm: stopped /dev/md9
root@rescue ~ # mdadm --assemble /dev/md9 /dev/sda3
mdadm: /dev/md9 assembled from 1 drive - not enough to start the array.

root@rescue ~ # mdadm -S /dev/md9
mdadm: stopped /dev/md9
root@rescue ~ # mdadm --assemble /dev/md9 /dev/sdb3
mdadm: /dev/md9 assembled from 1 drive - not enough to start the array.
Run Code Online (Sandbox Code Playgroud)

创建新的 md 磁盘也失败。

root@rescue ~ # cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sda1[1] sdb1[2]
      4200896 blocks [3/2] [_UU]

md1 : active raid1 sda2[1] sdb2[2]
      2104448 blocks [3/2] [_UU]

unused devices: <none>
root@rescue ~ # mdadm -A -R /dev/md9 /dev/sda3
mdadm: failed to RUN_ARRAY /dev/md9: Input/output error
mdadm: Not enough devices to start the array.
root@rescue ~ # cat /proc/mdstat
Personalities : [raid1] [raid6] [raid5] [raid4]
md9 : inactive sda3[1]
      1458830400 blocks

md0 : active raid1 sda1[1] sdb1[2]
      4200896 blocks [3/2] [_UU]

md1 : active raid1 sda2[1] sdb2[2]
      2104448 blocks [3/2] [_UU]

unused devices: <none>
root@rescue ~ # mdadm -S /dev/md9
mdadm: stopped /dev/md9
root@rescue ~ # mdadm -A -R /dev/md9 /dev/sdb3
mdadm: failed to RUN_ARRAY /dev/md9: Input/output error
mdadm: Not enough devices to start the array.
Run Code Online (Sandbox Code Playgroud)

更新 3:

从 md2 中删除磁盘不起作用。

mdadm --remove /dev/md2 /dev/sda3
mdadm: cannot get array info for /dev/md2
Run Code Online (Sandbox Code Playgroud)

更新 4:

最后,运行 assemble 并--force希望做到了。我现在正在将文件复制到另一台服务器。

sko*_*rgu 5

如果可能,您应该dd在做任何事情之前制作整个磁盘的映像,以防万一。

一旦mdadm释放它,您应该能够直接挂载 /dev/sda3 :

mdadm --stop /dev/md2

挂载 /dev/sda3 /mnt/rescue

如果这不起作用,testdisk通常可以在原始块设备上找到文件系统。


小智 5

就我而言,我提出了 CentOS 7 并尝试按照此页面上每个人的说明进行操作。我一直遇到设备忙消息。在我看来,你为什么得到

mdadm: 无法打开设备 /dev/sda1: 设备或资源繁忙

错误消息是因为该设备已作为其他东西安装。

我也根本不想对磁盘进行任何更改,因为我的用例是从我的 RAID1 阵列中提取一个非常大的文件,否则无法以任何可能的方式提取该文件,而最快的方法是将其中一个驱动器拉出,我确实想将驱动器放回原处,并且仍然保留我的配置。

这是我在其他网站上进行一些在线研究后所做的: 注意:NAS:0 是我的 NAS 设备的名称,因此请适当替换。

它是自动挂载的,尽管如果您要运行 mount 命令它会说它没有挂载,您可以通过运行来验证它是否已挂载:

[root@localhost Desktop]# cat /proc/mdstat 
Personalities : [raid1] 
md127 : active (auto-read-only) raid1 sdb2[0]
      1952996792 blocks super 1.2 [2/1] [U_]

unused devices: <none>
Run Code Online (Sandbox Code Playgroud)

请注意,它已自动/dev/md127为我安装。

好吧:

[root@localhost Desktop]# mdadm -A -R /dev/md9 /dev/sdb2 
mdadm: /dev/sdb2 is busy - skipping

[root@localhost Desktop]# mdadm --manage --stop /dev/md/NAS\:0 
mdadm: stopped /dev/md/NAS:0

[root@localhost Desktop]# mdadm -A -R /dev/md9 /dev/sdb2
mdadm: /dev/md9 has been started with 1 drive (out of 2).

[root@localhost Desktop]# mount /dev/md9 /mnt/
Run Code Online (Sandbox Code Playgroud)

那是为我做的。

如果有疑问,请使用 DD 驱动器制作完整副本并使用 CentOS 或其他 Linux Live CD。