2

I want to tryout Ubuntu 14.04 LTS. Because I don't want to reinstall windows after this I installed it via DVD-ROM onto my usb 3.0 stick (64GB). This worked fine.

The first thing when I restarted the computer I was wondering about that windows wasn't starting anymore, when the usb stick wasn't plugged in. I found out why and changed the boot order in the GPT partition using efibootmgr's -o parameter.

Now I have to press F9 to enter the UEFI boot menu of my HP laptop and then I can select ubuntu. All fine.

One thing left which bothers me: Can I configure, that ubuntu automatically starts when the USB stick is connected? Without USB stick windows should start normally without displaying grub?

sudo efibootmgr -v
[sudo] password for alex: 
BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 0001,0000,0004,9999
Boot0000* ubuntu    HD(2,145800,82000,1ec11f19-24da-44cd-8ac6cd26205992d2)File(\EFI\ubuntu\shimx64.efi)
Boot0001* Windows Boot Manager  HD(2,145800,82000,1ec11f19-24da-44cd-8ac6-cd26205992d2)File(\EFI\Microsoft\Boot\bootmgfw.efi)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}....................
Boot0004* Internal Hard Disk    ACPI(a0341d0,0)PCI(11,0)SATA(0,ffff,0)HD(2,145800,82000,1ec11f19-24da-44cd-8ac6-cd26205992d2)..BO
Boo9999* USB Drive (UEFI)   ACPI(a0341d0,0)PCI(1d,0)USB(10,0)..BO

alex@alex-desktop:~$ sudo parted -l
Modell: ATA SAMSUNG SSD 830 (scsi)
Festplatte  /dev/sda:  256GB
Sektorgröße (logisch/physisch): 512B/512B
Partitionstabelle: gpt
Disk-Flags: 

Nummer  Anfang  Ende    Größe   Dateisystem  Name                          Flags
 1      1049kB  683MB   682MB   ntfs         Basic data partition          versteckt, diag
 2      683MB   955MB   273MB   fat32        EFI system partition          boot, esp
 3      955MB   1089MB  134MB                Microsoft reserved partition  msftres
 4      1089MB  232GB   231GB   ntfs         Basic data partition          msftdata
 5      232GB   256GB   24,0GB  ntfs         Basic data partition          versteckt, msftdata


Modell: SanDisk Extreme (scsi)
Festplatte  /dev/sdb:  32,0GB
Sektorgröße (logisch/physisch): 512B/512B
Partitionstabelle: msdos
Disk-Flags: 

Nummer  Anfang  Ende    Größe   Typ       Dateisystem  Flags
 1      1049kB  28,4GB  28,4GB  primary   ext4         boot
 2      28,4GB  32,0GB  3652MB  extended
 5      28,4GB  32,0GB  3652MB  logical
3
  • Did you include an efi partition on flash drive? My install put UEFI entries on sda internal drive. I copied /EFI/ubuntu to efi partition on flash drive and then created /EFI/Boot/bootx64.efi which really was a copy of grub or shim. But I have not tried making it first in UEFI boot order, to see if that works or not.
    – oldfred
    Jun 7 '15 at 20:29
  • Please edit your question to include the output of the following commands: sudo efibootmgr -v and sudo parted -l. Add four spaces to the start of each line. This information will tell us how Windows is installed, whether you have an ESP on the USB flash drive (as oldfred is suggesting may be part of the problem), and how the EFI is configured to boot.
    – Rod Smith
    Jun 7 '15 at 22:46
  • @RodSmith edited
    – Tim
    Jun 8 '15 at 10:55
2

Background: EFI uses a boot order variable stored in NVRAM to determine what to boot. (This is the BootOrder: line in the efibootmgr output.) These entries point to EFI program files stored on an EFI System Partition (ESP), to network devices, and so on. You can have multiple ESPs, and each ESP can have multiple EFI boot files. If one boot file fails, the ESP should drop back to the next one in its list.

Your problem is that, although Ubuntu is installed on your USB flash drive, that flash drive has no ESP, and it looks as if GRUB has been installed in the ESP on the hard disk. Unfortunately, your GRUB configuration relies on configuration files on the USB drive, so if the USB drive is unplugged when GRUB launches, GRUB will drop back to a grub> prompt, but it won't fail in the sense of returning to the EFI so that the EFI can launch the next boot loader. When you first installed Ubuntu, this GRUB was set as the default boot loader, so you saw the type of failure you describe. You changed the default to Windows, which causes it to boot correctly, but makes it harder to boot Ubuntu. There are several ways to clean this up:

  • You can live with it as-is and use the computer's built-in boot manager (the F9 key you mention) to select which OS to boot. This solution is the safest one, since it involves no changes that might make matters worse.
  • You can attempt to reconfigure GRUB to read its configuration file from the ESP rather than from your Ubuntu /boot directory, then reset GRUB as the default. GRUB should then present a boot menu, which will enable you to select your desired OS a bit easier. I'm a bit rusty on how to do this, though. Check this old documentation page for all the gory details (and then some). Note that GRUB won't automatically select Ubuntu if and only if the USB drive is plugged in -- or at least, if it can be configured to do that, I don't know how.
  • You can repartition your internal hard disk to include an Ubuntu /boot partition and copy its files there. You'll then need to re-install GRUB. In theory, it should then work whether or not the USB drive is plugged in, but it won't automatically select Ubuntu when the USB drive is plugged in and Windows when it's not plugged in. This option is one of the riskiest ones, since it involves resizing your on-disk partitions.
  • Create an ESP on your USB flash drive and install GRUB there using the fallback filename of EFI/BOOT/bootx64.efi. (The installation procedure is likely to be a bit convoluted, though.) You can then use your boot manager (F9) to switch between the USB drive (GRUB/Ubuntu) and Windows. Some EFIs might let you set the USB drive as default if it's plugged in, which would give you the automatic boot to Ubuntu when it's available that you want, but I can't promise this detail will work as you want. You'll definitely need to repartition the USB drive (which adds a bit of risk), and you may need to convert the disk from MBR to GPT. One advantage of this approach is that the USB drive should be independently bootable on just about any EFI-based computer of the same architecture.
  • You can install my rEFInd boot manager to your ESP. With a few configuration tweaks (mainly setting default_selection vmlinuz,Windows or something similar in its refind.conf file), it should boot Ubuntu by default when the USB drive is plugged in and Windows when the USB drive is not plugged in.

There may be other possible solutions, too, but these are the ones that spring to mind. The best of these are probably leaving it as-is, creating an ESP on your USB drive and re-installing GRUB there, and using rEFInd.

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.