Page MenuHomeVyOS Platform

RAID1: "add raid md0 member sda1" does not restore boot sector
Closed, ResolvedPublicBUG

Description

When a RAID1 disk is replaced, the data partition is restored but not the boot sector.

Data was restored

Reproduce

Remove disk from array

vyos@vyos:~$ delete raid md0 member sda1
removing member  from RAID set md0
[ 1542.813574] md/raid1:md0: Disk failure on sda1, disabling device.
[ 1542.813574] md/raid1:md0: Operation continuing on 1 devices.
mdadm: set /dev/sda1 faulty in /dev/md0
mdadm: hot removed /dev/sda1 from /dev/md0

Clean data on disk

vyos@vyos:~$ dd if=/dev/zero of=/dev/sda bs=10M
dd: error writing '/dev/sda': No space left on device
205+0 records in
204+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 8.26372 s, 260 MB/s
vyos@vyos:~$ cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[0]
      2094016 blocks [2/1] [U_]

unused devices: <none>

Re-create partition table on sda

vyos@vyos:~$ format disk sda like sdb

This will re-format disk sda so that it has the same disk
partion sizes and offsets as sdb. This will not copy
data from sdb to sda. But this will erase all
data on sda.

Do you wish to proceed? [y/N] y
Re-formating disk drive sda...
Making backup copy of partitions...
Partition table backup saved to /var/tmp/backup_sda.20211225-1947
Deleting old partitions...
Creating new partitions on sda based on sdb...
Done!

Re-add disk sda to array md0

vyos@vyos:~$ add raid md0 member sda1
adding member sda1 to RAID set md0
mdadm: hot added /dev/sda1
vyos@vyos:~$ cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sda1[2] sdb1[0]
      2094016 blocks [2/1] [U_]
      [========>............]  recovery = 43.7% (916160/2094016) finish=0.0min speed=229040K/sec

unused devices: <none>
vyos@vyos:~$ cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sda1[1] sdb1[0]
      2094016 blocks [2/2] [UU]

unused devices: <none>

Verify

vyos@vyos:~$ dd if=/dev/sda bs=512 count=1 | xxd
1+0 records in
1+0 records out
512 bytes copied, 0.000679582 s, 753 kB/s
00000000: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000010: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000030: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000040: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000050: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000060: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000070: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000080: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000090: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000a0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000b0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000c0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000d0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000e0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000000f0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000100: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000110: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000120: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000130: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000140: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000150: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000160: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000170: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000180: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000190: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001a0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001b0: 0000 0000 0000 0000 b8be 07af 0000 8021  ...............!
000001c0: 0300 fd2f fef0 0008 0000 00e8 3f00 0000  .../........?...
000001d0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001e0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001f0: 0000 0000 0000 0000 0000 0000 0000 55aa  ..............U.
vyos@vyos:~$ dd if=/dev/sdb bs=512 count=1 | xxd
1+0 records in
1+0 records out
512 bytes copied, 0.000134586 s, 3.8 MB/s
00000000: eb63 9010 8ed0 bc00 b0b8 0000 8ed8 8ec0  .c..............
00000010: fbbe 007c bf00 06b9 0002 f3a4 ea21 0600  ...|.........!..
00000020: 00be be07 3804 750b 83c6 1081 fefe 0775  ....8.u........u
00000030: f3eb 16b4 02b0 01bb 007c b280 8a74 018b  .........|...t..
00000040: 4c02 cd13 ea00 7c00 00eb fe00 0000 0000  L.....|.........
00000050: 0000 0000 0000 0000 0000 0080 0100 0000  ................
00000060: 0000 0000 fffa 9090 f6c2 8074 05f6 c270  ...........t...p
00000070: 7402 b280 ea79 7c00 0031 c08e d88e d0bc  t....y|..1......
00000080: 0020 fba0 647c 3cff 7402 88c2 52be 807d  . ..d|<.t...R..}
00000090: e817 01be 057c b441 bbaa 55cd 135a 5272  .....|.A..U..ZRr
000000a0: 3d81 fb55 aa75 3783 e101 7432 31c0 8944  =..U.u7...t21..D
000000b0: 0440 8844 ff89 4402 c704 1000 668b 1e5c  [email protected]..\
000000c0: 7c66 895c 0866 8b1e 607c 6689 5c0c c744  |f.\.f..`|f.\..D
000000d0: 0600 70b4 42cd 1372 05bb 0070 eb76 b408  ..p.B..r...p.v..
000000e0: cd13 730d 5a84 d20f 83d8 00be 8b7d e982  ..s.Z........}..
000000f0: 0066 0fb6 c688 64ff 4066 8944 040f b6d1  [email protected]....
00000100: c1e2 0288 e888 f440 8944 080f b6c2 c0e8  [email protected]......
00000110: 0266 8904 66a1 607c 6609 c075 4e66 a15c  .f..f.`|f..uNf.\
00000120: 7c66 31d2 66f7 3488 d131 d266 f774 043b  |f1.f.4..1.f.t.;
00000130: 4408 7d37 fec1 88c5 30c0 c1e8 0208 c188  D.}7....0.......
00000140: d05a 88c6 bb00 708e c331 dbb8 0102 cd13  .Z....p..1......
00000150: 721e 8cc3 601e b900 018e db31 f6bf 0080  r...`......1....
00000160: 8ec6 fcf3 a51f 61ff 265a 7cbe 867d eb03  ......a.&Z|..}..
00000170: be95 7de8 3400 be9a 7de8 2e00 cd18 ebfe  ..}.4...}.......
00000180: 4752 5542 2000 4765 6f6d 0048 6172 6420  GRUB .Geom.Hard
00000190: 4469 736b 0052 6561 6400 2045 7272 6f72  Disk.Read. Error
000001a0: 0d0a 00bb 0100 b40e cd10 ac3c 0075 f4c3  ...........<.u..
000001b0: 0000 0000 0000 0000 b8be 07af 0000 8004  ................
000001c0: 0104 fdfe c2ff 0008 0000 00e8 3f00 0000  ............?...
000001d0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001e0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001f0: 0000 0000 0000 0000 0000 0000 0000 55aa  ..............U.

Details

Difficulty level
Unknown (require assessment)
Version
1.3.0
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Perfectly compatible
Issue type
Bug (incorrect behavior)

Related Objects

Mentioned In
1.3.3
1.3.1