Please provide step by step instructions for making a simple hand made Persistent USB that boots both BIOS and UEFI. No ISO9660 or ISO Booters please, I want to be able to easily modify the filesystem.
Simple Hand Made Persistent USB
Making a Grub2 booter that uses Persistent partitions is easy.*
- Boot Installed Ubuntu or Live USB.
- Insert Target USB.
- Start GParted.
- Create a GPT partition table on Target USB.
- Create a 1MB BIOS boot partition on the left, formatted as unformatted.
- Add a 300MB FAT32 EFI boot partition next to it.
- Add an ext4 root partition large enough for the Ubuntu ISO's contents, (~ 3GB for 20.04).
- Create an ext4 partition labeled casper-rw
- Add a NTFS data partition if desired.
- Apply all operations.
- Flag partition 1 bios_grub.
- Flag Partition 2 boot, esp
- Close GParted.
- Open the ISO's folder as Administrator, open the ISO using Archive Manager.
- Extract the ISO's contents to the Target's root partition.
- Drag and drop the boot and EFI folders from Archive Manager window to the EFI boot partition.
- Edit sdx2/boot/grub/grub.cfg adding set root=(hd0,3) after the first line that starts with
- Add a space and the word "persistent" after ---.
Install grub, if in BIOS mode or booted from USB drive run:
sudo mount /dev/sdx2 /mnt sudo grub-install --boot-directory=/mnt/boot /dev/sdx
If in UEFI mode on installed system, boot into the Target drive and run the above.
*Booting based on mkusb by sudodus
I tried to combine the methods
- described here by C.S.Cameron and
- by me at this do-it-yourself link
I installed a brand new Lubuntu Focal Fossa operating system in UEFI mode. Running that system I created a USB boot drive starting by creating the partition table with
gparted instead of cloning from a compressed image file.
- MSDOS partition table
- A FAT32 partition where the content of the iso file is extracted
- An ext4 partition to be used for persistence
It did not work to create a BIOS bootloader out of the box
sudo mount /dev/sdx1 /mnt/sd1 sudo grub-install --boot-directory=/mnt/sd1/boot /dev/sdx
This is what I was afraid of :-(
I could install the program package
grub-pc but it was not used, Instead the system complained that it did not work to install for the efi system. So I removed the program package
grub-efi-amd64-bin and after that
sudo grub-install --boot-directory=/mnt/sd1/boot /dev/sdx
grub-efi-amd64-bin into my installed system to have it 'complete' for UEFI tasks.
The USB pendrive works both in BIOS mode and UEFI mode. I tested with and without persistence via custom made menuentries.
This is not too difficult, but I am not willing to let a tool, that is made for users without much experience remove and reinstall the program package
grub-efi-amd64-bin because it is an important part of the boot system. In other words, I will keep the compressed image files in mkusb and in the instructions at this do-it-yourself link.