7

Self-explanatory question. But please keep in mind in totally new to Linux.

  • I really request you to answer this as though you were hypothetically going to explain to a 12 year old. Im actually 38, but the point is i find it difficult to follow things that intermediate Linux uses are cool with.
  • If there is a similar question previously answered(I tried finding one for ~25 mins, found nothing for Lubuntu with good steps -- im stupid, i need steps) , please do not immediately shut my question... Maybe give me some time so i can test to see if it works and if it does, i'll shut the question myself!
  • I need this because I have to move around and travel a lot, and need a reliable way to port a full OS without the risk of damaging a laptop, and further once im there, i generally have access to a machine, and for the rest my phone suffices.
21
  • 3
    Welcome to Ask Ubuntu: Please see: How to Create a Full Install of Ubuntu 20.04 to USB Device Step by Step askubuntu.com/questions/1217832/… Jun 25, 2020 at 11:10
  • 1
    Does your boot,esp partition /boot/grub/ folder contain both i386-pc and x86_64-efi folders with a grub.cfg file a duplicate of the one in your root /boot/grub folder? Jun 25, 2020 at 12:40
  • 1
    Open Disks, highlight the target drive, then the boot,esp FAT32 partition, if there is a little triangle lower left click it. a blue link to the partition should appear double or triple click that, Files should open, double click the boot folder, then the grub folder. do you see the items I mention above? Jun 25, 2020 at 13:10
  • 1
    Copy Boot and EFI folders to it from the Live USB or from the Ubuntu iso file. confirm /boot/grub/ has i386-pc and x86_64-efi folders. overwrite grub.cfg with the one from thr root /boot/grub/ folder then reinstall grub per my instructions. Jun 25, 2020 at 13:52
  • 1
    @sudodus That would make it easy to install to USB. It makes a pretty big download but could save a lot of hassle. perhaps add a small NTFS partition that could be expanded. A small swapfile could also be expanded. Don't think we need a separate /home partition. Making it encrypted could be an option. Maybe provide it as an answer at askubuntu.com/questions/1217832/… Jun 25, 2020 at 16:46

4 Answers 4

5

I presume you want a persistent (full-installation) on this USB. It is possible to make a USB installation that can boot in both Legacy and UEFI modes, but it requires some effort:

