Creating a PC-Boot-able Ubuntu Installation

I now have this working largely thanks to this process...

How to Create a Full Install of Ubuntu 20.04 to USB Device Step by Step

...and for the benefit of anyone, particularly newbies like me, attempting it to create a Ubuntu bootable USB installation I offer my own notes to the (slightly modified) original which are indicated by bullet points:

  • Create a Live USB or DVD using SDC, UNetbootin, mkusb, dd, etc.

You can get this here: https://ubuntu.com/tutorials/create-a-usb-stick-on-windows#1-overview Note that this is a 'Live' version which, despite the name, is only any good for testing Ubuntu or installing it - any data you add to it will be erased (although user 'ChanganAuto' says that if a live session with persistence is enough for your needs then just 'burn' the ISO with MKUSB using the option to have persistence: help.ubuntu.com/community/mkusb#Persistent_live_systems)

  • Turn off the computer and reboot with the USB (Booting BIOS mode preferred).

  • Select your language and 'Try Ubuntu'.

  • Insert the target flash drive.

  • Start GParted.

You can find all installed apps by clicking on the icon at the bottom left of the screen and using the search option.

BE SUPER-CAREFUL HERE - YOU DON'T WANT TO MESS UP YOUR PC'S OPERATING SYSTEM!

Use the drop-down box in the top-right of GParted to select the disk you want to work on. His was /dev/sdd - mine was /dev/sdc and the various partitions will be numbered sdx1, sdx2, sdx3, etc. where x is the drive in your particular case.

  • Unmount any mounted partitions.

    Some of the partitions may mount automatically

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

    What he means by 'right' is the end of the drive's space. You are creating 3Gb of padding (why so much?) and a few steps later you will create a partition which fills up to this point (if that makes sense!)

  • Create a 1MB partition on the left side, format as unformatted.

    i.e. at the beginning

  • Create a 300MB FAT32 partition next to the 1MB partition.

  • Create a 7GB ext partition next to the 300MB partition.

    I found this was NOT enough and doubled it to 14Gb

  • In the remaining space create an ext4 partition, (optional for /home partition).

  • Apply All Operations.

    You do this by pressing the 'tick' or 'check' sign

  • Flag the 1MB partition as bios_grub.

    Note that when you do this the words 'grub2 core.img' do not appear as he shows them in his diagram. This is not a problem.

  • Flag the 300MB partition as boot,esp.

  • Start Install Ubuntu.

    The top left icon on the home screen is the one which does this

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

    I wasn't

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

    IN THE NEXT STEPS BE VERY CAREFUL TO FOLLOW HIS INSTRUCTIONS CAREFULLY...

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

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

    Sounds easy! However, at the end of the installation you get a message saying that you need to restart - do not do this. Press the 'X' at the top-right of the message box to get rid of it without restarting!

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

    Yes, I had rights issues. So...

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

    To do this you'll need use the 'Terminal' application which you can find in the same way as you found 'GParted'. Once Terminal is running just type:

     sudo mount /dev/sdx3 /mnt 
    

    (Note that I have moved this up from where it was in the instructions)

    And then sudo -H nautilus and you'll get a window where somehow - sorry can't remember exactly how it worked - you can put the directories where they are supposed to go.

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

  • Re-Install GRUB:

    So, using the Terminal again...

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

    Note that it is just 'sdx' and not 'sdx3' or whatever, i.e. it's pointing at the disk not a specific partition.

  • Turn off computer and plug in the HDD.

    Shut down Ubuntu using the icon in the top-right of the screen - don't just switch the PC off!

  • Now, with the USB in a PC, try booting it.

    Getting a bootable USB took me three days (yes three!!!) to get right. I sincerely hope these notes (and of course the work of the original author C.S. Cameron) will save you some time. :-)


This bug is why you had to copy boot & ubuntu from ESP to external drive's ESP.

Please add to this bug report, its very old and we are very frustrated that nothing is done. Various work arounds now found, but Ubiquity installer should let you choose where to install boot loader, like it does for a BIOS install.

Posted work around to manually unmount & mount correct ESP during install #55 or( #23 & #26)

https://bugs.launchpad.net/ubuntu/+source/ubiquity/+bug/1396379

Others suggest disconnecting all other drives physically or logically in UEFI settings, so install drive is first drive. Or removing boot flag/esp flag from first drive, so only ESP is install drive. (I have not had that work, but others have.) Or if you have ESP on second or external drive, you can just reinstall grub, either manually or using Boot-Repair's advanced mode & full reinstall of grub to correct drive. Or copy both /EFI/Boot & /EFI/ubuntu folders from internal drive's ESP to external drive's ESP.

Remove esp flag from Windows before install to second or external drive - Tim Richardson, also #12 & 18 in bug report How do I install Ubuntu to a USB key? (without using Startup Disk Creator)

I believe that changing boot flag does not work for me as I use grub2 to loopmount ISO, not a separate bootable flash drive.

They may not fix anyway as now they are working on a new installer, but if we keep highlighing issue, new installer may have it right.