This quick entry has been created just to document the process needed to install GRUB2 from a running Debian Bullseye, trying to install GRUB2 on USB stick I always get this error:
# grub-install /dev/sdb Installing for i386-pc platform. grub-install: warning: Attempting to install GRUB to a disk with multiple partition labels. This is not supported yet.. grub-install: error: embedding is not possible, but this is required for cross-disk install.
In my case I have a BIOS based system (no an UEFI system), and this procedure doesn’t need to run an alternative Live image it’s just used my fresh Debian GNU/Linux installation (I have to remove all drives from my server to be able to boot from Debian).
I have had to follow this procedure in my HP Proliant G8 Microserver to be able to boot from ODD bay, due to SATA AHCI controller it’s needed to install GRUB2 on an USB stick (/dev/sdb in this case). So once I installed Debian GNU/Linux in a drive connected to ODD slot:
# fdisk /dev/sdb Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): p Partition number (1-4, default 1): First sector (2048-31490047, default 2048): Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-31490047, default 31490047): +3g Created a new partition 1 of type 'Linux' and of size 3 GiB. Command (m for help): a Selected partition 1 The bootable flag on partition 1 is enabled now. Command (m for help): p Device Boot Start End Sectors Size Id Type /dev/sdb1 * 2048 6293503 6291456 3G 83 Linux Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. # mkfs.ext4 /dev/sdb1
Next command is going to fix the problem we mentioned at the beginning of this entry, to prevent grub-install fails is needed to nuke the gap between the boot sector and the first partition:
# dd if=/dev/zero of=/dev/sdb seek=1 count=2047 2047+0 records in 2047+0 records out 1048064 bytes (1.0 MB, 1.0 MiB) copied, 0.140919 s, 7.4 MB/s # grub-install /dev/sdb Installing for i386-pc platform. Installation finished. No error reported.
Now it’s needed to shutdown my server, plug again all disks and then boot again to check that I can start Debian properly.
Have fun!
—
“Let us sacrifice our today so that our children can have a better tomorrow”
–A. P. J. Abdul Kalam