Ubuntu – How to make a portable Kubuntu on external drive (GPT) on UEFI computer


The problem: after installation Kubuntu on external SSD (Transcend ESD400 512Gb) on UEFI computer I can't use it on another one. I made some attempts but all of them were unsuccessful.

My computer: UEFI, Core i7 – 4 cores, Windows 7 Ultimate 64bit, 2 internal drives with GPT, external SSD with GPT.

Kubuntu distro: LiveUSB, created with Universal USB Installer, Kubuntu 14.04 LTS

External SSD was partitioned with GParted, partitions are alligned.

After each installation SSD was formatted and repartitioned. GRUB was checked: version 2.02, EFI (not grub-pc).

Attempt 1: with plugged internal drives.

I booted from LiveUSB. Perform usual installation. My partition table:

512Mb - EFI - fat32
30Gb - / - ext4
100Gb - /home - ext4
50Gb - /usr - ext4
50Gb - /opt - ext4

Bootloader was installed on External SSD (/dev/sdc).
After rebooting I found 2 boot entries ubuntu in UEFI. If my external SSD is plugged and I choose every of this 2 entries – everything works well: Kubuntu starts and works. If the external SSD is off – a black screen Minimal BASH-like line editing is supported appeared. If I choose UEFI TS512... (boot entry with label of the external SSD), it seems that the next entry works (Windows Boot Manager).

Attempt 2: with unpluged internal drives.

Installation procedure was the same. After rebooting system started and worked. But after plugging the internal drives, on booting from external (both ubuntu and UEFI TS512... entries) a black screen with blinking text cursor appears and nothing wants to start. If I choose Windows Boot Manager Windows starts well.

Attempt 3: tried to modify efi files.

Copied grubx64.efi from /dev/sda1 to dev/sdc1 and renamed to bootx64.efi. Nothing new – it goes down the list of entries until Windows Boot Manager.

Attempt 4: tried to modify grub.cfg and fstab.

In /boot/grub/grub.cfg replaces all hd2 with hd0. And in fstab I changed the UUID of EFI partition: before it pointed to /dev/sda1, now it points to /dev/sdc1.

So how can I make a portable system on external SSD, that will boot on every UEFI computer, but not only on mine?

Best Answer

Your problem is that the EFI boot process stores data on the boot loader's location in NVRAM, so when you install on one computer and then move the disk to another computer, the second computer doesn't know where to look to find the boot loader. The usual way around this problem is to use the default/fallback boot loader filename, EFI/BOOT/bootx64.efi, on the EFI System Partition (ESP; that's your FAT32 partition). The firmware looks for this filename on removable disks. The big caveat is that you may need to use the firmware's built-in boot manager to select that disk, and the details of how to access that boot manager vary from one computer to another.

You can copy the boot loader to that location manually. The way that's most likely to work, from a working Ubuntu installation, is:

cd /boot/efi/EFI
sudo mkdir -p BOOT
sudo cp ubuntu/shimx64.efi BOOT/bootx64.efi
sudo cp ubuntu/grubx64.efi BOOT/grubx64.efi

Note that these commands will overwrite any existing EFI/BOOT/bootx64.efi boot loader. You probably don't have one on your external disk right now, but you might want to double-check this. Also, this assumes that the ESP on the external disk is mounted at /boot/efi. You should definitely double-check that with df before you proceed. You don't want to overwrite the boot loader on your internal disk by accident!

If you're sure that you'll be booting with Secure Boot disabled, you could copy EFI/ubuntu/grubx64.efi to EFI/BOOT/bootx64.efi, but that won't work if the target computer has Secure Boot enabled.