4

I have this very weird problem with my Ubuntu installation. I installed Ubuntu on an external hard drive (Seagate 2 Terabytes usb3) and everything seems normal. But when I unplug the external hard drive and plug it again and then start the computer, I cannot boot from this external hard drive. Do you know how can I resolve this issue? Thanks!

Note: I know I can repair the boot by launching bootrepair utility, but that's not something I want to do everytime I unplug my external hard drive. Note2: Changing the harddrive isn't something I want to do. I had CentOS on it before and it worked just great.

| improve this question | | | | |
  • If your BIOS doesn't list the external drive as a possible boot medium, as you explain in a comment to an answer, the issue is unrelated to Ubuntu and off topic here. – David Foerster Apr 29 '15 at 11:03
  • 1
    I feel your concern but this is not really as off-topic as it may seem, since I have this issue only when I install ubuntu on this hdd. I don't have this issue with centos installation, for example. And when I delete ubuntu partition I can see the hdd as bootable again. – Dark Marouane Apr 29 '15 at 12:26
  • Which boot loader does CentOS use? You can probably use that to boot Ubuntu too. – David Foerster Apr 29 '15 at 14:26
3

If the computer is booting in EFI mode, as your "UEFI" tag and the symptoms imply, then you should first be aware of the cause of the problem: External media normally boot using the default/fallback boot filename, which is EFI/BOOT/bootx64.efi on the EFI System Partition (ESP) on x86-64/AMD64 systems. Most OS installations are to internal disks, which boot using customized entries stored in NVRAM. External media can also boot with such entries; but some EFIs delete entries that they can't see when you boot, so customized entries for external media can disappear if the external medium is unplugged while the system boots another OS.

Three solutions occur to me:

  • The most straightforward solution is to move/rename your boot loader. Ubuntu installs its boot loader as EFI/ubuntu/shimx64.efi and EFI/ubuntu/grubx64.efi on the ESP, which is normally mounted at /boot/efi in Ubuntu. Rename EFI/ubuntu on the ESP to EFI/BOOT on the ESP. You must then rename shimx64.efi to bootx64.efi. (If your system does not use Secure Boot, you may optionally rename grubx64.efi to bootx64.efi instead of renaming shimx64.efi.) This solution has the advantage that your external disk should be bootable on most EFI-based computers of the same architecture as the original computer.
  • Install my rEFInd boot manager to your internal disk's ESP and set it as the default boot program. You could do this in Ubuntu by unmounting the external ESP from /boot/efi, mounting the internal ESP to /boot/efi, and installing the Debian package (but not the PPA version). Do not edit /etc/fstab. Once set up in this way, rEFInd should launch on every boot, even when your external disk is unplugged; but because rEFInd builds its boot list on every boot, ignoring NVRAM entries, Ubuntu entries will appear only when the external disk is plugged in. This solution has the advantage of per-boot adaptability. You can even set rEFInd's defaults so that Ubuntu is the default boot option when the external disk is plugged in but Windows takes top spot when the disk is removed. One caveat: If you're using Secure Boot, you'll have to jump through some extra hoops to get it working. Copying the EFI/ubuntu directory tree from the external ESP to the internal one before installing rEFInd, then deleting EFI/ubuntu from the internal ESP, should do the job.
  • You can re-install GRUB to an ESP on an internal hard disk. To do this, you'll need to unmount /boot/efi from Ubuntu, mount an internal disk's ESP to /boot/efi, and re-install GRUB. You may want to update your /etc/fstab, too. This approach can be tricky, though; some GRUB configurations rely on a GRUB configuration file in /boot/grub, and if yours does this, /boot will also need to be on the internal disk or else GRUB will stop working when you unplug that disk, which means you won't be able to boot anything except by using the computer's built-in boot manager. I haven't been following the details of where Ubuntu stores its GRUB configuration file, so I'm not sure how likely you are to run into this problem.

Personally, I'd go with one of the first two solutions, since I'm not entirely sure where Ubuntu stores its grub.cfg file these days. That third option might be viable if you know that file gets stored on the same ESP as GRUB, or if you're willing to create a /boot partition on your internal disk.

| improve this answer | | | | |
  • Hi Rod, many thanks for your explanation. Now I understand the problem and I tried your first solution and It worked straight away. I kept the original efi/ubuntu and copied it into efi/boot with the renaming you suggested. Thanks, you saved me a lot of time! – Dark Marouane Apr 29 '15 at 17:13
  • 1
    *off-topic*(Also, I wanted to upvote this but couldn't due to my reputation. So, here is a symbolic +1) – Dark Marouane Apr 29 '15 at 17:17
0

I do have the same external HDD (seagate 1 TB) and i have installed elemantry os luna in it.In your case you should go to the boot device selection menu when your computer boots up and choose to boot your external HDD.

| improve this answer | | | | |
  • Actually I cannot see my hdd as a bootable device anymore after disconnecting it are reconnecting it again. – Dark Marouane Apr 29 '15 at 8:40
0

Make sure you got the device correctly connected to the computer before power it up. If you can't see the device in the boot device selection menu, try to select it manually in the bios menu. You should be able to order a boot device priority here and put it on the top of all devices. If you can't see it here, make sure the device actually works connecting it to another computer.

| improve this answer | | | | |
  • I'll try this once I have access to another computer, since I can't see my hdd in the bios settings.But then, I won't know what to do to solve my problem. – Dark Marouane Apr 29 '15 at 12:22
0

My story (can be useful to someone with the same problem): I’ve installed Ubuntu on external USB 3.0 hard drive on an iMac late 2013. I created the following partition scheme on that external drive:

EFI (200MB FAT), BOOT (200MB EXT2) and / (20GB EXT4)

I choose to add a bootloader to the External drive (not the iMac drive) After the successful installation, I was shocked when I couldn’t boot my OS X. It's strange because I didn't install any bootloader on main drive. If I removed the external drive, I get a black screen with the grub prompt command!

In panic, I researched online and I decided to give a try to rEFInd. After the installation from the .deb source (it's recommended to install from the .deb file to fix the problem with the Ubuntu 16.x versions) I could boot my OS X.

To restore the original boot menu (and ditch Linux), you can use the startup disk utility on your OS X or you can mount the EFI partition and with the "sudo rm ..." command, remove the “refind” and “Ubuntu” folders on that partition.

Reboot and everything will work like before.

| improve this answer | | | | |

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.