0

I have installed Debian Stretch onto an external USB drive that I plan to use as a portable installation that I can use on multiple computers, so I need to be able to boot it from the USB directly without creating an nvram entry in the UEFI. The problem is, the UEFI does not see the drive as bootable (it doesn't appear in the boot menu or boot settings).

I ran the Debian installer in expert mode and selected to install grub to the fallback location, I've booted the system via nvram and tried to install grub manually using

grub-install --efi-directory=/boot/efi --boot-directory=/boot --removable /dev/sde 

I have installed refind and ran it with --usedefault. I've confirmed that /boot/efi/EFI/BOOT/BOOTX64.efi is present, but the UEFI still doesn't list the USB drive as a boot option on two different machines I've tried.

Booting via nvram works fine, but I need to be able to boot directly from the USB without relying on nvram entries on motherboard.

Does anyone have any idea what could be going wrong? Here is the output of fdisk -l:

Disk /dev/sde: 59.8 GiB, 64160400896 bytes, 125313283 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: gpt
Disk identifier: 831C76FD-DE61-4D79-93F5-0DA1C5EE5978

Device       Start       End   Sectors  Size Type
/dev/sde1     2048   1050623   1048576  512M EFI System
/dev/sde2  1050624   1550335    499712  244M Linux filesystem
/dev/sde3  1550336 125313023 123762688   59G Linux filesystem

And parted:

(parted) print                                                            
Model: Samsung Flash Drive (scsi)
Disk /dev/sde: 64.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  538MB   537MB   fat32              boot, esp
 2      538MB   794MB   256MB   ext2
 3      794MB   64.2GB  63.4GB

/dev/sde1 is ESP, fat32 and is mounted at /boot/efi with the esp, boot flags. /dev/sde2 is ext2 and mounted at /boot, and /dev/sde3 is a luks partition with root and swap LV's.

0

nvram entries include where the root partition is for grubs system files. If you boot the device directly then the UEFI tells grub the root is the same as EFI system where normally this is the Linux system partitions /boot directory. The easiest solution here is to install grub to the efi system partition.

grub-install --efi-directory=/boot/efi --boot-directory=/boot/efi --removable /dev/sde

  • Thanks, I did try installing grub with --removable, but my /boot directory isn't on the ESP partition, it's on a separate ext2 partition with ESP mounted in /boot/efi. Will --boot-directory=/boot/efi still work in this case? I've read that dpkg requires kernels to be on a non-FAT32 filesystem because it has to use symlinks sometimes so that's why I've set it up this way. – Algebro Sep 20 '18 at 17:23
  • Just a heads up--I went ahead and tried this anyway and it didn't work. It created /boot/efi/grub/grubx64.efi but the UEFI still isn't seeing the device as bootable. – Algebro Sep 21 '18 at 19:12
0

I was able to solve this but I don't really understand why what I did works. I ended up running grub-install again without passing --efi-directory and --boot-directory (so the command ended up being grub-install --removable --verbose). I then removed the nvram entry and rebooted once and the drive wasn't detected, but after another reboot, it showed up in the boot list and was bootable.

I went through the same process on another computer (removed the existing nvram entry and rebooted) and the drive was detected there as well when it wasn't previously. It looks like it may be necessary to clear out nvram entries to get the UEFI to scan for more sometimes but I honestly am not sure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.