Pls help me choose the correct device to select for grub-pc

Hi

On my Debian 10 Server, when I ran apt -y install gnupg2 software-properties-common it popped-up a menu with "congiruing grub-pc" asking where to install Grub. I have no idea if it's MBR or /boot and also I have RAID-0 of 4 disks.

Pls see https://i.snipboard.io/GhQW4P.jpg

$ cat /proc/mdstat
Personalities : [raid1] [raid0] [linear] [multipath] [raid6] [raid5] [raid4] [raid10]
md125 : active raid0 sdd4[3] sdc4[2] sdb4[1] sda4[0]
4186112 blocks super 1.2 512k chunks

md126 : active raid1 sdd3[3] sdc3[2] sdb3[1] sda3[0]
4189184 blocks super 1.2 [4/4] [UUUU]

md127 : active raid0 sdd5[3] sdc5[2] sda5[0] sdb5[1]
31230402560 blocks super 1.2 512k chunks

md2 : active raid1 sdb2[1] sdd2[3] sdc2[2] sda2[0]
1048512 blocks [4/4] [UUUU]

unused devices:
$

$ df -Ph
Filesystem Size Used Avail Use% Mounted on
udev 7.8G 0 7.8G 0% /dev
tmpfs 1.6G 153M 1.5G 10% /run
/dev/md127 29T 12T 18T 40% /
tmpfs 7.9G 0 7.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup
/dev/md125 3.9G 18M 3.7G 1% /tmp
/dev/md2 1008M 91M 867M 10% /boot
tmpfs 1.6G 0 1.6G 0% /run/user/1000
$

Using legacy BIOS

$ [ -d /sys/firmware/efi ] && echo UEFI || echo BIOS
BIOS
$

Used Raid 0 as data has no importance and need better I/O performance.
Pls advise which devices i need to select for grub install, thanks!

Hi,

The only 100% safe way to approach this is to figure out where the GRUB bootblock is installed now. There's a few ways of doing that, but the most reliable would be to take a look at the bootblock of the devices available on your system, and see which of them contains GRUB.

Here's one way of doing that, using /dev/sda (which is the boot device on my test system here) as an example:

