How to install Ubuntu on portable external Hard Drive?

A very detailed answer would be beyond the scope of a single question, but here's the general outline. It's very easy, but success will partly depend on the ability of your computer to boot from an external hard drive. This depends on the bios.

Before starting, make sure your bios has an option to boot from a USB HD.

If all you need is the basic install, Python 2.7, and the C compiler, you can get away with installing Ubuntu to a fairly small partition. I forget the literal minimum Ubuntu needs to install, but it's roughly 8 GB. I would recommend 10 GB as a minimum, plus another 2-4 GB if you want a swap drive.

Create space for a partition

It's best in your case to create the new partition before doing the install. You will need to shrink the existing partition on your external hard drive first.

I would recommend backing up the USB HD; but if you had a second one, you could just install to that one. Depending on how full the drive is, you may not be able to back it completely; but try at least back up any important files. This is just a general warning and precaution since your data should be safe.

You have two options to shrink the existing partition:

  1. Use the Windows partition manager in administrative tools. I believe these are available in Home Premium. If the partition won't shrink by enough, you may need to delete files to make room. If you have more than enough available but it still doesn't shrink enough, use a free defrag tool like MyDefrag to defrag and move the files to the start of the partition.

  2. Use gparted from the Ubuntu live install media. This is probably the easier way to do it.

Create a new partition

Create the Ubuntu live installation media and use it to boot your computer. Choose Try Ubuntu.

Plug in the external hard drive. Start the program gparted. If you have not already shrunk the partition on the external HD, do it now.

In most cases, the internal HD will show up as sda and the external as sdb, but this is not guaranteed. Be sure you are looking at the correct HD in gparted.

Shrinking the partition will leave unallocated space. Use this to create a new partition. Format it to ext4. Jot down the partition number. This will be used for /.

You don't need a swap partition, but if want one, shrink the new partition by the size you want (or just make it a little smaller in the first place). Format that space to linux-swap.

Note down the numbers of the new partitions.

Run the Installer

Start the installer from the icon on the desktop or on the launcher. When asked how you want to install, choose: Somethine Else.

This will start the partitioner within the installer. This is different than gparted and may look a little intimidating to a beginner.

Carefully highlight the new partition (check the number and drive carefully) and click Change.

Follow the dialogs to a. Use the partition as ext4, b. mount to /, and c. format.

Highlight the swap partition and click Change. Choose use a linux-swap and that's all for that one.

