我最近将我的 Kubuntu 12.04 工作站搬到了新位置。它正常关闭,但当我在新家重新启动它时,RAID-1 阵列 /dev/md0 消失了!数组的元素被列为备用元素?(!)
RAID-1 阵列 /dev/md0 上仅包含关键文件,操作系统位于其自己的 HDD 上。
阵列的两个元素看起来都很健康,并列为:Linux raid 自动检测。
fdisk -l 输出:
# fdisk -l
Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000669b6
Device Boot Start End Blocks Id System
/dev/sdc1 63 1953520064 976760001 fd Linux raid autodetect
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0000f142
Device Boot Start End Blocks Id System
/dev/sdb1 63 1953520064 976760001 fd Linux raid autodetect
mdadm 输出:
# mdadm --examine /dev/sdb1 /dev/sdc1
/dev/sdb1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : f3d0cc70:52dfd786:d81c7e2d:1c12b06d
Name : forsaken:0
Creation Time : Tue Sep 3 04:52:19 2013
Raid Level : -unknown-
Raid Devices : 0
Avail Dev Size : 1953517954 (931.51 GiB 1000.20 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : active
Device UUID : 75c525b2:cdfbc3c4:918ac90a:a1bedfd0
Update Time : Thu Nov 20 16:50:46 2014
Checksum : ff0eb2ba - correct
Events : 1
Device Role : spare
Array State : ('A' == active, '.' == missing)
/dev/sdc1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : f3d0cc70:52dfd786:d81c7e2d:1c12b06d
Name : forsaken:0
Creation Time : Tue Sep 3 04:52:19 2013
Raid Level : -unknown-
Raid Devices : 0
Avail Dev Size : 1953517954 (931.51 GiB 1000.20 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : active
Device UUID : e62e960a:3adf4b5e:f1fb773f:a7a80cfa
Update Time : Thu Nov 20 16:50:46 2014
Checksum : 4ee25b00 - correct
Events : 1
Device Role : spare
Array State : ('A' == active, '.' == missing)
停止阵列并尝试自组装:
# mdadm --stop /dev/md0
mdadm: stopped /dev/md0
# mdadm --assemble -v --scan --uuid=f3d0cc70:52dfd786:d81c7e2d:1c12b06d
mdadm: looking for devices for /dev/md/0
mdadm: cannot open device /dev/sr0: No medium found
mdadm: no RAID superblock on /dev/sdb
mdadm: no RAID superblock on /dev/sde1
mdadm: no RAID superblock on /dev/sde
mdadm: no RAID superblock on /dev/sdd1
mdadm: no RAID superblock on /dev/sdd
mdadm: no RAID superblock on /dev/sdc
mdadm: no RAID superblock on /dev/sda9
mdadm: no RAID superblock on /dev/sda8
mdadm: no RAID superblock on /dev/sda7
mdadm: no RAID superblock on /dev/sda6
mdadm: no RAID superblock on /dev/sda5
mdadm: no RAID superblock on /dev/sda4
mdadm: no RAID superblock on /dev/sda3
mdadm: no RAID superblock on /dev/sda2
mdadm: no RAID superblock on /dev/sda1
mdadm: no RAID superblock on /dev/sda
mdadm: /dev/sdb1 is identified as a member of /dev/md/0, slot -1.
mdadm: /dev/sdc1 is identified as a member of /dev/md/0, slot -1.
mdadm: added /dev/sdc1 to /dev/md/0 as -1
mdadm: added /dev/sdb1 to /dev/md/0 as -1
mdadm: /dev/md/0 assembled from 0 drives and 2 spares - not enough to start the array.
尝试组装数组并强制其运行:
# mdadm --assemble -v --scan --force --run --uuid=f3d0cc70:52dfd786:d81c7e2d:1c12b06d
mdadm: looking for devices for /dev/md/0
mdadm: cannot open device /dev/sr0: No medium found
mdadm: no RAID superblock on /dev/sdb
mdadm: no RAID superblock on /dev/sde1
mdadm: no RAID superblock on /dev/sde
mdadm: no RAID superblock on /dev/sdd1
mdadm: no RAID superblock on /dev/sdd
mdadm: no RAID superblock on /dev/sdc
mdadm: no RAID superblock on /dev/sda9
mdadm: no RAID superblock on /dev/sda8
mdadm: no RAID superblock on /dev/sda7
mdadm: no RAID superblock on /dev/sda6
mdadm: no RAID superblock on /dev/sda5
mdadm: no RAID superblock on /dev/sda4
mdadm: no RAID superblock on /dev/sda3
mdadm: no RAID superblock on /dev/sda2
mdadm: no RAID superblock on /dev/sda1
mdadm: no RAID superblock on /dev/sda
mdadm: /dev/sdb1 is identified as a member of /dev/md/0, slot -1.
mdadm: /dev/sdc1 is identified as a member of /dev/md/0, slot -1.
mdadm: added /dev/sdc1 to /dev/md/0 as -1
mdadm: added /dev/sdb1 to /dev/md/0 as -1
mdadm: failed to RUN_ARRAY /dev/md/0: Invalid argument
mdadm: Not enough devices to start the array.
这仍然不起作用。如何重新组装 RAID-1 阵列并重新获得数据访问权限?
答案1
RAID 元数据似乎因某种原因被损坏。那是怎么发生的?一旦修复了任何错误配置、错误脚本、硬件问题等,请尝试以只读方式挂载:
mkdir /mnt/{sdb1,sdc1}
mount -o ro,loop,offset=$((2048*512)) /dev/sdb1 /mnt/sdb1
mount -o ro,loop,offset=$((2048*512)) /dev/sdc1 /mnt/sdc1
查看任一方是否已挂载,验证已知类型的文件,比较以查看任一方是否有损坏的文件。这也是进行备份的好时机。
一旦您决定保留哪一边,就可以用它来创建新的 RAID。
首先卸载:
umount /mnt/{sdb1,sdc1}
如果有任何人/dev/md*
按照 的规定使用任一设备/proc/mdstat
,请停止使用。
mdadm --stop /dev/md0
创建一个新的 RAID-1,在此示例中使用/dev/sdb1
.请注意,您必须使用正确的元数据版本和正确的偏移量。因此,仅当上面的安装确实有效时才执行此操作,否则您必须首先确定正确的偏移量。
mdadm --create /dev/md0 --metadata=1.2 --data-offset=2048 \
--level=1 --raid-devices=2 /dev/sdb1 missing
再次将其挂载为只读,以验证它是否确实按预期工作:
mount -o ro,loop /dev/md0 /mnt/sdb1
如果一切正常,最后将丢失的设备添加到您的 RAID 中。
mdadm /dev/md0 --add /dev/sdc1
这将使用 /dev/sdb1 上的数据覆盖 /dev/sdc1,希望使您的 RAID 恢复同步。
顺便说一句,您的分区从扇区 63 开始;如果您的磁盘仍有 512 字节扇区,那就没问题。然而,大多数较新的磁盘使用 4k 扇区,因此如果您必须更换 RAID 中的磁盘,您可能还需要注意这些新磁盘的分区对齐情况。