11

Every issue of Ubuntu LTS since 8.04, I have made a Full install of Ubuntu to USB flash drive, and recorded each step..

This has been intended to make a guide/check list for users wishing to create Full install bootable flash drives.

Previously the procedure worked for BIOS boot if created in BIOS and for UEFI boot if created in UEFI.

This year for 20.04 the instructions should work for both creating and running the drive booted from either BIOS or UEFI.

The question is:

How to Create a Full Install of Ubuntu to USB device with Step by Step instructions that work in either BIOS or UEFI.

  • My aplogies to post this as an Answer but I cannot add comments (my reputation is nonexistent) This is a question for the OP (possibly a dumb one) C.S.Cameron. When you say "adjust for larger drives". do you mean:' 32 GB ==> all partition sizes times 2 64 GB ==> all partition sizes times 4 etc.? except for "bios_grub" and "boot,esp" I guess PS: Great thread btw, I wish I could add more ups. – Caligola Apr 3 at 5:47
  • Thank you: If you build your system with everything you need on a 16GB drive and you clone that to 64GB drives you will have 3/4 of the drive unformatted. Do you want to reserve that space as ext4 for data and future programs or as a FAT32/NTFS data partition that Windows can also use? If Windows is not a factor forget the NTFS partition and use available space for the EXT4 partition. After cloning use GParted to stretch that partition to fill the drive, (except for the last 1MB on the right side). If you want lots of NTFS data space stretch the NTFS partition. Or a little of each. – C.S.Cameron Apr 3 at 6:28
  • I know Im a pain but don't really know how to do these 2: - Copy the boot and the EFI folders from the Live USB to the boot,esp partition sdx3. - Copy grub.cfg from partition sdx4 /boot/grub/ to partition sx3 /boot/grub/. – Caligola Apr 3 at 10:25
  • Open Files, (Nautilus), and right click on the Ubuntu.iso file, select "Open With Archive Mounter", The Ubuntu.iso file will appear on the left, (like a folder), open it and you will see a bunch of folders, Boot and EFI can be copy pasted to sdx3. First open Disks and select your USB, left click Filesystem 3, click the triangle button, click the link lower right. sdx3 will open, paste Boot and EFI. Click Filesystem 4, Click the link, open boot, open grub, copy grub.cfg, open grub on sdx3 and overwrite grub.cfg with the copy from sdx4. – C.S.Cameron Apr 3 at 11:13
  • I can neither see the ubuntu.iso file in Nautilus nor have any "Archive Mounter" option in the right click dropdown (Open with... doesn't help either). I think I made an "original mistake". As a live usb I am using the iso image downloaded from the official site flashed with UUI (Pendrive linux) from windows, while your instructions call for making it from a working linux environment with SDC, Unetbootin, etc. – Caligola Apr 4 at 6:52
12

Creating a Full Install of Ubuntu 20.04 to USB that works in both BIOS and UEFI

Following is based on a 16GB Target drive, adjust for larger drive. This looks like a long list but, should take less than ten minutes to do the work.

  • Create a Live USB or DVD using SDC, UNetbootin, mkusb, dd, etc. (See Note 1 at bottom)
  • Turn off and unplug the computer.
  • Unplug the power cable from the hard drive or unplug the hard drive from the laptop. (See Note 2 at bottom)
  • Plug the computer back in.
  • Insert and boot the Live USB or Live DVD. (Booting BIOS mode preferred).
  • Select Language and Try Ubuntu.
  • Insert the target flash drive.
  • Start GParted.
  • Unmount any mounted partitions.
  • Select Device tab and create a GPT partition table on the Target drive.
  • Create a 3GB NTFS or FAT32 partition on the right side, (optional Linux / Windows data partition, See Note 3 at bottom).
  • Create a 1MB partition on the left side, format as unformatted.
  • Create a 300MB FAT32 partition next to the 1MB partition.
  • Create a 7GB ext partition next to the 300MB partition.
  • In the remaining space create an ext4 partition, (optional for /home partition).
  • Apply All Operations.
  • Flag the 1MB partition as bios_grub.
  • Flag the 300MB partition as boot,esp.

Image of GParted

  • Start Install Ubuntu.
  • Select Language, click "Continue".
  • Select Keyboard layout, click "Continue".
  • Select Wireless network, click "Continue". (optional).
  • Select installation preference and select "Download updates while installing Ubuntu", (optional), and Select "Install third-party software ...", click "Continue". (Optional).
  • If asked about mounted partitions, select Yes, click "Continue".
  • Do not use Advanced feature disk encryption for this install method. (See Note 3 at bottom).
  • At "Installation type" select "Something else", click "Continue".
  • Under Device for boot loader installation select the target drive.
  • Select partition sdx4 and click change, select use as Ext4, select format this partition, and Mount point = "/" then OK.
  • If asked to Write previous changes... click Continue.
  • Select partition sdx5 and click change, select use as Ext4, select format this partition, and Mount point = "/home" then OK. (optional).
  • Click Install now.

Image of  Something else

  • Confirm partitions to be formatted if asked, click continue.

  • Select your location. click "Continue".

  • Insert your name, computer name, username, password and select if you want to log in automatically or require a password. - Click "Continue".

  • Wait until install is complete.

  • Do not reboot or unplug the target USB.

  • Copy the boot and the EFI folders from the Ubuntu ISO file to the boot,esp partition sdx3.

  • If there any problems with permissions, etc, open Nautilus using sudo -H nautilus and try copying again.

  • Copy grub.cfg from partition sdx4 /boot/grub/ to partition sdx3 /boot/grub/ overwriting the grub.cfg file.

  • Re-Install GRUB:

    sudo mount /dev/sdx3 /mnt
    sudo grub-install --boot-directory=/mnt/boot /dev/sdx

  • Turn off computer and plug in the HDD.

  • Replace the computer's cover.

Note 1, Booting ISO Files.

  • If you want the USB to have the ability to boot ISO files using GRUB, create the boot drive using mkusb with the usb-pack-efi option. (this replaces GRUB 2.04 with 2.02).
  • Alternatively you can put rmmod tpm anywhere above the first menuentry in grub.cfg.

Note 2: Hard drive removal.

  • You may omit disabling the hard drive in BIOS boot if after partitioning you choose to install grub to the root of the USB drive you are installing Ubuntu to, (ie sdx not sdx1). Be cautious, many people have overwritten the HDD MBR as default location for boot loader is sda, any items in the internal drive's grub will be added to the USB's grub. You may do an update-grub later. If you leave the HDD plugged in with UEFI install, fstab may use the HDD's UUID for /boot/efi. In this case # or delete the /boot/efi.UUID line in fstab.

Note 3: Apple compatibility.

  • If you own an Apple computer make this partition FAT32.

Note 4: Encryption (optional).

| improve this answer | |
  • +1; Good and detailed description. Have you done thiis when booted in UEFI mode as well as in BIOS mode? Would the same instructions work in both cases? (Maybe you have explained it already, but I did not find such details.) – sudodus Mar 17 at 14:04
  • If you cannot disconnect drive, you may have UEFI drive settings to disable it. I just unmount & mount correct ESP during install. Posted work around to manually unmount & mount correct ESP during install #23 & #26 bugs.launchpad.net/ubuntu/+source/ubiquity/+bug/1396379 – oldfred Mar 17 at 14:27
  • 1
    @sudodus : I have been testing for about two weeks now, I have built the drive booted both from BIOS and UEFI and have run the drive from BIOS and UEFI. All work OK for me. I have also built the drive using a mkusb Live drive that was created with the usb-pack-efi option. This booted extra ISO files per Note 1. I would be happy if you gave it a check, it only took me 6 minutes from booting the live drive to typing my name and password. – C.S.Cameron Mar 18 at 4:44
  • @oldfred : So far, I have not had a problem disconnecting USB, however I am on vacation and only have two computers with UEFI on me. other computers are BIOS only. – C.S.Cameron Mar 20 at 8:45
  • @stomwerk You can have the ISO on an external USB or on the Live USB. I have just copied the the boot and the EFI folders from the Live/Persistent USB I am using to make the drive. They are located in filesystem/cdrom/ when booted from the Live USB. – C.S.Cameron Jun 25 at 9:32
2

Easy way to get installed Ubuntu 20.04 LTS that boots in UEFI and BIOS

enter image description here

This is the easy way for you to get an installed Ubuntu system, that boots both in UEFI and BIOS mode, and you can use it in several cases. However,

  • if you want to learn how to do it, or
  • if you want to be sure of the content (and don't rely on me), or
  • if you want hibernation, or
  • if you want an encrypted disk (LVM with LUKS encryption),

then you must do it yourself. (In the encrypted disk case, you must create the passphrase yourself during the installation.)

Using a method similar to what is described by C.S.Cameron I have created

  • a compressed image file of
  • an installed system of Ubuntu 20.04 LTS
  • that can boot both in UEFI mode and BIOS mode (alias CSM alias legacy mode).

This compressed image file expands to 15.7 GB, so it fits into drives with size at least 16 GB. It is easy to extract and clone it to an external drive

  • with mkusb (only one step),
  • but you can use any
    • extraction tool,
    • plus cloning tool,
    • plus a tool to fix the gpt partition table gpt-fix. You may have problems in Windows to find such a tool, and in several cases you can skip it, and the drive will work anyway.

After extraction, cloning and fixing, it is a good idea to expand the root partition, where Ubuntu is installed in order to use the whole drive, when you are using a big drive ( > 16 GB ).

There are more details about this image file

dd_unb_ubuntu-20.04_15GB_2020-06-26.img.xz

at the following link,

help.ubuntu.com/community/Installation/UEFI-and-BIOS

Finally, the installed system has a password, and you are encouraged to change it,

Password: changeme
| improve this answer | |
  • 1
    Thank you, I am downloading now. – C.S.Cameron Jun 27 at 4:54
2

Simplified Full Install of Ubuntu 20.04 to USB that Boots BIOS and UEFI Mode

  • Download BIOS/UEFI Template: https://phillw.net/isos/linux-tools/uefi-n-bios/dd_grub-boot-template-for-uefi-n-bios.img.xz

  • Flash image to target USB using Win32DiskImager, Rufus, mkusb, balenaEtcher, etc.

  • It is recommended to unplug any internal drives especially when installing in UEFI mode.

  • Boot Live Installer USB, and insert Target USB.

  • Start install process, select: Language, Keyboard, Wireless, Updates and Something Else.

  • Select Target USB for Bootloader installation.

  • (Optional Data Partition), Select the empty space on the Target drive and click the plus sign to create a FAT32 partition with mount point "/Windows". Leave at least 6GB empty space for root partition.

  • Select the empty space on the Target drive and click the plus sign to create an ext4 partition with mount point "/".

  • Select Install now, confirm partition to be formatted, enter location, name and password.

  • When install is complete copy root /boot/grub/grub.cfg to overwrite boot,esp /boot/grub/grub.cfg

enter image description here

  • If created using Rufus/Etcher or in UEFI mode reinstall GRUB for BIOS boot:

    sudo mount /dev/sdx3 /mnt

    sudo grub-install --boot-directory=/mnt/boot /dev/sdx

Thanks to Sudodus for the mkusb based BIOS/UEFI Template

| improve this answer | |
  • 1
    @sudodus: I Finally got around to playing with the BIOS/UEFI template. It saves a lot of time and complexity making a Full install USB. I am wondering if there is anyway to automatically add rmmod tpm to Full install grub.cfg? So far I have only constructed a drive in BIOS mode but have booted it in BIOS and UEFI. Will make one in UEFI mode tomorrow. – C.S.Cameron Jun 26 at 14:19
  • What do you mean by automatically? You can 'borrow' it from the grub.cfg file that comes with the template. You can actually borrow the whole head of that file (and replace the head of the grub.cfg created by Ubuntu). – sudodus Jun 26 at 20:18
  • 1
    @sudodus: I was thinking of the "grub_platform" version, somehow embedding it in /etc/grub.d. It would be good enough if you could update "rmmod tpm" in grub.cfg to "grub_platform". Thanks for the Answer below. I'm sure that is the easiest way to make a Full install Ubuntu USB and it can be done completely in Windows using Rufus or Etcher. – C.S.Cameron Jun 27 at 4:52
  • If you use the method that I have used for the compressed image file, grub.cfg in the 'usbboot' partition will not be updated, not touched by update-grub. I have merged part of the original version there (for isoboot) with the version of the Ubuntu installed system in the root partition. The head and tail of the file is from the isoboot version and the middle with menuentries from Ubuntu root. I have modified the menuentries to use the links for vmlinuz and initrd to make it independent of upgrades of the kernel. - The future will show if it can resist upgrades of Windows and Ubuntu. – sudodus Jun 27 at 8:36
  • 1
    @sudodus: Made another Full install USB, this time using a UEFI booted computer. I added a FAT32 Data partition. Otherwise every step the same as above. This time "grub_platform" was in the correct place. Got error when booting BIOS mode "i386-pc/normal.mod not found". Re-installed BIOS GRUB. Also edited /etc/fstab to # out /boot/efi UUID line. All is running well. – C.S.Cameron Jun 27 at 8:48
1

Install Ubuntu from a Pre-built Image File.

This is another version of sudodus answer in step by step format.

If working in Windows:

The USB drive should boot on almost any modern X86-64 computer.

enter image description here

Thanks to sudodus for the image file.

In Windows it may be necessary to install 7Zip before proceeding. Rufus will use it when working with the .xz image: https://www.7-zip.org/a/7z1900-x64.exe

If working in Ubuntu: you can use mkusb, Disks or Etcher to flash the USB drive. P7zip may be needed to extract the image.

| 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.