GRUB2 – How to Check on Which Drives GRUB2 Installed an MBR

bootbootabledebiangrub2

I'm on a Debian/Squeeze system (with a history going back to at least Woody) which was upgraded to grub2 as part of the Squeeze upgrade. All works well, but I'm about to mess with the disk configuration.

Currently the machine runs off 2 80GB drives with RAID1-ed /, /home and /boot partitions (there's another pair of drives with a RAID1-ed "/data" and a couple of swaps, in case anyone was wondering where the swap is, but I'm not touching those).

I've added 2 130GB SSDs, partitioned them to be at least as large as the partitions on the 80GB drives, and intend to switch over to the new SSD drives by growing the RAID1s to include them, waiting for sync, then removing the old drives from the arrays so just the SSDs are left (and then growing the filesystems). But mdadm/ext3 wrangling is not what this question is about…

That'll leave me with 2 obsolete 80GB (IDE) drives which I want to remove from the machine. My worry is that removing them will take some crucial MBR with them. How do I ensure the machine remains bootable ?

More specifically:

  • When I did the Squeeze upgrade, I remember there was some choice presented about which drives grub2 should install to (I went with the default, which was all drives). The SSDs weren't in the machine at the time though; how can I rerun this to get grub to install on the SSD MBRs ? (I'm guessing it's a dpkg-reconfigure of some package).

  • How can I find which drives grub2 thinks it's installed on ? Good grief there are almost 200 files under /boot/grub/ these days! Where to look ? Also, it seems slightly odd that /boot/grub/device.map.auto only lists 3 drives currently (2 of the 80GBs but only one of the other drive pair, and none of the SSDs). How do I get that up to date ? (Update: that was a red herring; device.map.auto seems to be a relic from years ago; device.map looked sensible on an update by grub-mkdevicemap. Think my paranoia in this area originates from an old mobo's BIOS which would reorder the device order seen by GRUB on a whim).

Outcome: all went well and I now have the two old 80GB IDE drives out of the box, and a snappy and quick booting system running off RAID1-ed SSDs with all filesystems resized up to their new partition sizes. The other "missing piece of the Grub puzzle" I was looking for was dpkg-reconfigure grub-pc which prompts for which disks to maintain a MBR on. Aaron's answer actually did most to reassure me that this was working as expected, hence accepting that answer.

Best Answer

The MBR is 512 bytes, so a quick way to see if GRUB is there...

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

That dumps the MBR, I see "GRUB" in mine at byte 0x17F = 383.

dd if=/dev/sda bs=1 count=4 skip=383

When I do that, it prints 'GRUB' followed by the dd output.

You can wrap that in a bash for loop or something to go across more drives. if you don't want to do it manually.

Related Question