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?
Best Answer
Nuke the gap between the boot sector and the first partition.
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
before starting and check to see where the first partition starts. Use
count=S-1
, where S is the start of the first partition.