Very important: change the installation of the bootloader to the USB HD. This will most likely be /dev/sdb. This will prevent you from overwriting the master boot record on your hard drive. (If you do this by accident, it's easily fixed).

Double-check your partition choices, then click Install Now.


That's it. To run Ubuntu, boot the computer with the USB plugged in. Set your bios order or otherwise move USB HD to the first boot position. The boot menu on the usb will show you both Ubuntu (on the external drive) and Windows (on the internal drive). Choose the one you want. If you boot without the usb, you will boot into Windows normally.

Ubuntu has Python 2.7 installed by default. To install the C comiler, open the terminal, any run:

sudo apt-get install gcc

or

sudo apt-get install build-essential

(if you want some additional programs helpful for C programming).


To run Ubuntu in a virtual machine instead, install VirtualBox or VMWarePlayer in Windows. Both are free. Create a new VM and use the installer media to install to the VM. But this time, don't worry about partitions. Choose Install Ubuntu to the entire virtual drive. This doesn't affect the rest of the hard drive.

If you want to put the VM on the external hd, be sure to override the default location when creating the VM and put it on a folder on the external drive.

Creating your installation media with persistence through a Windows program like LiveUSBCreator will also work, but this option will be very slow.


Ubuntu can, and does, run well entirely from an external hard drive. I have used Ubuntu this way for years. It doesn't affect Windows. There's nothing special about installing to USB drives. You connect the USB drive, boot using a CD or an pen drive, and choose the external disk when it comes to selecting the installation location.

However:

You will have partition the external hard disk. I assume your external disk has a single partition with an NTFS filesystem. The best thing to do is shrink this partition by about 20 GB (which is more than enough for Ubuntu) and create new partitions there. This is not as difficult as it sounds (and you'd have to worry about partitions if you wanted to install another copy of Windows too).

Either use Windows' Disk Management tool to shrink the partition, or use GParted from the Ubuntu Live mode. Using the former is quicker, but limits you to whatever space is available after the last used sector in the partition (which can be very low, even if you have plenty of free space). Using the second can be very slow, especially if the partition is large, but lets you extract most of the free space.

In either case, after you get the free space, use GParted to create an extended partition there and within that extended partition, an ext4 partition. Install Ubuntu to this partition. Choose your external hard disk as the device for GRUB (bootloader) installation as well.

Alternative:

If you have a pendrive handy, use UNetBootin or Universal USB Installer or some such tool to create a bootable Ubuntu drive with persistence. If persistence is enabled, your settings and other changes to Ubuntu that you make when in Live mode don't vanish when you restart. It's ideal for low usage scenarios. You can install Python or anything else and get comfortable with Ubuntu, and then, whenever you feel ready, install Ubuntu. Note that changes made in the live mode do not affect any installation you make with it.


Full Install to USB

Full installs are more stable and secure than persistent installs, but not as quick to make. They are better at utilizing disk space as no fixed size casper-rw file or partition is required. They are not very good for use of installing Ubuntu.

Following is a step by step how to install 18.04 on a 16GB flash drive with options for separate Home partition and Windows compatible data partition, install to mechanical external drive is similar:

  • Create a live USB or DVD using SDC, UNetbootin, mkusb, etc.
  • Turn off and unplug the computer. (See note at bottom)
  • Unplug the power cable from the hard drive or unplug the hard drive from the laptop.
  • Plug the computer back in.
  • Insert the flash drive.
  • Insert the Live USB or Live DVD.
  • Start the computer, the USB/DVD should boot.
  • Select language.
  • Select install Ubuntu.
  • Select Keyboard layout
  • Select "Continue".
  • Select installation type and "Download updates while installing Ubuntu" and Select "Install third-party software ...", (optional).
  • Select "Continue".
  • At "Installation type" select "Something else". (Full disk encryption is now working with flash drives).
  • Select "Continue".
  • Confirm target device is correct.
  • Select "New Partition Table".
  • Click Continue on the drop down.

(Optional FAT32 data partition for use on Windows machine)

  • Click "Free space" and "+".
  • Make "Size..." about 2000 MB.
  • Select "Primary".
  • Location = "Beginning of this space".
  • "Use as:" = "FAT32 file system".
  • "Mount point" = "/windows".
  • Select "OK"

(Non Optional Root Partition)

  • Click "free space" and then "+".
  • Select "Primary", "Size ..." = 4500 to 6000 MB, "Beginning of this space", Ext4, and Mount point = "/" then OK.

(Optional home partition)

  • Click "free space" and then "+".
  • Select "Primary", "New partition size ..." = 1000 to 6000 MB, Beginning of this space, Ext2, and Mount point = "/home" then OK.

(Optional swap partition, allows hibernation and frees up memory when RAM is full)

  • Click "free space" and then "+".
  • Select "Primary", "New partition size ..." = remaining space, (1000 to 2000 megabytes, or same size as RAM), Beginning of this space and "Use as" = "swap area" then OK.

(Important)

  • Confirm "Device for boot loader installation" points to the root of the USB drive. Default should be OK if HDD was unplugged.
  • Click "Install Now".

  • Select your location.

  • Select "Continue".
  • Insert your name, computer name, username, password and select if you want to log in automatically or require a password.cscameron
  • Select "Continue".
  • Wait until install is complete.
  • Turn off computer and plug in the HDD.
  • Replace the computer's cover.

Note: You may omit disabling the hard drive if after partitioning you choose to install grub to the root of the USB drive you are installing Ubuntu to, (ie sdb not sdb1). Be cautious, many people have overwritten the HDD MBR as default location for boot loader is sda, any items in the internal drive's grub will be added to the USB's grub. You may do an update-grub later.