First, you have to have an installation media that boots in both Legacy and UEFI. Tools such as Rufus or Ventoy can be used to create these. For example, if using Rufus, when making the installation medium, set the partition scheme to "MBR" and the target system to "BIOS or UEFI". If using Ventoy (which can be run under Linux as well as just Windows), it will support both Legacy and UEFI by default, just copy the Lubuntu ISO to the USB.

  1. Plug in your installation medium and boot from it through Legacy mode first. Select "Try Lubuntu" at the menu.
  2. Once at the desktop of your live system, plug in the USB you wish to use as the target (which Lubuntu will be installed onto).
  3. Connect to the internet if not already connected.
  4. Open a terminal and run sudo apt install gparted. LXQt has KDE Partition Manager by default, however Gparted works better in cases like this.
  5. Launch Gparted. Change the dropdown in the top right-hand corner to your target USB device.
  6. Right click any existing mounted partitions and unmount/swapoff them.
  7. Select "Device" on the top bar, and select "Create partition table". Change the dropdown to "GPT" (note: this will erase all data on the disk, ensure data is backed up to your satisfaction first!).
  8. Create a new partition. The size should be 1MB and the file system should be unformatted.
  9. Create another partition. The size should be 100MB and the file system should be FAT32.
  10. Create another partition. The size should be around ~1GB and the file system should be swap.
  11. Create one last partition, which will be used as the root filesystem of your installation. The size should be however much space you have left on the disk. File system should be ext4.
  12. Apply the changes by clicking the tick button in Gparted.
  13. Right click the 1MB partition, select "Manage flags", and set the flags to bios_grub.
  14. Also set the flags of the 100MB partition to boot and esp.
  15. Close Gparted and proceed with the installation as you normally would, until you reach the partitioning step.
  16. Select "Manual partitioning" or "Advanced" at the partitioning step. You'll be asked to specify the partitions to use for installation.
  17. Set the 1MB unformatted partition to "Reserved BIOS boot area".
  18. Set the 1GB swap partition as swap.
  19. Set the ext4 partition as the root partition (mount point = /). If it is shown, check the box to specify to format this partition.
  20. Don't forget to change the bootloader dropdown to your USB drive!
  21. Confirm that the partitions are correct and then continue.
  22. Wait for installation to finish, then power off your machine.
  23. Boot from your installation media again, this time in UEFI mode. Follow the same steps to get to the live system desktop.
  24. Plug in your target USB again.
  25. Connect to the internet.
  26. Open a terminal.
  27. Run sudo fdisk -l. Take note of the /dev/sdx label of your USB drive, it will probably be /dev/sdb or /dev/sdc. In these next commands, /dev/sdx will refer to your disk. Make sure you substitute the x for the actual letter shown for your one!
  28. sudo umount /dev/sdx4
  29. sudo swapoff /dev/sdx3
  30. sudo umount /dev/sdx2 (this one may not be mounted but its best to make sure they're all unmounted anyway)(sdx1 is the BIOS boot partition so it will never be mounted).
  31. sudo mount /dev/sdx4 /mnt
  32. sudo mkdir -p /mnt/boot/efi
  33. sudo mount /dev/sdx2 /mnt/boot/efi
  34. sudo swapon /dev/sdx3
  35. sudo mount --bind /dev /mnt/dev
  36. sudo mount --bind /dev/pts /mnt/dev/pts
  37. sudo mount -t proc proc /mnt/proc
  38. sudo mount -t sysfs sysfs /mnt/sys
  39. sudo mount -t tmpfs tmpfs /mnt/run
  40. sudo chroot /mnt.
  41. apt install grub-efi-amd64 (EDIT: If on 32-bit instead of 64-bit, run apt install grub-efi-i386 instead).
  42. grub-install --efi-directory=/boot/efi --target=x86_64-efi --removable (this will install the UEFI bootloader. It will not conflict with your existing Legacy bootloader installation) (EDIT: If you experience problems at this stage, mount /dev/sdx2 /boot/efi and then try again)(EDIT 2: It may also be possible to copy the EFI bootloader files from the live system instead of installing like this, but I felt it was more robust to do a clean install of the bootloader)(EDIT 3: Replace --target=x86_64-efi with --target=i386-efi if on a 32-bit system).
  43. update-grub.
  44. blkid | grep /dev/sdx2 (x is still a placeholder here). From the output of this command, take note of the UUID number, which is in the format XXXX-XXXX.
  45. echo "UUID=XXXX-XXXX /boot/efi vfat umask=0077 0 1" >> /etc/fstab (XXXX-XXXX is still a placeholder, replace it with your partition's UUID).
  46. Now exit your chroot.
  47. Power off your system (all currently mounted partitions will be unmounted automatically).
  48. Boot from your new installation in either Legacy or UEFI mode; both will work!

Enjoy your system. If any of this doesn't make sense I'll be happy to clarify it. I have personally tested this before myself (for Kubuntu not Lubuntu), and works fine.

20
  • Doubt at step 17.... Lubuntu 20.04 seems to have these settings unavailable.... Either that or I just don't know how to get to them. I've tried right-clicking ,which yields no result and neither do any menu icons... Will have to ditch the GUI and hit the terminal ? screenshot : [ drive.google.com/file/d/1qPO-qgf3zP6aFlMDAvvyEbRVUvyN1Fxy/… ]
    – An Ant
    Jun 25, 2020 at 10:04
  • Okay... so no issues apparently... apparently the GUI is 10 steps ahead of me, and I can only change the the etx4 partition to root (/) and I'm guessing it configures the other automagically, since it wouldn't let me touch the setting of other partitions without formatting, which to me implies that it knows what its doing withe them... great ! I've set this to install at step 21 ~ 22.
    – An Ant
    Jun 25, 2020 at 10:15
  • Errors @ Step 41-42 ...running 41 gives me some errors that do not seem to impede what I'm doing, but trying out step 42 gives me ' grub-install: error: /boot/efi doesn't look like an EFI partition.' Relevant Screenshot attached here [drive.google.com/file/d/1qPO-qgf3zP6aFlMDAvvyEbRVUvyN1Fxy/…
    – An Ant
    Jun 25, 2020 at 11:09
  • Wrong screenshot link in above comment. correct screenshot link --> drive.google.com/file/d/1HUBYBUIoP16WXVrgSErspYMyVbHs78MR/…
    – An Ant
    Jun 25, 2020 at 11:19
  • I am in such deep sh*t, @DanielMassey , So if you see the screenshot error , right after that I absolutely have no idea to do, my system. I'm sitting and waiting for you. I have no idea what witchcraft commands I used, all I know is I need help to get beyond this error !
    – An Ant
    Jun 25, 2020 at 15:36
3

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

  • 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

  • If created 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

4
  • @An Ant: Here is the simplified full install procedure I promised you, Better late than never. Jun 26, 2020 at 13:47
  • After configuring Linux to my tastes, i see that i need no more than 6GB for the root partition (currently occupies only 5.2GB) ... When I attempt shrinking the root partition in GParted, I have no success. I intend to create an ExFAT partition with the unused storage to utilise this space as a regular flash drive , to move files from here to there. When i need space, I'll just extend the ext4 partition.... But i'm unable to shrink it ! What should I do, Cameron and @Daniel Massey
    – An Ant
    Jun 27, 2020 at 1:23
  • 1
    @ An Ant: I have never had luck shrinking the root partition beyond what GParted wants. Once it runs out of space it will not boot. I have not had luck with ExFAT, but It has been a while since I tried. Usually I have a NTFS partition unless there is a Mac in the picture, then I recommend a FAT32 partition. Data partition is missing from above guide but I will add it soon. Perhaps I will try ExFAT. I think the data partition should be created in the installer before the root partition so that it is No1 partition. Old Windows only sees the first partition on a flash drive. Jun 27, 2020 at 4:31
  • 1
    @An Ant: If you do not have a separate /home partition, your root partition will continue to grow. It might not be fun to be traveling and run out of space. Remember, you will need a computer running Linux to expand the root partition or delete data on it. Which means that you will need to carry a spare Live USB with you. Jun 27, 2020 at 5:39
0

I do it using YUMI Multiboot USB creator (you can download it from Pendrivelinux.com). It is used to put multiple operating systems on 1 pen drive. I have one that is set up for UEFI and one that is set for Legacy BIOS (Version YUMI-2.0.7.2 is legacy, version YUMI-UEFI-0.0.2.3 for UEFI (obviously). This has worked for me on older systems, if I wish a legacy boot on a UEFI BIOS, I disable secure boot.

0

Creating a Full install USB the Easiest way

(Password is "changeme", change it)

Thanks to sudodus for the image file, perhaps he will create one with Lubuntu also.

3
  • Brilliant, except its 15 gigs... I guess we sacrifice convenience for bandwidth/download time or bandwidth/download time for convenience.
    – An Ant
    Jul 3, 2020 at 5:31
  • @An Ant: It ends up as 15GB when flashed to disk, but it is only 2GB to download, That is better compression than the Ubuntu ISO. I don't think a Full install disk less than 16GB is practical. I made the remaining GB on mine a FAT32 data partition. Jul 3, 2020 at 5:48
  • Ah, I see. I though the downloaded size was 2 GB, my bad
    – An Ant
    Jul 3, 2020 at 7:57

You must log in to answer this question.

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