Centos

mdadm 在第二個設備 raid1 之前設置模式?

  • March 27, 2021

我有個問題。伺服器使用兩個磁碟softraid1。磁碟 sda 死了,換了磁碟。現在重新啟動,將分區表 sdb 複製到 sda ok。下一步將引導記錄 sdb 複製到 sda 確定。finaliy add sda in raid array retunr 總是錯誤。錯誤文本:在列出第二個設備 (/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

好的,我發現了問題。正確的命令:

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>

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