Official website for Linux User & Developer
FOLLOW US ON:
Dec
7

Dual boot USB drive – tutorial

by Rob Zwetsloot

Want to carry around a multi-booting hard drive you can connect to any computer? Then this quick tutorial may just be for you

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.

Set-up your hard drive the right way with our guide
Set-up your hard drive the right way with our guide

Resources

A USB-powered external hard drive with at least 75 GB of space

Step-by-step

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

Step 2

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

Use:

$ 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.

  • Tell a Friend
  • Follow our Twitter to find out about all the latest Linux news, reviews, previews, interviews, features and a whole more.
    • Sharuzzaman Ahmat Raslan

      Which distro owns the GRUB? Ubuntu or Fedora? It looks like Ubuntu is the owner, and only Ubuntu must contain the grub package.

    • Pingback: Links 10/12/2013: Games, Applications, and Instructionals | Techrights

    • Michael DeGuzis

      “grub” is maintained by GNU and the Free Software Foundation and is not “owned” by Ubuntu, let along one single person. *facepalm*

    • Sharuzzaman Ahmat Raslan

      You misunderstood my question. There are 2 distro with GRUB package available. From the guide, it looks like Ubuntu is the one which do the modification to the MBR, and Fedora is only the secondary OS. So, which distro should “own” the GRUB configuration and maintenance? Ubuntu or Fedora? What happen if I update GRUB in Fedora? Will it modifies the GRUB config and ruined everything? This is because the way GRUB was package is different in Ubuntu and Fedora. This is not about GRUB owns by FSF. I know it is own by FSF.

    • Victor

      i wonder too if that tutorial can be used with any distro, i want a with manjaro and that i can add any other as i please. i had in mind trying deepin for a while now

    • Scott Allen

      Oh yea. USB’s with 75 GB space are cheap.