Makeusb
Makeusb
1 Introduction
Sometimes one needs to save an installed Linux, but keep it available for occasional
viewing. A conventional backup of its partition(s) will do , but it is inconvenient to
have to restore it to use it. A convenient solution is to copy it to a USB drive, and make
the drive bootable.
There are two ways of transfering a running Linux to a USB drive. There is a good
FOSS article [1] on this issue. One is to make an .iso file and image that to the USB
drive and make it bootable. This results in what is commonly called a live filesystem.
It can be booted and used , but any changes are lost on shutdown. There are ways of
adding permanence to a live filesystem, but they are complicated and limited, and do
not allow kernel updates.
The second way is to do the equivalent of a full linux install on the USB drive. This
allows it to operate just like a hard disk install with full permanence and updateability.
This document looks at implementing this second option.
1
2. BIOS-boot partition, no fileasystem, 1Mb bios_grub flag
3. LinuxRoot partition, ext4 , at least 20Gb, mount point /
4. Linux_swap partition, swap, 4GB
5. others as needed
The EFI_System partition should be first.
The –exclude option on rsync avoids copying psuedo filesystems that are populated at
boot time and any mounts, especially /mnt which is the USB drive partition copied to.
2
rsync - aAXvH -- exclude =' dev /* ' -- exclude =' proc /* ' -- exclude = ' sys /* '
-- exclude = ' tmp /* ' -- exclude = ' run /* ' -- exclude = ' mnt /* '
-- exclude = ' media /* ' -- exclude = ' lost + found ' -- exclude =' common /* '
/ media / nevj / Linuxroothome / / mnt
That should work in any shell. It does not matter whether the quotes are single or
double.
3
rm -r grub
rm -r efi
2.6 Use the booted USB drive Linux to configure grub on the USB
drive
Now that we have the USB drive copy of Linux booted, we can use it to do its own
grub configuration. That is easy
Edit /etc/default/grub, adding or modifying the line
GRUB_DISABLE_OS_PROBER=true
then simply
update-grub
4
The update-grub should find the Linux on the USB drive, but not find any other Lin-
uxes on the HDD. That is what we want - we want the USB drive and its grub to be
configured independently of the harddisk.
While there you can test that the swap space is mounted
swapon --show
Having its own swap space is part of making the USB drive independent
Test any other mounts, as required.
5
2.9 Test boot in UEFI mode
Reboot and set the BIOS to UEFI mode and choose the USB drive. The grub menu
belonging to the USB drive wil appear. Check out booting from this menu. Then the
acid test - boot the USB drive in another computer in UEFI mode. Mine works. I wish
you luck.
2.10 Acknowledgment
Feedback from Edgar Hoffman is appreciated.
References
[1] Emmanuel (2021) Persistent Live USB vs. Full Linux Install on a USB
Drive. URL https://www.fosslinux.com/49280/persistent-live-usb-vs-full-linux-
install-usb-drive.htm
[2] Matzigjkeit, Okuji, Watson, and Bennett (2021) The GNU GRUB Manual URL
https://www.gnu.org/software/grub/manual/grub/grub.html