Partner links

Tips for installing a Linux distribution on an external hard drive

Linux

Installing a Linux distribution on an external hard drive should be easy and once installed, you should have no problem booting it from any computer. However, things are not always as trouble-free as they should be.

If you installed the Linux distribution on an MBR partitioning scheme and correctly configured the installer to install GRUB (the bootloader) in the Master Boot Record of the external hard drive, chances are it will boot from any computer, not just the one it was originally installed from.

However, if you installed the system on a GPT partitioning scheme, with an EFI Boot Partition, it will likely not boot from another computer. And that’s because the installer will most likely install the bootloader files where it thinks they should be installed (in the EFI Boot Partition of the internal hard drive), not where you specified (the EFI Boot Partition of the external hard drive).

For such a system to boot from any computer, you’ll have to modify the /etc/fstab file. If you’re new to Linux and have no idea what MBR and GPT means, read Guide to disks and disk partitions in Linux.

The /etc/fstab (fstab is for filesystems table) provides information about a system’s disk partitions and other data sources. It is automatically generated during the installation process and can be modified manually. Below is a sample fstab file taken from an installation of Ubuntu 15.04 on an external hard drive. Installation was on an MBR partitioning scheme.

During installation, the external hard drive was the third one detected. That’s why it’s /dev/sdc. The internal hard drive was /dev/sda, the first hard drive detected. And so in this sample fstab file, all references are to /dev/sdc, except /dev/sda9, the swap partition of the internal hard drive. If you have an fstab file like this one, it is save to delete a reference to the swap partition of the internal hard drive, because it’s not needed.

# /etc/fstab: static file system information.
#
#                                           
# / was on /dev/sdc1 during installation
UUID=a0987f87-8735-4573-a73f-770df53dd464   /             ext4    errors=remount-ro  0       1

# /home was on /dev/sdc5 during installation
UUID=c0351972-8d99-4a0a-8939-8b365f1aeaab   /home         ext4    defaults           0       2

# swap was on /dev/sda9 during installation
UUID=40794eb1-c16a-4e55-afa8-cc238f0c9f97   none          swap    sw                 0       0

# swap was on /dev/sdc6 during installation
UUID=ee62dfbf-0e94-4c46-9ed0-0815b62a52de   none          swap    sw                 0       0

The next fstab file is from an installation on an external hard drive on a GPT partitioning scheme and with an EFI Boot Partition. As with the example above, the internal hard drive was /dev/sda, while the external was /dev/sdc. The key difference between this and the other one is that the bootloader files were installed in /dev/sda2, the EFI Boot Partition of the internal hard drive.

That’s why such a system will not boot from a computer other than the one it was connected to during installation. To make the system globally bootable, you’ll have to modify the reference to /boot/efi to point to the EFI Boot Partition of the external hard drive. That involves finding the UUID of that partition. No, you do not have to generate a new one. Just find the original UUID.

# /etc/fstab: static file system information.
#
#
#                                         

# / was on /dev/sdc7 during installation
UUID=777438ba-43c8-4890-bd3b-a78564f5be82    /             ext4    errors=remount-ro 0       1

# /boot/efi was on /dev/sda2 during installation
UUID=20A5-CC5C                              /boot/efi      vfat    umask=0077      0         1

# /home was on /dev/sdc8 during installation
UUID=e137ea18-e4cd-4cc8-8987-ec414ca249a2   /home          ext4    defaults        0        2

# swap was on /dev/sdc9 during installation
UUID=40794eb1-c16a-4e55-afa8-cc238f0c9f97   none           swap    sw              0        0

So how do you find the original UUID of the EFI Boot Partition of the external hard drive. On most Linux distributions (maybe all of them), you’ll find the UUID of partitions in /dev/disk/by-uuid. Here, for example, is a sanitized listing of those in an installation of Linux Mint 17.2. Note that when looking for the original UUID, you should be doing so from the computer the external drive was connected to while it was being installed.

Once you locate the UUID, modify the entry that points to the UUID of the /boot/efi line in fstab to match.

total 0
lrwxrwxrwx 1 root root 10 043A5D033A5CF2E2 -> ../../sda4
lrwxrwxrwx 1 root root 10 0632A4AC32A4A263 -> ../../sda1
lrwxrwxrwx 1 root root 10 20A5-CC5C -> ../../sda2
lrwxrwxrwx 1 root root 10 2E4A57624A57263D -> ../../sda5
lrwxrwxrwx 1 root root 10 40794eb1-c16a-4e55-afa8-cc238f0c9f97 -> ../../sda9
lrwxrwxrwx 1 root root 10 410ea9d1-983e-4359-9fa2-ced3ade90d9e -> ../../sdb6
lrwxrwxrwx 1 root root 10 468486a8-d0f8-49bf-ba95-3fd3df39db5a -> ../../sdb1
lrwxrwxrwx 1 root root 10 5E7E1DD77E1DA933 -> ../../sda6
lrwxrwxrwx 1 root root 10 777438ba-43c8-4890-bd3b-a78564f5be82 -> ../../sda7
lrwxrwxrwx 1 root root 10 cbd3021a-1d3c-470b-9a1e-b161c878e9eb -> ../../sdb5
lrwxrwxrwx 1 root root 10 e137ea18-e4cd-4cc8-8987-ec414ca249a2 -> ../../sda8

Another point to note when you’re attempting to install a Linux distribution on an external drive: Use the appropriate version of the installer. For example, if you intend to install the system on a GPT partitioning scheme with an EFI Boot Partition, use the UEFI-aware version, and the non-UEFI version, if you intend to install it using an MBR partitioning scheme.

To make sure that you use the appropriate version of the installer, access the computer’s boot menu and look for entries for the installation DVD or USB stick. Booting from the one starting with UEFI: will boot the UEFI version of the installer, while booting from the one starting with USB will boot the standard version of the installer. In Figure 1, the last two entries for the installation USB stick.

Which method do I recommend for installing a Linux distribution on an external drive? Use the MBR partitioning scheme, so you don’t have to deal with the EFI Boot Partition mess.

Computer boot menu

Figure 1: Entries in the boot menu of target computer

Share:

Facebook
Twitter
Pinterest
LinkedIn

Partner links

Newsletter: Subscribe for updates

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Get the latest

On social media

Security distros

Hacker
Linux distros for hacking and pentesting

Crypto mining OS

Bitcoin
Distros for mining bitcoin and other cryptocurrencies

Crypto hardware

MSI GeForce GTX 1070
Installing Nvidia GTX 1070 GPU drivers on Ubuntu

Disk guide

LVM
Beginner's guide to disks & disk partitions in Linux

Bash guide

Bash shell terminal
How to set the PATH variable in Bash
Categories
Archives
0
Hya, what do you think? Please comment.x
()
x