![mdadm 在第二个设备 raid1 之前设置模式?](https://linux22.com/image/665725/mdadm%20%E5%9C%A8%E7%AC%AC%E4%BA%8C%E4%B8%AA%E8%AE%BE%E5%A4%87%20raid1%20%E4%B9%8B%E5%89%8D%E8%AE%BE%E7%BD%AE%E6%A8%A1%E5%BC%8F%EF%BC%9F.png)
我有一个问题。服务器使用两个磁盘软 RAID1。磁盘 sda 坏了,更换了磁盘。现在重新启动,将分区表 sdb 复制到 sda 就好了。下一步将引导记录 sdb 复制到 sda 就好了。最后在 RAID 阵列中添加 sda 总是返回错误。错误文本:在列出第二个设备 (/dev/md0) 之前,必须提供一个选项来设置模式。查看命令历史记录。请帮我解决这个问题。mdadm –manage /dev/md0 –add /dev/sda1 命令不起作用。我该怎么办
root@rescue ~ # sfdisk -d /dev/sdb | sfdisk /dev/sda
Checking that no-one is using this disk right now ...
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
OK
Disk /dev/sda: 364801 cylinders, 255 heads, 63 sectors/track
sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/sda: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
/dev/sda1 2048 16779264 16777217 fd Linux raid autodetect
/dev/sda2 16781312 17829888 1048577 fd Linux raid autodetect
/dev/sda3 17831936 2165315584 2147483649 fd Linux raid autodetect
/dev/sda4 2165317632 5860533167 3695215536 f W95 Ext'd (LBA)
/dev/sda5 2165319680 5860531120 3695211441 fd Linux raid autodetect
Warning: partition 1 does not end at a cylinder boundary
Warning: partition 2 does not start at a cylinder boundary
Warning: partition 2 does not end at a cylinder boundary
Warning: partition 3 does not start at a cylinder boundary
Warning: partition 3 does not end at a cylinder boundary
Warning: partition 4 does not start at a cylinder boundary
Warning: partition 4 does not end at a cylinder boundary
Warning: partition 5 does not end at a cylinder boundary
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
Successfully wrote the new partition table
Re-reading the partition table ...
If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
root@rescue ~ # fdisk -l
Disk /dev/sda: 3000.6 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders, total 5860533168 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 identifier: 0x55555555
Device Boot Start End Blocks Id System
/dev/sda1 2048 16779264 8388608+ fd Linux raid autodetect
/dev/sda2 16781312 17829888 524288+ fd Linux raid autodetect
/dev/sda3 17831936 2165315584 1073741824+ fd Linux raid autodetect
/dev/sda4 2165317632 5860533167 1847607768 f W95 Ext'd (LBA)
/dev/sda5 2165319680 5860531120 1847605720+ fd Linux raid autodetect
Disk /dev/sdb: 3000.6 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders, total 5860533168 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 identifier: 0x0006abe2
Device Boot Start End Blocks Id System
/dev/sdb1 2048 16779264 8388608+ fd Linux raid autodetect
/dev/sdb2 16781312 17829888 524288+ fd Linux raid autodetect
/dev/sdb3 17831936 2165315584 1073741824+ fd Linux raid autodetect
/dev/sdb4 2165317632 5860533167 1847607768 f W95 Ext'd (LBA)
/dev/sdb5 2165319680 5860531120 1847605720+ fd Linux raid autodetect
Disk /dev/md0: 8589 MB, 8589869056 bytes
2 heads, 4 sectors/track, 2097136 cylinders, total 16777088 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 identifier: 0x00000000
Disk /dev/md0 doesn't contain a valid partition table
Disk /dev/md1: 536 MB, 536805376 bytes
2 heads, 4 sectors/track, 131056 cylinders, total 1048448 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 identifier: 0x00000000
Disk /dev/md1 doesn't contain a valid partition table
Disk /dev/md2: 1099.5 GB, 1099511431168 bytes
2 heads, 4 sectors/track, 268435408 cylinders, total 2147483264 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 identifier: 0x00000000
Disk /dev/md2 doesn't contain a valid partition table
Disk /dev/md3: 1891.9 GB, 1891948101632 bytes
2 heads, 4 sectors/track, 461901392 cylinders, total 3695211136 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 identifier: 0x00000000
Disk /dev/md3 doesn't contain a valid partition table
root@rescue ~ # dd if=/dev/sdb of=sdb.part bs=1024k count=1
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.0158913 s, 66.0 MB/s
root@rescue ~ # dd if=sdb.part of=/dev/sda bs=1024k count=1
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.00358636 s, 292 MB/s
root@rescue ~ # cat /proc/mdstat
Personalities : [raid1]
md3 : active raid1 sdb5[2]
1847605568 blocks super 1.0 [2/1] [_U]
md2 : active raid1 sdb3[2]
1073741632 blocks super 1.0 [2/1] [_U]
md1 : active raid1 sdb2[2]
524224 blocks super 1.0 [2/1] [_U]
md0 : active raid1 sdb1[2]
8388544 blocks super 1.0 [2/1] [_U]
unused devices: <none>
root@rescue ~ # mdadm –manage /dev/md0 –add /dev/sda1
mdadm: An option must be given to set the mode before a second device
(/dev/md0) is listed
答案1
好的,我发现了问题。正确的命令:
mdadm /dev/md0 -a /dev/sda1
不是 :
mdadm –manage /dev/md0 –add /dev/sda1
最后开始工作!
root@rescue ~ # cat /proc/mdstat
Personalities : [raid1]
md3 : active raid1 sda5[3] sdb5[2]
1847605568 blocks super 1.0 [2/1] [_U]
resync=DELAYED
md2 : active raid1 sda3[3] sdb3[2]
1073741632 blocks super 1.0 [2/1] [_U]
[>....................] recovery = 4.8% (52262208/1073741632) finish=88.1min speed=193162K/sec
md1 : active raid1 sda2[3] sdb2[2]
524224 blocks super 1.0 [2/2] [UU]
md0 : active raid1 sda1[3] sdb1[2]
8388544 blocks super 1.0 [2/2] [UU]
unused devices: <none>