`install-grub` claims that I have multiple partiton labels and that embedding is impossible
I am trying to get GRUB installed on my non-booting desktop computer, but I am encountering several errors. Other sources discussing these errors have ascribed them to either a lack of free disk space before the first partition (I have the requisite free space), or to a problem with /boot/grub/grub.cfg
(problem persists even after regenerating that file correctly).
I booted with a live USB and attempted to reinstall GRUB using the following commands, but I encounter an error that prevents it from working:
$ sudo mount /dev/sda1 /mnt $ sudo grub-install --root-directory=/mnt /dev/sda 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: warning: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged.. grub-install: error: will not proceed with blocklists.
However, /dev/sda
appears to be formatted correctly for installing grub:
$ sudo fdisk -l /dev/sda Disk /dev/sda: 111.8 GiB, 120034123776 bytes, 234441648 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x8d91017b Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 234440703 234438656 111.8G 83 Linux $ blkid /dev/sda1 /dev/sda1: UUID="84e9ff65-c4ba-42eb-8a6d-ebc703fae1f7" TYPE="ext4" PARTUUID="8d91017b-01"
It has the standard 1 MiB free space at the beginning, and /dev/sda1
is formatted correctly. I have tried using grub-mkconfig
to rebuild the config file:
$ for f in proc sys dev dev/pts ; do sudo mount --bind /$f /mnt/$f ; done $ sudo chroot /mnt # grub-mkconfig -o /boot/grub/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.19.0-26-generic Found initrd image: /boot/initrd.img-3.19.0-26-generic Found linux image: /boot/vmlinuz-3.19.0-23-generic Found initrd image: /boot/initrd.img-3.19.0-23-generic Adding boot menu entry for EFI firmware configuration done
However, I still get the same error message when running grub-install
, whether in or out of the chroot
environment.
Booting the live USB in legacy mode, I get the same error; the only difference is the output of running grub-mkconfig
in the chroot
environment:
# grub-mkconfig -o /boot/grub/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.19.0-26-generic Found initrd image: /boot/initrd.img-3.19.0-26-generic Found linux image: /boot/vmlinuz-3.19.0-23-generic Found initrd image: /boot/initrd.img-3.19.0-23-generic Found memtest86+ image: /boot/memtest86+.elf Found memtest86+ image: /boot/memtest86+.bin Found Windows 7 (loader) on /dev/sdc1 done
How can I get grub installed correctly?
Solution 1:
Nuke the gap between the boot sector and the first partition.
# dd if=/dev/zero of=/dev/sdX seek=1 count=2047
That's for if the first partition starts at sector 2048. Some start earlier, especially on drives that were partitioned by Windows. To be sure, run
# fdisk -l /dev/sdX
before starting and check to see where the first partition starts. Use count=S-1
, where S is the start of the first partition.
Solution 2:
One can create a new partition where the GPT record is, then wipe it using dd
. That way, only the MBR record will remain.
Assuming problem device is /dev/sda
:
Create a new partition in the initial 1 MiB
$ parted /dev/sda
$ mkpart primary ext4 0MiB 1MiB
$ quit
Then, zero the newly created partition
$ dd if=/dev/zero of=/dev/sda2
Then, delete the partition
$ parted /dev/sda
$ rm 2
$ quit
grub-install
should now work as expected.
Solution 3:
Had a similar problem with the multiple partition labels, although i am quite sure that that is not the case.
sudo grub-install target=i386-pc /dev/sda --force
is what I used to get around this. Tacking on a --force
is not a "recommended" solution, but I have had no issues so far =P
Solution 4:
Here is what I did that got it working again:
Used gdisk
to convert the MBR partition to GPT, insert a partition into the empty space (type EF02 "BIOS Boot partition"), transposed its entry with my original partition, and flagged it as legacy BIOS bootable.
Then ran
$ sudo mount /dev/sda1 /mnt $ sudo grub-install --root-directory=/mnt /dev/sda
It then installed successfully, and I able to boot to my main drive.