# dd if=/dev/sda bs=512 count=1 | xxd
1+0 records in
1+0 records out
512 bytes copied, 3.5661e-05 s, 14.4 MB/s
00000000: eb63 9001 b401 4c49 4c4f 1802 a834 e55d  .c....LILO...4.]
00000010: 0000 0000 4806 ef59 7716 e88a 8100 8060  ....H..Yw......`
00000020: 70a8 0500 b8c0 078e d0bc 0008 fb52 5306  p............RS.
00000030: 56fc 8ed8 31ed 60b8 0012 b336 cd10 61b0  V...1.`....6..a.
00000040: 0de8 6601 b00a e861 01b0 4ce8 5c01 601e  ..f....a..L.\.`.
00000050: 0780 fafe 7502 88f2 bb00 0080 0100 0000  ....u...........
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  ..t21..D.@.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 7716 e88a 0000 8020  ...<.u..w...... 
000001c0: 2100 8326 7105 0008 0000 50fc 3f00 0035  !..&q.....P.?..5
000001d0: 7105 83fe ffff 0008 4000 0050 dc1c 0000  q.......@..P....
000001e0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001f0: 0000 0000 0000 0000 0000 0000 0000 55aa  ..............U.
# 

If you don't have xxd installed then you could pipe this into the hex or binary viewer of your choice - even | cat -v | grep -i grub would do in a pinch, but better to use something more suited to the task if you can.

In any case, you'll get 512 bytes of output on your terminal - specifically, the very first 512 bytes of data that could be read from the device, which (for a bootable device) corresponds to the installed bootblock.

If you get output that looks more or less like the above (ignore the first few lines that mention LILO - that's a...longer story), and in particular if your output mentions GRUB (as the example above does, starting at around position 0x188 in the hex dump), then you know you've found something with a GRUB bootblock.

However, that might not be the end of the story. It's entirely possible (as the message from your installer mentions) that GRUB bootblocks were simply installed to all possible bootable devices when your system was set up. But equally, it might be the case that they're not.

In any case, if you find a GRUB bootblock on the device you believe to be your boot device (that is to say, the device that corresponds to the physical device that the BIOS will attempt to boot from), then you can probably safely install GRUB to that location.

Now, please note a few things here. This is one of the few areas where it is technically possible to get things wrong, and badly so. It's unlikely to be sure that something will go awry, but only ever install a new or updated bootblock on a device that you are absolutely sure (or as sure as you can possibly, reasonably be) is the correct device. It should be safe these days, pretty much - but please do be careful.

I should also advise a bit of caution with that dd command - you might be safest just copy-and-pasting that and then only changing the device name used after the if= flag, as if you get a dd command wrong or specify flags you shouldn't, again things can go very interestingly and awkwardly wrong with your system. But the command I've provided should be safe in almost any conceivable circumstance, as all it does is read the first 512 bytes from the specified input device, and pipe them into the hex reader of your choice.

I hope this helps. If not, or if you have any further questions, please let us know and I'm sure either myself or someone else who is around at the time will be able to assist further.

Thanks drysdalk for your reply. I ran the dd command to inspect first 512 bytes of all 4 drives and it seems like all of them have GRUB installed?

So should I choose all 4 drives to install grub or just the first one sda . In case if I choose all 4 drives, will it harm it in anyway?

dd if=/dev/sda bs=512 count=1 | xxd

1+0 records in
1+0 records out
00000000: eb63 9000 0000 0000 0000 0000 0000 0000 .c..............
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 ................
512 bytes copied, 0.0157335 s, 32.5 kB/s00000050: 0000 0000 0000 0000 0000 0080 0008 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 ..t21..D.@.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 0000 0000 0000 0000 ...<.u..........
000001c0: 0200 eeff ffff 0100 0000 ffff ffff 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.

dd if=/dev/sdb bs=512 count=1 | xxd

00000000: eb63 9000 0000 0000 0000 0000 0000 0000 .c..............
1+0 records in
1+0 records out
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 0080 0008 0000 ................
512 bytes copied, 0.0104388 s, 49.0 kB/s00000060: 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 ..t21..D.@.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 0000 0000 0000 0000 ...<.u..........
000001c0: 0200 eeff ffff 0100 0000 ffff ffff 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.

dd if=/dev/sdc bs=512 count=1 | xxd

1+0 records in
1+0 records out
00000000: eb63 9000 0000 0000 0000 0000 0000 0000 .c..............
00000010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000020: 0000 0000 0000 0000 0000 0000 0000 0000 ................
512 bytes copied, 0.0959527 s, 5.3 kB/s00000030: 0000 0000 0000 0000 0000 0000 0000 0000 ................

00000040: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000050: 0000 0000 0000 0000 0000 0080 0008 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 ..t21..D.@.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 0000 0000 0000 0000 ...<.u..........
000001c0: 0200 eeff ffff 0100 0000 ffff ffff 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.

dd if=/dev/sdd bs=512 count=1 | xxd

1+0 records in
1+0 records out
00000000: eb63 9000 0000 0000 0000 0000 0000 0000 .c..............
00000010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000020: 0000 0000 0000 0000 0000 0000 0000 0000 ................
512 bytes copied, 0.106229 s, 4.8 kB/s00000030: 0000 0000 0000 0000 0000 0000 0000 0000 ................

00000040: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000050: 0000 0000 0000 0000 0000 0080 0008 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 ..t21..D.@.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 0000 0000 0000 0000 ...<.u..........
000001c0: 0200 eeff ffff 0100 0000 ffff ffff 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.

Hello,

Given that the GRUB bootblock is already installed on all physical devices, I can't imagine it being likely that problems will be caused by re-installing it to those same devices. As long as you can see that the installer will be writing the GRUB MBR to /dev/sda, /dev/sdb, /dev/sdc and /dev/sdd, and no-where else, then I think things should be fine.