33

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.

C.S.Cameron
  • 19,519
  • 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 03 '20 at 05:47
  • 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 04 '20 at 06:52
  • Since my boss was so kind (...) to equip me (read burden me) with a second and third laptop, I am currently wiping out one of them (an turning it into an ubuntu 19.10 and restart from there. I'll let you know how it goes. either way great support C.S.C – Caligola Apr 04 '20 at 06:52
  • Hi CSC. Got passed those two steps, now I bump into someting else: reinstalling GRUB:

    sudo mount /dev/sdb3 /mnt # the target has sdb partition prefix gets me: can't find in etc/fstab

    – Caligola Apr 04 '20 at 08:42
  • 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 03 '20 at 06:28
  • 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 03 '20 at 11:13
  • 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 03 '20 at 10:25
  • @ThomasWard, Please tell me why you have deleted my answer and an answer by C.S.Cameron (in this thread). He and I think these answers are useful, and we refer to them from several other answers here and at the Ubuntu Forums. – sudodus Dec 16 '20 at 07:53
  • I found these instructions very useful but there are one or two areas where newbies may have questions so I have added some notes here: https://askubuntu.com/questions/1332371/creating-a-pc-boot-able-ubuntu-installation/1332619#1332619 – K1tty Apr 20 '21 at 09:01
  • Thank you, I will have a read and edit as I am able. – C.S.Cameron Apr 20 '21 at 09:40

1 Answers1

36

Follow this link for a step by step guide for Ubuntu 22.04.


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. K1tty has done an excellent job clarifying many points in this answer, see https://askubuntu.com/a/1332619/43926

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

Archisman Panigrahi
  • 28,338
  • 18
  • 105
  • 212
C.S.Cameron
  • 19,519
  • +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 '20 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 https://bugs.launchpad.net/ubuntu/+source/ubiquity/+bug/1396379 – oldfred Mar 17 '20 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 '20 at 04: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 '20 at 08: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 '20 at 09:32
  • @Thomas Ward: Why have three valuable answers on this page just been deleted. They each provide a simple method of creating a Full install to USB? – C.S.Cameron Dec 16 '20 at 01:14
  • maybe sudo grub-install --boot-directory=/mnt/boot --removable – VidathD Jan 09 '21 at 23:40
  • @Sasuke Uchiha: Greetings from Hikkaduwa, Will that work if there is more than one USB drive plugged in? I will give it a try when I get a chance, sounds like a good idea, thanks. – C.S.Cameron Jan 10 '21 at 02:26
  • @C.S.Cameron Greetings from Gampaha. Wait are you from SL? I did this in kali in a vm by chrooting into the drive from the installer shell sooo not sure – VidathD Jan 10 '21 at 05:17
  • Nice. Hope you like the country. btw, that command should be grub-install --efi-directory=/mnt/usb --boot-directory=/mnt/usb/boot --removable See https://www.gnu.org/software/grub/manual/grub/html_node/Installing-GRUB-using-grub_002dinstall.html – VidathD Jan 10 '21 at 06:49
  • @Sasuke Uchiha: I will try that. – C.S.Cameron Jan 10 '21 at 10:09
  • I am getting the /casper/vmlinuz not found at boot time. Is there any solution? – GuPe Jul 25 '21 at 13:08
  • @Guacho Perez did you try the drive on another computer? Try it on both BIOS and UEFI boot. Confirm /boot/mgrub/grub.cfg got copied from sdx4 to sdx3. https://askubuntu.com/a/1332619/43926 clarifies many above points. – C.S.Cameron Jul 26 '21 at 00:35
  • With this above solution (having portable ubuntu in my USB, including grub bootloader in USB) Can I upgrade new ubuntu version in my USB drive without effecting windows bootloader? or anything that I have in my computer's Hard drive? @C.S.Cameron – Shateel Feb 07 '22 at 11:11
  • 2
    @Shateel I have upgraded Full install USB's many times and never had a problem. – C.S.Cameron Feb 07 '22 at 16:30
  • @C.S.Cameron Thanks! any chance that you will make tutorial on Kali Linux Portable (Installation Version) just like this tutorial. – Shateel Feb 07 '22 at 17:42
  • What if you use a VM and mount the flash drive directly to the VM and use the ISO to install as you would do on a normal hard drive – poqdavid May 20 '22 at 22:09
  • @poqdavid There are many ways to create a bootable Ubuntu drive. Another method using VBox is to convert a VDI file to IMG and then install that to Disk using Rufus, Etcher, Gnome Disks or mkusb. – C.S.Cameron May 20 '22 at 23:12
  • @C.S.Cameron So there is no down side to installing any linux flavor in a USB using a VM well except flash drives can be slow – poqdavid May 21 '22 at 04:33
  • Ubuntu will run in RAM as long as there is enough of it. RAM is a lot faster than SSD or HDD. – C.S.Cameron May 21 '22 at 04:38
  • Copy the boot and the EFI folders from the Ubuntu ISO file to the boot,esp partition sdx3. I would clarify telling that sdx3 is the boot_esp partition and that to copy from /media/cdrom you shoud previously mount the partition using Disks. – Federico Paolantoni Aug 12 '22 at 12:33
  • I followed the instructions carefully and made sure to select the bootloader installation to the root of the stick (sdd, not sdd1). Still, the windows bootloader on the Laptop HDD was overwritten, and the stick only works on this particular laptop. I need to repair both, the stick and the laptop. How would I do that? – Hauptideal May 18 '23 at 11:54
  • @Hauptideal: If you tried this method booted from UEFI mode, check the USB's /etc/fstab file to see if there is a line mentioning the laptop's UUID. If so try adding # at the beginning of the line. Please let us know if this works for you. – C.S.Cameron May 18 '23 at 12:21