This post shows how to clone an installed Linux to your USB disk so you can use it every where in every computer that supports UEFI/GPT.
- An installed Linux to be cloned
- A helper Linux (could be a LiveCD or a real system)
- An external disk with GPT partition table
/dev/sdais the disk containing the installed Linux that will be cloned later
/dev/sdbis the external disk
/mnt/sdais the mount point of
/mnt/sdbis the mount point of
# Boot into your helper Linux
If you are using a LiveCD Linux, you make a bootable USB with that LiveCD image and then boot your computer from the USB.
If you are using a real system, make sure you are not booting into the one that will be cloned later.
The best choice is always using a Virtual Machine 😃
# Partition your external disk
You can use
gparted or what ever you want
to partition your disk. You should learn how to use these partition tools by Googling.
I will assume that you have the following partition after all successful operation. note that: the EFI partition is essential because we are using UEFI/GPT
/dev/sdb1is the EFI partition.
/dev/sdb2is the Linux root partition.
/dev/sdb3is the data partition for containing non-system files (such as your shared documents and movies).
# Copying root filesystem files
Assume that we have the following structure of
Let's do the following steps:
There's no need to mount the efi partition in
/dev/sda1 as we
will re-install grub later which will re-generate all boot files.
Then copy all files under
sudo cp -a /mnt/sda/* /mnt/sdb
Don't forget to add the
-a option, that is, keep all files' attributes (ownership, timestamp, etc.)
I don't want to use a home partition so I just merged the root and home in
If you would like to use a home partition, you should create a separate home partition
/dev/sdb and mount it to
/mnt/sdb/home before copying files.
# Installing grub
And let grub to perform the installation:
sudo grub-install --target x86_64-efi --removable --boot-directory=/mnt/sdb/boot --efi-directory=/mnt/sdb/boot/efi
Now we are preparaing to
chroot into the root and generate grub config. But first
we should mount 3 fundamental virtual filesystems:
sudo mount --bind /dev /mnt/sdb/dev sudo mount --bind /sys /mnt/sdb/sys sudo mount --bind /proc /mnt/sdb/proc
And next step is generating grub config file. Please note that we should disable the
os-probe feature because a Linux To Go should never discover and boot into systems
that installed on the host's disk.
chroot /mnt/sdb chmod -x /etc/grub.d/30_os-prober grub-mkconfig -o /boot/grub/grub.cfg
Do not use
update-grub as it will modify UEFI boot items.
/etc/fstab is corrupted as it is copied from an old disk
whose UUID does not match the one now.
You can use
blkid to see the UUID of
And we should only mount
/boot/efi when system starts, so
/etc/fstab like this:
UUID=530190fb-9486-429b-8aea-ff80a27aaa4f / ext4 errors=remount-ro 0 1 UUID=6E98-B9EE /boot/efi vfat defaults 0 2
6E98-B9EE should be your
# Clean up
It's time to unmount all things and have a reboot.
sudo umount -a /mnt/sda sudo umount -a /mnt/sdb
Power off your machine and boot from your external disk.
You should see your Linux logo or
dmesg now on your screen.
# Frequently Asked Questions
If grub says
grub-install: error: /usr/lib/grub/x86_64-efi/modinfo.sh doesn't exist. Please specify --target or --directory
That's because your helper Linux is installed with BIOS/MBR. You can run the following command to install required files:
sudo apt install grub2-efi-modules