UEFI full install to a USB using another USB install media.
Superfically the same as a legacy install with the addition of an EFI partition on the target USB, but there are problems which may leave you with an unbootable target and even host.
First decide if you want MSDOS or GPT partitioning on the target USB. You might want MSDOS partitioning if some (older) machine wont boot with a GPT USB stick. GPT probably is the default here. In either case, your first partition will be the 300M EFI partition.
It will have a FAT32 filesystem and the boot flag.
Next decide if you want the target USB to boot with both UEFI
and legacy MBR bootloaders. This depends upon how you want to use the
USB. It's a little more work, but does improve portability. If you
are using GPT partitioning, you will need to include a 1M partition
without a filesystem, with the grub-bios flag. You can just add the
1M partition now and for a later project to add the legacy grub-pc bootloader to your UEFI stick.
Select in your UEFI settings (formerly known as the BIOS) the ones which allow your install USB to boot in UEFI mode. The install media can boot in both modes, so to create a UEFI target, it needs to boot in UEFI mode.
The rest of the USB target may be your root (/) filesystem. Don't bother with swap, it will be unbearably slow and if used, will cause more rapid wear on the stick. For the filesystem, avoid journaling, which may also cause undue wear -- ext2 or ext4 without journaling. You may need to set "ext4 without journaling" before running the installer, that may not be a choice.
Boot the install media, if you set up the partitions, select the
"something else" choice, then identify the root (/) and EFI System
Partition (ESP). The bootloader location you want to be the
target USB, (example /dev/sdc), but whatever you enter, will be
ignored. Run the install, and then start dealing with the problems.
1) The bootloader location you input for your target is ignored,
and the bootloaders get copied to sda's ESP.
Fix: Copy everything in the sda EFI partition to the target's EFI partition.
These are just files, copy them any way you like, keeping the directory structures.
2) One of the bootloader files improperly copied to sda, grub.cfg, references the target USB. This file overwrites the grub.cfg in the host's EFI partition, so the host will no longer boot without the target USB present.
Fix: Before the install, backup your host's /boot/efi/EFI/ubuntu/grub.cfg to .../grub.cfg.good so you may easily restore it after it gets overwritten.
3) Assuming you copied all the files in the host's ESP to the target's, the bootloaders are still in the wrong location for removable media.
Fix: Removable media boots off /EFI/Boot/bootx64.efi, so copy grubx64.efi and if present, shimx64.efi, from /EFI/ubuntu to /EFI/Boot, then rename shimx64.efi if present to bootx64.efi. If shimx64.efi is not present, rename grubx64.efi to bootx64.efi.
4)If your host was running with secure boot enabled, your nvram boot entry was shimx64.efi. The install to USB may have changed that to grubx64.efi.
Fix: Restore the nvram entry with efibootmgr. In this case, (boot failure of the first boot entry), some machines may try a fallback to /EFI/Boot/bootx64.efi,
the removable media bootloader, before they try the second item in the bootorder. For this reason, I recommend setting up the host's /EFI/Boot just like the USB target's, with a bootx64.efi which is a copy of shimx64.efi or grubx64.efi.
There's an easy alternative, install to the USB target in legacy mode and add the UEFI bootloaders later. Use MSDOS partitioning, have a 300M FAT32 EFI partition, and a root (/) partition. Select the UEFI settings to boot your install media in legacy mode. Select "something else" in the installer, and select your root on the target. This is a normal legacy install which causes no problems.
After the install, copy everything in the host's ESP to the target's ESP. This brings over the Windows bootloaders, and the /EFI/Boot directory.
Find the target USB's UUID with:
Make a directory on the EFI partition at /EFI/ubuntu
In the EFI/ubuntu directory, make a file named grub.cfg with the UUID and disk and partition for the root partition:
search.fs_uuid YourUUID root hd1,gpt2
Put a copy of shimx64.efi and grubx64.efi into /EFI/Boot, and rename the shimx64.efi to bootx64.efi. These files may be found on the
install media under /EFI/BOOT, with the reaname already done.
The target should now be able to boot in UEFI mode! Optionally, you can make the ESP mount point /boot/efi on the target, and add a line on the target's /etc/fstab to mount the EFI partition there. You might want to do this if you install the grub-efi package, which may
occasionlly update the bootloaders, but if they work, the only reason for doing that is security updates.
There's really not much difference between a legacy and UEFI install, just the bootloaders really.