3

My hard-drive on Ubuntu running laptop died because of age and extensive use in the past, but before it died completely I managed to create persistent live-usb pendrive to use as temporally system. This solution worked and I run system from usb stick for month or so. Now I got 1000GB external hard drive and wanted to install fresh and fully functional system on it. Because I had persistent live-USB stick already, it was my main option to install new system, so I run live usb mode, plugged in external drive, and allocated partitions as follows:
Gparted window

I made installation (Ubuntu MATE 16.04), shutdown after completion, removed USB-stick but kept external HDD and turned laptop on. After checking bios settings and making sure it detected external drive and can load from it, I put it on top of boot priority and restarted.
Nothing happened, system did not load, it was just blackscreen and it looked like it tried to load from broken old HDD instead of new one. I plugged in USB stick, loaded Grub from flash drive, entered console mode and tried manually booting from external HDD to check if it installed properly, by running those commands in grub console:

set root=(hd0,msdos5)
linux /vmlinuz root=/dev/sda5 libata.force=1:disable
initrd /initrd.img
boot

libata.force is to disable old dead harddrive, because otherwise it will just keep slowing things down, as well as wasting itself.
After running those commands system loaded perfectly and as expected from external harddrive, so I figured that problem is somewhere in bootloader\grub. I did some googling, tried to comment grub menu skipping in /etc/defaults/grub:

#GRUB_HIDDEN_TIMEOUT=0 
#GRUB_HIDDEN_TIMEOUT_QUIET=false

and running update-grub, but it did not help.
I tried running grub-install as well, but it had no effect - system refused to load grub from external HDD.
I could not understand what is the problem, because laptop could run from USB stick with same version of system just fine, so I cracked open EFI partition from USB stick and tried to look what is different, and live-usb EFI partition had structure like this:

boot
    > grub
        [more files]
    > memtest
        [more files]
EFI
    > BOOT
        bootia32.efi
        bootx64.efi
    > ubuntu
        [more files]

While EFI partition on external HDD after installation looked like this:

EFI
    > ubuntu
        [same files as in EFI/ubuntu on live-usb]

So on HDD after installation there was no BOOT folder. After googling about UEFI I wound this in wikipedia:
https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface#Booting

This automated detection relies on standardized file paths to the OS loader, with the path varying depending on the computer architecture. The format of the file path is defined as /BOOT/BOOT.EFI;

So I've just copied BOOT folder from live-usb to my mounted /boot/efi partition into same EFI folder, removed usb stick and restarted.

After that step laptop actually booted from external harddrive and I was greet by grub console without anything else. By manually running linux-initrd-boot chain as before from usb-stick I was able to launch Ubuntu with no issues whatsoever.
That left me with actually working boot into linux from that external HDD, but no understanding of what is wrong and how to fix it. After looking on boot/grub content of efi on stick, I realized that it is pretty where it locates grub.cfg and all, so considering I've copied booting efi file from it, I created boot folder in my EFI partition and copied content of /boot from installation on external HDD to it, so my /boot/efi/boot was copy of /boot. After restarting system, it actually worked as it supposed to, it loaded standard ubuntu themed grub with option to load Ubuntu, and system worked with no issues at all.
While it leaves me with working system, fact that I had to manually tinker with it and way it all works is no good at all.

So my question is, what is wrong with UEFI installation in my case, why it does not load without /EFI/BOOT, why installation does not create it, and how do I fix this all properly?

  • How did you ran grub-install – Arun Jun 15 '17 at 1:43
  • @Arun I just run: sudo grub-install /dev/sda because I do not know that much about grub and that is what grub wiki told me to do. – Ethuil UI Jun 15 '17 at 1:49
  • Great question! – fosslinux Jun 15 '17 at 2:56
  • UEFI only boots external installs from /EFI/Boot/bootx64.efi. We normally have to manually copy /EFI/ubuntu/shimx64.efi to be bootx64.efi. But you still need the ubuntu folder as the version of grub with a full install expects more support & boot files in /EFI/ubuntu folder.The version of grub in installer is a limited version with just the needed support to boot the live installer. Also: askubuntu.com/questions/559007/… – oldfred Jun 15 '17 at 3:57
  • @oldfred Thank you, I just deleted all files I created manually (folder /boot/efi/BOOT/ and /boot/efi/boot, after that I run grub install as follows: sudo grub-install --efi-directory=/boot/efi --boot-directory=/boot --removable Installing for x86_64-efi platform. Installation finished. No error reported. – Ethuil UI Jun 15 '17 at 11:01

Your Answer

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

Browse other questions tagged or ask your own question.