0

I am currently trying to install Ubuntu 16.04.1 on a USB Stick using EFI so I have a portable OS to carry around and I have the ability to plug it into the laptop I use, which only has a EFI setting or no EFI at all (not both). I figured it was the same process as a external hard drive so I followed similar steps. However, it will only working on the computer in which I installed it on. I have tried adding the flag to the EFI partition "ef00" using gdisk, installing over a virtual machine, I have tried everything I could find that I can do.

I don't know else I can do this. Please help. Thanks in advance.

Ookinder
  • 103
  • 2
    Gdisk is a partition tool. For full install to any external device you have to partition in advance with an ESP - efi system partition on external. Then copy /EFI/ubuntu from drive seen as sda to external and copy again to /EFI/Boot on external and rename shimx64.efi to bootx64.efi. You also need to edit fstab with correct UUID for external drives' efi partition (ESP). UEFI only boots /EFI/Boot/bootx64.efi from external drives. https://ubuntuforums.org/showthread.php?t=2338836 – oldfred May 17 '17 at 23:38
  • It helps if you can remove the internal drive from from computer, where you intend to install Ubuntu to the target USB stick. Then the installer will treat the target USB stick as if it were an internal drive. You can try according to the following links and links from them. https://askubuntu.com/questions/912254/bootable-ubuntu-usb-with-custom-kernel/912280#912280, https://askubuntu.com/questions/912254/bootable-ubuntu-usb-with-custom-kernel/912280#912280, https://askubuntu.com/questions/911673/installing-ubuntu-17-04-to-an-external-drive/911690#911690. Alternative: persistent live drive. – sudodus May 18 '17 at 00:56
  • oldfred, I have tried doing that but it keeps trying to boot from a UUID that isn't there. Is there something I am missing. I have done all the steps you listed in your comment. It just brings me to grub rescue saying "error: no such device" and the UUID of the device that isn't present. – Ookinder May 18 '17 at 01:06
  • sododus, I have tried that aswell. No use. It only wanted to boot from the computer I did it on, but non else. I'd rather have a perfectly running Ubuntu OS on the drive then a persistent live drive either. Sorry. – Ookinder May 18 '17 at 01:27
  • @Vencorr, What computer is it? If you have a bootable installed system in a USB stick, the computer will boot from it, if you can select a temporary boot menu via a hotkey (different in different computers, can be F9, F10, F12 ...). Another alternative is to clone from a [compressed] image file of a working installed system according to https://help.ubuntu.com/community/Installation/UEFI-and-BIOS – sudodus May 18 '17 at 01:38
  • 1
    @sododus It is an HP Pavilion 2013 that I am using. I know how to use the boot menu and such. The problem is that after installation, choosing the usb flash drive will either just put me in a boot loop, or skip it. Using an image file didn't work out well for me at all. I don't know what the problem is. This is a perfectly working USB drive. – Ookinder May 18 '17 at 04:12

1 Answers1

1

HP rings a bell

Several HP computers with the same and similar age as your computer do not 'want to' boot via grub, if there is a GUID partition table, when accessed via USB. If there is an MSDOS partition table and the boot partition has a boot flag, it works. (Normally booting via grub should not bother about the partition table or boot flag.) My son and some friends have such computers, and I have tested and verified this behaviour more than once.

You can check the partition table with the following command

sudo parted -ls

Unfortunately dd_text_16.04-UEFI-n-BIOS_2017-05-07_intel-4-pendrive-7.8GB.img.xz has a GUID partition table.

Modell: SanDisk Extreme (scsi)
Disk /dev/sdd: 16,0GB
Sektorstorlek (logisk/fysisk): 512B/512B
Partitionstabell: gpt
Disk Flags: 

Nummer  Början  Slut    Storlek  Filsystem       Namn  Flaggor
 1      1049kB  316MB   315MB    fat32                 startbar, esp
 2      316MB   317MB   1049kB                         bios_grub
 3      317MB   7262MB  6946MB   ext2            root
 4      7262MB  7799MB  537MB    linux-swap(v1)

Test

But I think it will work for you from the following image, dd_Lubuntu_16.04.2_amd64_persist-live_mkusb-12.1.4_7.8GB_msdos-pt.img.xz. It has the correct partition structure to boot also in 'middle-age HP computers'.

Modell: SanDisk Extreme (scsi)
Disk /dev/sdd: 16,0GB
Sektorstorlek (logisk/fysisk): 512B/512B
Partitionstabell: msdos
Disk Flags: 

Nummer  Början  Slut    Storlek  Typ       Filsystem  Flaggor
 3      2097kB  130MB   128MB    primary   fat32      startbar
 4      130MB   1072MB  942MB    primary
 2      1072MB  6443MB  5372MB   extended             lba
 5      1073MB  6443MB  5371MB   logical   ext2
 1      6443MB  7799MB  1356MB   primary   ntfs

In linux you install from compressed image files with mkusb. In Windows you can use Win32 Disk Imager.

Final installation

I remember that you don't want a persistent live system, but if you test it and it works, you can create an MSDOS partition table with the relevant partitions and flags in your USB stick. gparted is a good tool for this purpose.

Then you can install Ubuntu into it with Ubuntu's standard installer. It is easiest, particularly in UEFI mode, if you disconnect (unplug) the internal drive.

Select 'Something else' at the partitioning window of the installer. The target USB stick will be seen as an internal drive, when booted from another USB stick, and the installer will install the EFI boot files into it. (Otherwise the EFI stuff will be written into the internal drive and you have to copy it manually, which is possible but tricky.)

Tweaks

This link describes some tweaks for the installed system.

sudodus
  • 46,324
  • 5
  • 88
  • 152