Hi, On Wed, Sep 11, 2024 at 12:45:46AM +0200, Florent Rougon wrote: > The partition table indeed starts at offset 446 (decimal), however I'd > still rather run grub-install or “dpkg-reconfigure grub-pc” than copy > the first 446 bytes from one drive to another drive. The reason is that, > AFAIUI, what GRUB writes in this area when installed is likely to > contain disc-specific info. More specifically, according to [1]: > > There isn't room for much function in the 446 bytes available for > executable code in the boot sector. The sole function of this stage1 > code is to load the much larger stage2 boot program. When stage1 is > installed in the MBR, it is configured with the BIOS drive number and > the absolute LBA of the first sector of the stage2 file in the boot > partition. It loads that one sector into a fixed location in memory > and transfers control to it. (...)
Since booting from sdb wasn't working in any case, I thought I'd experiment a bit. I copied the first 446 bytes of sda to sdb. This made matters worse! Instead of a "grub> " prompt, I just got a blank screen. I then rebooted from sda and did: $ sudo dpkg-reconfigure grub-pc selecting both sda and sdb. I was then able to boot from sdb. This does leave me wondering however, if the boot code in the mBR of sdb is now set to believe that this is "the second drive", I suppose (hd1) in grub terms? With the implication that should sda fail or be removed, this machine may still not boot because its boot code looks for something on a drive that no longer exists (sdb now being (hd0))? The grub.cfg itself (and later, the fstab) finds its drives by UUID so I'm not worried about that part. I just have dim memories about having to do grub-install to sdb but trick it somehow that this was (hd0)… I do also wonder why my simple dd of the first 446 bytes did not work, as the /boot partition is at the same position on both drives and is an MDADM RAID1 so should have its stage2 at the same LBA. After doing the "dpkg-reconfigure grub-pc" the first 446 bytes of both sad and sdb are (still) identical so something else somewhere else must have been changed. $ sudo dd if=/dev/sda bs=446 count=1 2>/dev/null | sha256sum b7ccacdeb89b1fd8c272549c69ff07570b033747c0a84a73febc7851c7cf4f2e - $ sudo dd if=/dev/sdb bs=446 count=1 2>/dev/null | sha256sum b7ccacdeb89b1fd8c272549c69ff07570b033747c0a84a73febc7851c7cf4f2e - Not understanding quite what is going on is worrying to me, even if things do now work. 🙁 Thanks, Andy -- https://bitfolk.com/ -- No-nonsense VPS hosting