Andy Smith
2024-09-09 20:10:01 UTC
Hi,
I've come into possession of a machine running Debian 10 with two
drives in it; sda and sdb. These have been labelled with a DOS MBR
and partitioned. The first partition starts at sector 2048 of both
drives (512 byte sectors). It appears that GRUB has been installed
on both sda and sdb:
$ sudo dd if=/dev/sda bs=1 count=512 2>/dev/null | xxd
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 52bb 1704 . ..d|<.t...R...
00000090: f607 0374 06be 887d e817 01be 057c b441 ...t...}.....|.A
000000a0: bbaa 55cd 135a 5272 3d81 fb55 aa75 3783 ..U..ZRr=..U.u7.
000000b0: e101 7432 31c0 8944 0440 8844 ff89 4402 ***@.D..D.
000000c0: c704 1000 668b 1e5c 7c66 895c 0866 8b1e ....f..\|f.\.f..
000000d0: 607c 6689 5c0c c744 0600 70b4 42cd 1372 `|f.\..D..p.B..r
000000e0: 05bb 0070 eb76 b408 cd13 730d 5a84 d20f ...p.v....s.Z...
000000f0: 83d0 00be 937d e982 0066 0fb6 c688 64ff .....}...f....d.
00000100: 4066 8944 040f b6d1 c1e2 0288 e888 f440 @f.D...........@
00000110: 8944 080f b6c2 c0e8 0266 8904 66a1 607c .D.......f..f.`|
00000120: 6609 c075 4e66 a15c 7c66 31d2 66f7 3488 f..uNf.\|f1.f.4.
00000130: d131 d266 f774 043b 4408 7d37 fec1 88c5 .1.f.t.;D.}7....
00000140: 30c0 c1e8 0208 c188 d05a 88c6 bb00 708e 0........Z....p.
00000150: c331 dbb8 0102 cd13 721e 8cc3 601e b900 .1......r...`...
00000160: 018e db31 f6bf 0080 8ec6 fcf3 a51f 61ff ...1..........a.
00000170: 265a 7cbe 8e7d eb03 be9d 7de8 3400 bea2 &Z|..}....}.4...
00000180: 7de8 2e00 cd18 ebfe 4752 5542 2000 4765 }.......GRUB .Ge
00000190: 6f6d 0048 6172 6420 4469 736b 0052 6561 om.Hard Disk.Rea
000001a0: 6400 2045 7272 6f72 0d0a 00bb 0100 b40e d. Error........
000001b0: cd10 ac3c 0075 f4c3 f2b8 530e 0000 8020 ...<.u....S....
000001c0: 2100 fd35 373e 0008 0000 0038 0f00 0035 !..57>.....8...5
000001d0: 383e fd51 6031 0040 0f00 0098 3b00 0051 8>.Q`***@....;..Q
000001e0: 6131 fdef 45aa 00d8 4a00 00d0 1d00 0010 a1..E...J.......
000001f0: 64ab 05fe ffff feaf 6800 0230 27df 55aa d.......h..0'.U.
$ sudo dd if=/dev/sdb bs=1 count=512 2>/dev/null | xxd
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 ***@.D..D.....f..\
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 ***@f.D....
00000100: c1e2 0288 e888 f440 8944 080f b6c2 c0e8 ***@.D......
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 481f 78c6 0000 8020 ........H.x....
000001c0: 2100 fd35 373e 0008 0000 0038 0f00 0035 !..57>.....8...5
000001d0: 383e fd51 6031 0040 0f00 0098 3b00 0051 8>.Q`***@....;..Q
000001e0: 6131 fdef 45aa 00d8 4a00 00d0 1d00 0010 a1..E...J.......
000001f0: 64ab 05fe ffff feaf 6800 0230 27df 55aa d.......h..0'.U.
This machine does not boot properly, going immediately to a grub>
prompt. If, during the boot process, I force the BIOS to boot from
sdb then it does boot properly.
This machine is doing something useful at the moment, so I am under
pressure to not have it out of service for extended periods of time
while I tinker with it.
The drives are partitioned and set up for MD RAID-1. The current
grub config loads the mdraid1x module and is set to consider its
root as array UUID aca790f8:3fcc9451:e65b1821:87ee8ab7:
$ grep root=\' /boot/grub/grub.cfg | sed 's/^\t*//' | uniq
set root='mduuid/aca790f83fcc9451e65b182187ee8ab7'
$ for dev in sda1 sdb1; do sudo mdadm -E "/dev/$dev" | grep 'Array UUID'; done
Array UUID : aca790f8:3fcc9451:e65b1821:87ee8ab7
Array UUID : aca790f8:3fcc9451:e65b1821:87ee8ab7
/proc/mdstat shows all the MD arrays are currently running fine with
paired partitions from sda and sdb.
So, it looks like this machine is redundant against drive failure
EXCEPT for during boot, and it's just something odd with the MBR of
sda.
What is the simplest way to make it work, and be redundant?
Normally for things of this era (i.e. not UEFI) I would be taking
care to grub-install on both drives after install. Clearly someone
did install grub to both, but sda's copy is no longer working.
Perhaps grub has been upgraded since then, causing another
grub-install against sda (only), and then the BIOS's idea of drive
order flipped around?
Can I simply copy the first 512 bytes of sdb to the start of sda?
I do not particularly want to run grub-install, as the MBR of sdb is
known good at the moment. Perhaps though I could run:
$ sudo grub-install /dev/sda
and then compare again the first 512 bytes of each drive?
Is there any way to sanity check what an MBR will do, grub-wise? My
searching found grub-emu but I couldn't find any useful
documentation and didn't want to just run it. Similarly grub-probe.
I was kind of hoping that there would be something I could run which
would say "yes, this MBR has grub v<whatever> and is set to find its
grub.cfg on (hdX)", then I might be able to see some difference in
what the MBR of sda wants to do. I'm particularly interested in
seeing if the binary grub data in the MBR actually comes from the
grub that is installed from the grub-pc package in the OS.
Thanks,
Andy
--
https://bitfolk.com/ -- No-nonsense VPS hosting
I've come into possession of a machine running Debian 10 with two
drives in it; sda and sdb. These have been labelled with a DOS MBR
and partitioned. The first partition starts at sector 2048 of both
drives (512 byte sectors). It appears that GRUB has been installed
on both sda and sdb:
$ sudo dd if=/dev/sda bs=1 count=512 2>/dev/null | xxd
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 52bb 1704 . ..d|<.t...R...
00000090: f607 0374 06be 887d e817 01be 057c b441 ...t...}.....|.A
000000a0: bbaa 55cd 135a 5272 3d81 fb55 aa75 3783 ..U..ZRr=..U.u7.
000000b0: e101 7432 31c0 8944 0440 8844 ff89 4402 ***@.D..D.
000000c0: c704 1000 668b 1e5c 7c66 895c 0866 8b1e ....f..\|f.\.f..
000000d0: 607c 6689 5c0c c744 0600 70b4 42cd 1372 `|f.\..D..p.B..r
000000e0: 05bb 0070 eb76 b408 cd13 730d 5a84 d20f ...p.v....s.Z...
000000f0: 83d0 00be 937d e982 0066 0fb6 c688 64ff .....}...f....d.
00000100: 4066 8944 040f b6d1 c1e2 0288 e888 f440 @f.D...........@
00000110: 8944 080f b6c2 c0e8 0266 8904 66a1 607c .D.......f..f.`|
00000120: 6609 c075 4e66 a15c 7c66 31d2 66f7 3488 f..uNf.\|f1.f.4.
00000130: d131 d266 f774 043b 4408 7d37 fec1 88c5 .1.f.t.;D.}7....
00000140: 30c0 c1e8 0208 c188 d05a 88c6 bb00 708e 0........Z....p.
00000150: c331 dbb8 0102 cd13 721e 8cc3 601e b900 .1......r...`...
00000160: 018e db31 f6bf 0080 8ec6 fcf3 a51f 61ff ...1..........a.
00000170: 265a 7cbe 8e7d eb03 be9d 7de8 3400 bea2 &Z|..}....}.4...
00000180: 7de8 2e00 cd18 ebfe 4752 5542 2000 4765 }.......GRUB .Ge
00000190: 6f6d 0048 6172 6420 4469 736b 0052 6561 om.Hard Disk.Rea
000001a0: 6400 2045 7272 6f72 0d0a 00bb 0100 b40e d. Error........
000001b0: cd10 ac3c 0075 f4c3 f2b8 530e 0000 8020 ...<.u....S....
000001c0: 2100 fd35 373e 0008 0000 0038 0f00 0035 !..57>.....8...5
000001d0: 383e fd51 6031 0040 0f00 0098 3b00 0051 8>.Q`***@....;..Q
000001e0: 6131 fdef 45aa 00d8 4a00 00d0 1d00 0010 a1..E...J.......
000001f0: 64ab 05fe ffff feaf 6800 0230 27df 55aa d.......h..0'.U.
$ sudo dd if=/dev/sdb bs=1 count=512 2>/dev/null | xxd
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 ***@.D..D.....f..\
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 ***@f.D....
00000100: c1e2 0288 e888 f440 8944 080f b6c2 c0e8 ***@.D......
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 481f 78c6 0000 8020 ........H.x....
000001c0: 2100 fd35 373e 0008 0000 0038 0f00 0035 !..57>.....8...5
000001d0: 383e fd51 6031 0040 0f00 0098 3b00 0051 8>.Q`***@....;..Q
000001e0: 6131 fdef 45aa 00d8 4a00 00d0 1d00 0010 a1..E...J.......
000001f0: 64ab 05fe ffff feaf 6800 0230 27df 55aa d.......h..0'.U.
This machine does not boot properly, going immediately to a grub>
prompt. If, during the boot process, I force the BIOS to boot from
sdb then it does boot properly.
This machine is doing something useful at the moment, so I am under
pressure to not have it out of service for extended periods of time
while I tinker with it.
The drives are partitioned and set up for MD RAID-1. The current
grub config loads the mdraid1x module and is set to consider its
root as array UUID aca790f8:3fcc9451:e65b1821:87ee8ab7:
$ grep root=\' /boot/grub/grub.cfg | sed 's/^\t*//' | uniq
set root='mduuid/aca790f83fcc9451e65b182187ee8ab7'
$ for dev in sda1 sdb1; do sudo mdadm -E "/dev/$dev" | grep 'Array UUID'; done
Array UUID : aca790f8:3fcc9451:e65b1821:87ee8ab7
Array UUID : aca790f8:3fcc9451:e65b1821:87ee8ab7
/proc/mdstat shows all the MD arrays are currently running fine with
paired partitions from sda and sdb.
So, it looks like this machine is redundant against drive failure
EXCEPT for during boot, and it's just something odd with the MBR of
sda.
What is the simplest way to make it work, and be redundant?
Normally for things of this era (i.e. not UEFI) I would be taking
care to grub-install on both drives after install. Clearly someone
did install grub to both, but sda's copy is no longer working.
Perhaps grub has been upgraded since then, causing another
grub-install against sda (only), and then the BIOS's idea of drive
order flipped around?
Can I simply copy the first 512 bytes of sdb to the start of sda?
I do not particularly want to run grub-install, as the MBR of sdb is
known good at the moment. Perhaps though I could run:
$ sudo grub-install /dev/sda
and then compare again the first 512 bytes of each drive?
Is there any way to sanity check what an MBR will do, grub-wise? My
searching found grub-emu but I couldn't find any useful
documentation and didn't want to just run it. Similarly grub-probe.
I was kind of hoping that there would be something I could run which
would say "yes, this MBR has grub v<whatever> and is set to find its
grub.cfg on (hdX)", then I might be able to see some difference in
what the MBR of sda wants to do. I'm particularly interested in
seeing if the binary grub data in the MBR actually comes from the
grub that is installed from the grub-pc package in the OS.
Thanks,
Andy
--
https://bitfolk.com/ -- No-nonsense VPS hosting