Carrying around a USB stick with a pre-loaded live distro is very useful. It can either be used as an emergency distro for a PC experiencing some troubles, diagnosis tools, a portable distro for yourself and much more. However, when it comes to using it as a portable distro, there are some limitations. Not all live distros allow you to install extra software permanently, and even then they may have a limited repository of software that can be installed in a live environment.
This isn’t a problem if you have enough storage space though, such as the kind you get on a portable, USB-powered external hard drive. You can install distros to them similarly to how you’d install to a normal hard drive, however there are some changes you’ll need to make if you plan to dual boot from this hard drive on any machine.
We’ll guide you through how to partition, install and run two distros from an external hard drive, and what best practices you should employ. We’ll use Fedora and Ubuntu in our assumptions, as they are two of the most common distros and derivatives.
A USB-powered external hard drive with at least 75 GB of space
Step 1 Swap partition
In our example, we’ll start with Ubuntu. Plug in the USB Drive, and boot into Ubuntu. Make sure you’ve saved any important data on the external drive. The first thing you’ll need to do is create a swap partition – make it 4 GB in size so that it can make the most out of more powerful systems. Put it towards the end of the hard drive
You can create some shared space for both distros to use, either independantly or as a shared home directory if you’re feeling a bit more brave. We want to save 10-15 GB for each distro, so keep that in mind while creating it. Use ext3 or ext4 as the filesystem, or NTFS if you want it to be cross-platform.
Step 3 Ubuntu Root
Now create the 10-15 GB space you’ll want for Ubuntu, and set it to be root by selecting / in the menu. It will automatically mount the swap the partition we created when booting into Ubuntu or Fedora in the future. Carry on with the installation instructions.
Step 4 Fedora Root
Put in the Fedora disc with the USB hard drive still plugged in, and boot up. Choose the external drive from the list of discs Installation Destination, create a custom partition in the space remaining as ext3 or 4, and set the mount point to /. Install as normal.
Step 5 GRUB Reinstall
Boot back into the Ubuntu Live Disc, and make a note of what fdisk -l labels the Ubuntu boot partition on the external drive as. Mount it with:
$ sudo mount /dev/sdXY /mnt
And then reinstall GRUB 2 from Ubuntu with:
$ sudo grub-install –root-directory=/mnt/ /dev/sda
Step 6 GRUB Update
After rebooting, you’ll be able to get back into Ubuntu on the external drive. Once there, mount the Fedora partition however you wish, and run:
$ sudo update-grub
It will automatically detect the Fedora install, and update the boot menu next time you boot from the hard drive
Step 7 Find fstab
$ ls -l /dev/disk/by-uuid
…to find out the UUID of the partition for your shared storage on the hard drive. This should be called the same on both Ubuntu and Fedora. Go to the terminal, and open fstab with your favourite text editor like so:
$ sudo nano /etc/fstab
Step 8 Use fstab
You’ll need to add a new entry so that your shared space mounts every time you boot into one of the external drive distros. Enter into both fstabs something like:
UUID=XXXXX [mount point] ext4 errors=remount-ro 0 2
You can change ext4 to whatever other filesystem you used.
Step 9 Go Portable
You should now be fully set-up to take your portable Linux distros everywhere, with a shared space between them, and the ability to boot between either of them without having to guess which partition is which.