Debian – GRUB and LILO Fail to Install on NVMe Hard Disk

debiangrub2hard-disklilosystem-installation

I'm trying to install 64-bit Debian stable on a Lenovo Thinkpad. When I get to the installation step that installs the bootloader, I get this message:

An installation step failed. You can try running the failing item again from the menu, or skip it and choose something else. The failing step is: Install the GRUB boot loader on a hard disk

Going back to the menu and selecting LILO gives me the same error. The installation log says

May  1 13:24:23 main-menu[188]: WARNING **: Configuring 'grub-installer' failed with error code 1
May  1 13:24:23 main-menu[188]: WARNING **: Menu item 'grub-installer' failed.
May  1 13:24:28 main-menu[188]: INFO: Menu item 'lilo-installer' selected
May  1 13:24:28 main-menu[188]: WARNING **: Unable to set title for fdisk-udeb.
May  1 13:24:28 main-menu[188]: WARNING **: Configuring 'lilo-installer' failed with error code 1
May  1 13:24:28 main-menu[188]: WARNING **: Menu item 'lilo-installer' failed.

I'm not using LVM or RAID. So far, I've tried

  1. Disabling UEFI boot and using legacy boot instead. The error still occurs, with both GRUB and LILO.

  2. Following the instructions on this question and running

    parted /dev/nvme01
    set 1 bios_grub on
    

    from TTY2, but I get an error that says parted not found. On my system /dev/nvme01 is the only hard disk

  3. Check for hardware errors. When I first purchased the system I ran all the available hardware tests, both from within the BIOS and from within Windows, and it passed all of them. I'm assuming that means the hardware isn't malfunctioning.

  4. Per this thread that had a similar error, albeit with LVM, I tried redoing the partitioning with a small /boot partition at the beginning, formatted with ext2. Same error.

  5. Switching to TTY4 to look at the installation output, I also see the error

    chroot: can't execute 'grub-probe': No such file or directory
    

    Searching for information on that turns up this thread and this bug report related to GRUB, but a) those are old, and b) I've run through the installation up to this point over a dozen times now and I get the error every time, so it doesn't seem like a one-off thing.

  6. I've used Gparted to check that the hard disk is completely empty.

  7. Secure boot is disabled in the BIOS.

  8. I've run the installation using the full DVD and the netinstall CD; both are booted from USB, but the problem persists.

I was able to successfully create an msdos partition table and three partitions (for /, /home, and swap) on the drive in the previous installation step, so I don't know why GRUB suddenly can't write to the drive.

How do I fix this and get Debian installed? As of now, the (brand new!) system is completely unusable because I can't get an OS on it.


Could part of the problem be that Debian/parted recognizes the disk incorrectly? It says the disk is 512.1 GB, which is true in the sense that the specs say 512 GB and that's what is advertised, and it will let me allocate all 512 GB to various partitions. However, if I load it in Gparted, the actual disk space is closer to 476 GB, but I assumed that's just the usual 1024 vs 1000 stuff.

(I also posted a version of this question on the Debian forums, so I'll update my question with anything important from that thread and vice versa.)

Best Answer

Here is what worked for me, using Debian jessie (stable). I basically took the instructions from this wiki post, and stripped out all the steps about dual-booting with Windows, since those didn't apply to my case.

  1. In the BIOS, set "UEFI only" boot.

  2. Using Gparted, create a FAT32 partition at the beginning of the disk with the boot and esp flags. (The Debian installer should be able to do this too, but since the installer incorrectly recognized the size of the disk, I prefer to use Gparted). In my case, the FAT32 partition is /dev/nvme0n1p1.

  3. During the installation, make sure you have a network connection configured (manually or automatically, doesn't matter). Otherwise, the next step will fail.

  4. At the installation stage where GRUB fails to install, open a shell and run the following commands:

    mount --bind /dev /target/dev
    mount --bind /dev/pts /target/dev/pts
    mount --bind /proc /target/proc
    mount --bind /sys /target/sys
    cp /etc/resolv.conf /target/etc
    chroot /target /bin/bash
    
    aptitude update
    aptitude install grub-efi-amd64
    update-grub
    grub-install --target=x86_64-efi /dev/nvme0n1
    

    Exit the shell and select "Continue without installing a bootloader." You'll see a warning message that gives you boot commands to use; you can ignore this.

  5. Once the installation completes, boot into the system. Add "nvme" to /etc/initramfs-tools/modules, then run update-initramfs -u as root.

  6. Edit /etc/default/grub and add this line

    GRUB_CMDLINE_LINUX="intel_pstate=no_hwp"
    

    and add "nomodeset" to the GRUB_CMDLINE_LINUX_DEFAULT so it looks like this:

    GRUB_CMDLINE_LINUX_DEFAULT="quiet nomodeset"
    
  7. Run update-grub.

The last few commands (initramfs onward) are necessary to prevent disk not found errors the second time you try to boot into the new system.

Related Question