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:

Share on facebook
Facebook
Share on twitter
Twitter
Share on pinterest
Pinterest
Share on linkedin
LinkedIn

Hola! Did you notice that LinuxBSDos.com no longer run network ads?  Yep, no more ads from the usual suspects that track and annoy you across the Internet. But since I still need to pay to keep the site running, feel free to make a small donation by PayPal or your favorite cryptocurrency.

  • Bitcoin
  • Ethereum
  • Xrp
  • Bitcoin cash
  • Bitcoin sv
  • Litecoin
  • Binance coin
  • Cardano
  • Ethereum classic
Scan to Donate Bitcoin to bc1qzvlte2m224zkayhdc7fdfjkp2rsgt0l5a496ua

Donate Bitcoin to this address

Scan the QR code or copy the address below into your wallet to send some Bitcoin

Scan to Donate Ethereum to 0x0F4362DFF77F3Ba0Dc637F5f3Eba35D09a2fA60C

Donate Ethereum to this address

Scan the QR code or copy the address below into your wallet to send some Ethereum

Scan to Donate Xrp to r4ggjvL36njsMCYTkJ3S7cTHscPsMsSGQv

Donate Xrp to this address

Scan the QR code or copy the address below into your wallet to send some Xrp

Scan to Donate Bitcoin cash to qrs0dedzp9t55af3nfwypydghp29r0xguy9s20fz2k

Donate Bitcoin cash to this address

Scan the QR code or copy the address below into your wallet to send some Bitcoin cash

Scan to Donate Bitcoin sv to 15K9TLyVDBtLuG9cYvXCX9SSkq9C9oUKHK

Donate Bitcoin sv to this address

Scan the QR code or copy the address below into your wallet to send some Bitcoin sv

Scan to Donate Litecoin to LetJ9QQMb7u2LMZ9Tu6rtHwcBcQFW98fbG

Donate Litecoin to this address

Scan the QR code or copy the address below into your wallet to send some Litecoin

Scan to Donate Binance coin to bnb1ga8trq08ssqepd90v6225nzfgy448pu5pw8gxp

Donate Binance coin to this address

Scan the QR code or copy the address below into your wallet to send some Binance coin

Scan to Donate Cardano to addr1qx2354yw49etstfljpdhwja3ajjlt487lg95vu9ngy2q6vu4rf2ga2tjhqknlyzmwa9mrm997h20a7stgectxsg5p5esq5l7d9

Donate Cardano to this address

Scan the QR code or copy the address below into your wallet to send some Cardano

Scan to Donate Ethereum classic to 0xcD6CC972a2297FcafACDcfE042C55C69516a9264

Donate Ethereum classic to this address

Scan the QR code or copy the address below into your wallet to send some Ethereum classic

Subscribe for updates. Trust me, no spam!

Sponsored links

1. Attend Algorithm Conference, a top AI and ML event.
2. Reasons to use control panel for your server.
3. DHgate Computers Electronics, Cell Phones & more.

Upcoming events

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest

On social media
Via my newsletter

Partner links

1. Attend Algorithm Conference, a top AI and ML event for 2021.
2. Reasons to use control panel for your server.
3. DHgate Computers Electronics, Cell Phones & more.
Hacking, pentesting distributions

Linux Distributions for Hacking

Experts use these Linux distributions for hacking, digital forensics, and pentesting.

Categories
Archives

The authors of these books are confirmed to speak during

Algorithm Conference

T-minus AI

Author was the first chairperson of AI for the U.S. Air Force.

The case for killer robots

Author is the Director of the Center for Natural and Artificial Intelligence.

Why greatness cannot be planned

Author works on AI safety as a Senior Research Scientist at Uber AI Labs.