5

I am a newbie with Ubuntu and am trying to make a USB stick that will boot Ubuntu on my PC (a Surface Pro) so that, without affecting the PC, I can boot up Ubuntu when I like and use it as an alternative OS.

Getting a bootable Ubuntu image onto a USB stick seems to be super-simple - you just go to https://ubuntu.com/download/desktop and follow the instructions to create a 'Desktop' image. This image is great in the sense that it will boot onto my PCs without any problem. However, as most people reading this will know, the 'Desktop' image is really a test-and-then-install version - anything you do while testing the image gets erased every time you finish using it. I believe this image is called the 'live' version.

So, I followed instructions I found on the web on how to use the live image to create a bootable USB stick. However, this creates an image which doesn't boot on the PC like the live image used to create it! I understand that the reason it won't boot is because it is a MBR (Master Boot Record) rather than GPT and/or UEFI version. I can quickly tell if a disk is likely to work because when I put it into an old HP laptop and start the boot menu, if the USB stick is listed as a "USB Hard Drive (UEFI)" then it is, as far as I can see, PC-bootable. The live image passes this test of course.

The web is full of instructions on how to convert an MBR disk to GPT (or whatever it is that I need) but I just can't find anything that actually works and some of the instructions look very complicated.

So, my first question is this: Is there a reliable process for converting a Ubuntu installation on a USB stick (that one has created with the 'Desktop' image) into a state where it will boot, i.e. has the same boot setup/configuration as the 'Desktop' image?

Or, failing that, can anyone tell me if there is an image which one can actually use as a normally installed version? Or can the 'Desktop' image be converted into a working version?

I'm surprised that this is all so difficult. If the boot configuration of the live image is considered acceptable and good (which it is as far as I can see) then why doesn't its own installation process create an image which boots like itself?

Thanks, K1tty

7
  • 5
    Does this answer your question? How to Create a Full Install of Ubuntu 20.04 to USB Device Step by Step Apr 19, 2021 at 8:16
  • This may answer your question howtogeek.com/howto/14912/…
    – David
    Apr 19, 2021 at 8:18
  • Archisman Panigrahi, just to let you know that I tried that process but towards the end of the installation I got a message saying "The 'grub-efi-amd64-signed' package failed to install into /target/. Without the GRUB boot loader, the installed system will not boot." I checked the amount of storage available in each of the partitions and found that the 7Gb partition (the one described in the instructions as /dev/sdd4) has no space left in it - my suspicion is that the install ran out of space. I will make that partition larger and try the install again.
    – K1tty
    Apr 19, 2021 at 11:08
  • 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 Apr 19, 2021 at 11:33
  • 1
    I can report that after a lot of messing around I have got the process to work. As a newbie I found a few things that were difficult, e.g. the grup2 core.img name did not appear in the 'File System' column as shown in the instructions. Also, sudo mount /dev/sdx3 /mnt about 4 stages before than shown. Also, when the OS install is complete you must press the 'X' and not 'Restart'. It does work though. I am typing this on my new USB-mounted OS!
    – K1tty
    Apr 19, 2021 at 15:39

3 Answers 3

7

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

4
  • 1
    Welcome to Ask Ubuntu. Very nice and detailed answer! Apr 20, 2021 at 9:11
  • 1
    Excellent. Instead of editing my version, I will add a note sending anyone with problems to this answer. Well done +1. Apr 20, 2021 at 10:26
  • 1
    The reason for the 3GB NTFS or FAT32 partition, sdx1, is that Windows versions prior to 10 can only see the first partition on a flash drive. Apr 20, 2021 at 10:30
  • Thank you to Zanna for helping tidy my writing up!
    – K1tty
    Apr 28, 2021 at 7:57
3

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.

5
  • Thanks, yes a new installer is definitely needed. I have spent nearly 3 whole days trying to get this to work. It's inefficient when you think how incredibly easy the live version is to get working.
    – K1tty
    Apr 19, 2021 at 15:40
  • 1
    The Calameres installer does provide an option for where to install the bootloader. Apr 20, 2021 at 9:07
  • Using an image file to install to USB is easier. Apr 20, 2021 at 10:32
  • Yes, I wondered about this. Now that I have a working bootable USB stick can I simply image it and recreate it at will?
    – K1tty
    Apr 20, 2021 at 11:42
  • Yes, I keep an image of my Full install USB on hard disk and reuse it quite often. For example: askubuntu.com/questions/1300540/… Apr 21, 2021 at 3:28
1

The instructions in the highlighted answer work flawlessly (original link: How to Create a Full Install of Ubuntu 20.04 to USB Device Step by Step). I successfully created a usb stick for Zorin OS 16 which is based on Ubuntu 20.04.

Prior to following these instructions, I had simply booted into the live session and installed the OS on my usb with bootloader location as the usb itself. While it worked, it made some changes to the Windows 10 bootloader I had on an attached internal drive - I didn't want that. So I deleted the entry for "Ubuntu" from by BIOS Boot Options (Dell 3410) and followed these instructions to give it another shot.

This time, I used a Virtual Machine to create the USB - no need for disconnecting any hard drives (I did not have any hard drives inside the VM too - just the Zorin OS ISO to boot from and my 16GB usb drive)

I skipped creating the partition for Windows as well as for /home. Just a 1Mb partition (bios_grub), 300Mb partition (boot, esp) and remaining 14GB space formatted with ext4 with mount point as / - this setup works well for me.

Though - if somebody can please tell me why we needed to copy the grub config file and those boot & efi folders into the boot partition - I thought installing bootloader on the usb should take care of all that.

2
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review Sep 10, 2021 at 8:10
  • @Aquib: we needed to copy the grub config file and those boot & efi folders into the boot partition so we can boot either BIOS or UEFI. Nov 8, 2022 at 6:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .