How to install Ubuntu on portable external Hard Drive?

338,747

Solution 1

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.

Solution 2

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.

Solution 3

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.

Solution 4

I don't think this is fully supported via Wubi, but it can be done. I'm not entirely sure of how you plan to use it.

In the past, I've unplugged my Windows device, plugged in my external device, and just run through the install using the external (and in many cases, the only) drive. Ubuntu will install correctly and treat that drive as "a drive" - nothing special being external.

Then, rather than dealing with dual-boot and GRUB, I can just use the BIOS/uEFI options to select my preferred boot device after I reconnect my Windows drive.

There are other ways of doing it, but I've found this to be the easiest, with the absolute minimal risk to my Windows systems.

Share:
338,747

Related videos on Youtube

Lexx Luxx
Author by

Lexx Luxx

Updated on September 18, 2022

Comments

  • Lexx Luxx
    Lexx Luxx almost 2 years

    OS: Windows 7. I want install Linux Ubuntu on portable external Hard Drive USB 2.0. I read a variety of methods, but I'm confused by contradictory advices and methods. Actually, installing Ubuntu on anything other than clean PC looks much more complicated than installing Windows. I need to have Ubuntu package + Python 2.7 + C compiler installed. My external hard drive is partially filled, I need to keep all files.

    Will Ubuntu run entirely on external hardrive, without writing anythinhg to Windows system folders and to registry?

    Can anyone post detailed guide how install Ubuntu on external hard drive?

  • Lexx Luxx
    Lexx Luxx about 10 years
    I dont want open laptop and remove hard drive.
  • Meninx - メネンックス
    Meninx - メネンックス over 7 years
    2016, Unetbootin, Universal and other syslinux type installers are not working with 14,04 and later persistent installs. Grub2 type installers that do work for persistent partitions on thumb drives do not seem to be working for USB hard drives, even with casper-rw files or partitions.
  • sudodus
    sudodus about 7 years
    mkusb, help.ubuntu.com/community/mkusb, can create a persistent live drive in USB hard drives and SSD drives in external boxes with USB or eSATA connections. But the original poster wanted to keep all current files in the target drive, and mkusb will overwrite the partition table and create a new one. So it would not be an option for this case unless those data are backed up to another drive and restored after the persistent live system is installed.
  • Communicative Algebra
    Communicative Algebra about 6 years
    The Ubuntu 18.04 installer broke grub on my internal hard drive even though I chose installation of the bootloader to the USB hard drive, as advised in these instructions. I needed to run boot repair to recover.
  • BruceWayne
    BruceWayne about 5 years
    If I purchase say a 64GB USB drive and do a full install of Ubuntu on to that, I assume: it will allow me to use the whole drive for storage, will be persistent, and I can use that on any PC to boot up to Ubuntu. Is that correct?
  • Meninx - メネンックス
    Meninx - メネンックス about 5 years
    @BruceWayne : Correct, the only thing a Persistent install can do that a Full install can't is install Ubuntu. I like to have a FAT32 or NTFS partition that can be used for data on a Windows or Linux computer. The file system partition (/) and home partition, (/home), are on a ext4 partition not visible to windows.
  • mchid
    mchid almost 5 years
    @CommunicativeAlgebra You can avoid this problem by disconnecting your internal drive before and during the installation process so that the installation of the bootloader can only go on the external drive.
  • Porcupine
    Porcupine about 4 years
    @mchid How can we disconnect internal drive before and during the installation process? Could you please explain it a bit.
  • mchid
    mchid about 4 years
    @Nikhil It really depends on what kind of computer you have. In all cases, you should be properly grounded when touching any internal computer part. For a tower computer, you just have to unplug the SATA cable from the drive before you do the installation. You can plug the SATA cable back into the drive sometime after installation. For a laptop, you have to unplug the drive from the computer. Then, plug it back in sometime after installation.
  • mchid
    mchid about 4 years
    @Nikhil If a laptop, disconnecting the drive may be more trouble than it is to use bootrepair to recover and it may be easier to use the bootrepair method instead of taking your laptop apart.
  • Conner Dassen
    Conner Dassen about 4 years
    After installing Ubuntu on my external SSD like this, even though the SSD is not plugged in, my laptop boots to a GRUB command line. Even with the SSD connected I am booted directly into a grub command line.
  • lewis
    lewis almost 4 years
    opening the laptop and disconnection the drive is the biggest downside, The process is the best way not to toast your windows install as all other ways using grub introduce conflicts. Using bios to boot works as it loads before windows and so no boot conflicts or windows damage. The drive do not see each other at boot and so no need of grub except on external disk and it only loads when that disk is selected for boot. probably not what I want to do on my new windows machine though as i break warranty by fussing with internal hardware to disconnect internal drive temporarily.
  • Akeo
    Akeo over 3 years
    C.S.Cameron, can you please update the Rufus link to the latest version? The latest is 3.13, not 3.11, and releases 3.12 and 3.13 actually contain important bugfixes related to Ubuntu. Preferably, you may want to point to rufus.ie, as it always contains a link to the latest download as well as localized information about Rufus that OP might be interested in. Or, if you want to point to GitHub, please use github.com/pbatard/rufus/releases as it avoids linking to a version that may be obsolete. Thanks!
  • Meninx - メネンックス
    Meninx - メネンックス over 3 years
    @Akeo: Yes you are right, besides it is probably better not to have the download link pop right up. People prefer to see what they are downloading. Thanks.
  • Akeo
    Akeo over 3 years
    Much appreciated. Thanks! (PS: For some reason, whenever I try to @ your name, it gets deleted. Weird...)
  • Meninx - メネンックス
    Meninx - メネンックス over 3 years
    @Akeo: I think that is because I wrote the answer and every comment made to it goes to me without an "@". same with comments to questions.