Move an installed Linux to a bootable USB drive

I recently had a lot of spare time waiting for our internet connection to recover from floods. I needed a method of preserving Linux distros that I had installed to HD and then finished with. Clearly a backup would do, but I wanted easier access than that, so I looked into making bootable USB flash drives, with a full copy of an installed Linux.

It is actually quite easy - easier than making a live distro - and you dont need any special tools. Here briefly are the steps

  1. Prepare partitons on the USB drive
  2. transfer a copy of the Linux from HDD to a root partition on the USB drive. I just used rsync. You dont need any fancy imaging tools.
  3. Mount the new rootfilesystem on USB and fix /etc/fstab so its UUID’s point to the USB drive partitions
  4. Use a Linux on HD to install grub on the USB drive
  5. Boot the USB drive and get a grub> command prompt
  6. Use grub commands to boot the USB copy of Linux
  7. Log into the booted USB Linux and configure grub
  8. Reboot the USB drive and get a grub menu for the USB drive only
  9. Final test, move the USB drive to another computer and boot it there. It should boot, independently of the computer environment.

That is very brief. If anyone is interested, the details are here

https://github.com/nevillejackson/Unix/blob/main/grub/makeusb.pdf

Note: When viewing pdf on github, you need to click the download button, it will not display automatically.

I am not finished - have only done legacy boot. Should be able to make USB bootable in either legacy or UEFI or both.

Thanks to @Deby and @Fast.Edi for suggestions

Neville

7 Likes

Thanks Neville,
Good Information :slight_smile:

2 Likes

Hi.
Thanks for writing this howto.
I took the liberty to translate it to German, so me and my fellows of the Community can test this on our next meeting.
I hope this is OK with you?

Greetings

2 Likes

Wow, great job. I do the occassional translation, too.

1 Like

Yes of course it is OK. It is a public document.
I had a brief read … I did 5 years of German at school, but I am very rusty. It brought back memories. Did you translate it by hand? Did you use the .tex file from github?

If your friends test it, they will undoubtedly find some cases that do not work. One that has occurred to me is that some people use a separate /boot partition. It does not cover that.
If you find issues let me know. We can upgrade the document.

Still working on uefi boot
Regards
Neville

Can you see any oversights? I dont want to mislead or confuse… it is a difficult enough issue without me adding to the mystery.

I must have read about 20 howto docs and in the end the only useful one was the GNU Grub manual. I dont want to become No 21.

Cheers
Neville

PS translation is ambiguous

Hello Neville,

Great job! Thank you. If you simply want to do a backup, using gparted and a large hard drive is simpler and less expensive. The sweet spot price-wise is now 4 TB 3.5" hard drives (Seagate or WD). For easy access, you can multi-boot the hard drive using GRUB. I have Debian, Star, Q4OS and Mageia installed on 120 GB SSD. An extended partition with logical volumes are necessary, since only 4 primary partitions can be created on 1 physical hard drive.

Cheers,
Deby.

1 Like

You must be using an MBR partition table.
A GPT partition table would permit up to 128 partitions.
Beware, if you try to use gparted to convert a disk to GPT partition table, you will lose your files.

Have never used gparted to do a backup, but yes, it will do a copy of a partition. Must try it.

Cheers
Neville

1 Like

Yes, it is MBR partition table with legacy (no UEFI) boot. I don’t feel like reinstalling everything now, but I found a cheap Jasper Lake Intel Celeron N5095 mini PC on Aliexpress, which I plan to buy and use GPT and UEFI boot.

Cheers

You can use GPT with legacy boot or with uefi.
When you do it make the EFI System partition the very first partition
and
put a small (1Mb) bios-boot partition on there too, just in case you want to use legacy boot
You can actually put 2 copies of grub on a GPT disk, one in the EFI partition and one in the bios-grub partition. Then it will boot with either legacy or uefi. Both grubs would share the same configuration files. I am experimenting with this at the moment.

Cheers
Neville
PS Looked at Aliexpress. Seems a good buy. I bought a secondhand Dell with similar specs and about same price. Check it has ports you need, mine had no builtin wireless.

I want to use only UEFI boot in my new system with GPT table on SSD. The mini PC I plan to buy is a barebone (case, power adapter, motherboard and CPU soldered to the motherboard). The barebone always shipped without RAM, SSD and WiFi adapter. I use Ethernet, so no need for wireless and already have an SSD and DDR4 SODIMM RAM. Barebone is always a better deal since the sellers always overcharge for RAM and SSD. Here are even cheaper mini PCs that use an older and less powerful Apollo Lake CPU N3350, but also include LPDDR3 4GB RAM + 64GB eMMC + 2.4GHz & 5GHz dual band WiFi + Licensed Windows 10.

N3350 is a 6 Watt Mobile CPU, which includes integrated Intel HD Graphics 500 and powerful enough for Internet, office and multimedia - HTPC.

Thanks.

Ah, nice. Hope you could read it so far. Everything I translate (usually howtos or such) I translate 99% by hand. In some occasions, especially when it’s a “tricky” part with lots of nested sentences I use deepl. I mostly try to remove the complexity (in technical texts) by breaking it down to simple sentences, but keeping the original meaning (of corse). That’s not easy sometimes… :wink:

Sure thing…

@nevj
Hi @nevj
I understand spare time, and playing with Linux!!! I have ran multiple Linux, and more Distros,
than I can remember, but I fail to see the logic in having multiple booting Distros, although
I do want to run “Kali”, just not sure on where and how to do the install.
You keep up the good works with Linux.

Hi Dave, Yes I will keep having fun.
I looked into usb drives because I wanted a way to archive an installed linux ie get rid of it off my machine, but have it accessible if I wanted to refer to it.

There are advantages of multiple linux installs.
If one crashes, I can use the other to rescue it.
Sometimes a package will run in one distro, but not in another eg julia has a problem in void linux at the moment.
It broadens my experience. I want to see where to go next
I enjoy the variety too.

Cheers
Neville

PS
You might like to look at this

https://github.com/nevillejackson/Unix/blob/main/mxkde/mxkde.pdf

Note github is not like a website, you have to press the download button to get the file

1 Like

You could try Kali on a USB drive. If you do that, use a full linux install rather than a live filesystem. Then you can save changes, just like an install on HD.
Just use the normal install meduim but tell the installer to put it on the USB drive, then the installer should put grub on the usb drive for you.
Partition the usb drive before you start, that is easier… get rid of the fat32 and make normal linux partitions and filesystems.

Sounds like fun
Neville

Well it is not too difficult reading my own composition… I can interpolate where the vocab beats me. I am not really fluent enough to tell if you got the meaning right. It is a very subtle thing.

Lets see what feedback you get. We might be able to get together on this

Neville

@nevj
I was thinking about a Kali install on a small 120GB SSD.

That would be super good

The document

https://github.com/nevillejackson/Unix/blob/main/grub/makeusb.pdf

Had some oversights and has undergone an upgrade.
If anyone is trying to follow the procedure outlined in this document it would be a good idea to download the upgraded copy.
There can be issues if your shell is not bash
The joint UEFI/Legacy boot now works, there is a section on UEFI in the upgraded copy.
Thanks to @Fast.Edi for feedback
Apologies for any inconvenience
Neville

1 Like

Is there a reason that you can’t dd the whole thing onto a larger usb stick?