Thursday, March 17, 2011

Install Linux on an external USB Hard Drive

In my recent OpenSUSE 11.4 REVIEW, I briefly mentioned that I install Linux distros on external USB drives. I received some feedback from people who wanted to know more about this, so I decided to put together a quick tutorial to show how I do it. First off, let me explain a little bit what the goal is here, and what benefits may come from it.

When you test as many distros as I do, you either have a huge array of testing machines (which would be ideal, but way too expensive), a huge Hard Drive and tons of patience to deal with Virtual Machines, or you simply buy some external USB hard drives and get on with it. In my case, I want to be able to test stuff or install many flavors of Linux with flexibility, but hopefully not spending a fortune, so installing on USBs is the way to go for me.

I think that testing on a VM is a pain for many reasons:

  • Managing virtual drives is painstakingly slow.
  • Creating and removing virtual drives like crazy is not good for file system health, certainly not a good way to keep the hard drive defragmented.
  • Most distros I have tried require extra drivers to be able to correctly configure my monitor and other pieces of hardware.
  • If things go wrong, you are never 100% sure if it is something in the VM that is causing that error.
  • More importantly, VMs are great to get at quick look at a distro, but not for reviews. More specifically, if you are interested in finding how that specific distro does in terms of hardware management, VMs just don't cut it.

Installing on an external USB drive, specially if that drive has good throughput (fast read/write speed), is as close as it gets to installing on an internal drive. Sure, USB drives and buses are slower, but buying the right one can get you pretty close to real life responsiveness. Unfortunately, USB drives with fast input/output are the most expensive ones... Oh, well, nothing is truly perfect.

Another great thing about installing on a USB drive is that you can turn a single PC into many. In other words, if you have one PC and want to use several different OS, either you partition your drive, with the risks and limitations involved in doing so, or you stick to a single OS, which is what most people do. Installing different OS on different USB drives allows users to experience truly different OS on the same machine.

This approach is also great to introduce people to Linux progressively. Instead of trying to get rid of their current Windows installation (not recommended), you can simply give away a USB drive with an installation of your favorite distro. That way, they can go back to Windows whenever they need to and learn Linux at their own pace. Needless to say, this eliminates potential frustration in the long run, but also risks of losing personal data/settings when moving from Windows to Linux.

Similarly, if you travel with your company PC, chances are you are stuck in an airport or a hotel with a corporate build. You cannot install the applications you want, anything personal is a no go and performance is crazy slow due to trillions of security policies nobody understands. Guess what? You can plug in your Linux USB drive and use that same hardware to run your own distro of choice, which does exactly what you want it to do, how you want it to do it. Oh, yes, and it modifies absolutely nothing on the company Hard Drive, so you won't get into trouble.

These are just examples of a few applications I have noticed so far, but I am sure you will put it in use for your own wicked ends. Alright, let's see how this simple but neat trick goes about.

IMPORTANT NOTE: While the steps that follow are simple and represent very low risk, they could result in permanent hardware damage if you don't know what you are doing. Use this tutorial at your own risk!


Meet my HP NX7400 Notebook, my main distro testing workhorse. Yes, it is old, heavy and ugly, but it is as Linux friendly as it gets. I consider it a perfect starting point for installations because hardware support in Linux is sometimes a bit elusive, so I think it's always smart to stick to devices you know and trust. Getting the last thing in the market is not necessarily a good idea, and you can end up banging your head against the wall when you don't get past GRUB.

Now, for the purpose of this tutorial, let's say that step 1 is removing the laptop battery, as shown below. This is extremely simple, just turn your laptop upside down and find how it works (usually just a matter of sliding a couple parts to get it out).

The main reason behind removing the battery is that we want to make sure we lower the risks of static electricity screwing up our hardware. If you are doing this on a desktop, make sure you unplug your PC before you try to disconnect your internal hard drive.

Once the battery is out, it's time to remove the hard drive cover and extract the hard drive, as shown below. A small screwdriver often comes in handy for this task. When you are done, put your hard drive inside an anti-static bag and away from any magnetic source (stereo speakers, for instance). Now, put the cover back in place and restore the battery to its original position. Even with the battery on, I recommend running installations with AC power on, just because most installation wizards don't give you any clue about your battery charge levels. An installation broken due to power loss is most probably a corrupt one.

Your computer lacks any boot media now, so it's time to insert your LiveCD/DVD/USB and boot from it. This may require a bit of BIOS tweaking to modify the boot order. I personally like to keep USB first, then optical drives. If you are not using any other boot source, configure your internal hard drive to be third in the chain.

In my experience, LiveUSBs and the tools to build them up are still anything but reliable, so I always like to keep a few RW-DVDs around. More and more distros are leaning towards LiveDVDs so they don't need to deal with space limitations in CDs, which is another reason why RW-DVDs are the way to go. After all, a DVD can accomodate both a LiveCD and LiveDVD ISO. Last but not least, the RW bit is important, because (assuming you have a RW-DVD burner) you can reuse a single DVD many times, thus saving time and money.

Now, boot from your LiveDVD and let it load the installation wizard. In my case, because I am using my trusty NX7400, I almost always jump straight into installation. I am confident that hardware recognition will not be an issue, but if you are not certain, it's always a good idea to start a session from your Live media and make sure that hardware management is not an issue.

Before you start the installation piece itself, make sure you plug in your USB drive. When it comes to USB drives, if you want good performance in the long run, I would recommend spending a bit more and getting a model with speedy I/O. In addition, if you want to use whatever you install for anything other than mere testing, I would say anything below 16GB falls short.

In order to be able to set up your USB drive for subsequent installations, it is a good idea to keep a LiveCD around with some sort of partition utility (I would recommend Parted Magic specifically). This comes in handy when you need to fix any issues with partitions, create new ones or delete existing ones, or even recover your system under some extreme failure.

Everything is in order now, so simply go ahead an proceed with your installation. Your USB drive should appear as /dev/sda1 and selecting the option "use the entire disk" for the installation is probably best.

That is all there is to it, really. Once again shut down your box, remove your battery and put your internal hard drive back on. Then, restart your system and boot from your USB hard drive. You'll probably notice that most day to day activities are very responsive, and sometimes you may find it hard to believe that a USB drive is all there is behind the scenes. Having said so, some other activities like running updates can take significantly longer than they would on your standard internal hard drive. Because of that, my recommendation would be to keep your system as up to date as possible by updating often.

Good luck and let me know if you have any questions.


  1. Great article. But what I don't understand is why you do remove the HD before installing in the USB HD. I am using Ubuntu 10.10 via USB HD in a windows based netbook, after trying 4 different distros in the USB HD. In fact I have 2 linux distros and a ntsc partition in this USB HD, and all of them installed through LiveUSBs. 0 problems during installations and they work great. And nothing changed in the netbook internal HD.IMO, easy, quick and safe.

  2. Da, nici eu n-am înțeles de este necesară manevra cu HDD-ul intern (demontare/remontare) și m-ar interesa un răspuns argumentat deoarece folosesc zilnic 2 HDD-uri externe atașate la un Lenovo 3000N200.
    Întrețin, la nivelul meu de începător-amator, 8 distribuții GNU/Linux, majoritatea derivate Debian.
    Numa' bine !

  3. Like I said, I am just showing the way I do it. I just can't be bothered to deal with GRUB and potentially modifying the MBR. In addition, if an installation detects another OS sitting in another drive, chances are you will get a dual boot, which is not what I want.

  4. Another thought. You can use an external, usb-powered hdd to evaluate distros. Sometimes they are on sale cheaper than 16GB usb thumb drives.

  5. I am referring to an external, usb powered, 5400rpm spinning-type hdd in the above post.

  6. Thanks for your posts,

    Yes, I do have a drive like the one you mentioned, and although I have never found them as cheap as 16GB pens, they do get pretty close sometimes.

    The main thing I dislike about such drives is that they are a lot bigger, and once you have 3 or 4, plus the cases they usually require, it takes a lot of space. Along the same lines, they are more difficult to carry, it´s not like you can take one of those in your pocket! ;-)

  7. Hi Chema,

    This is awesome! After I read your openSUSE article, I tried installing on an external USB drive myself. I did it the hard way, by leaving the internal hard drive in the system, rewriting the grub options, and carefully avoiding the OS partitions on the internal hard drive. Took a lot more time and double and triple checking to make sure I didn't screw up the internal hard drive, or the MBR on that drive. Think I'll try your way next time.

    You are right - I am amazed at how fast it is running off of an external USB. I used a USB HDD, rather than a thumb drive. LibreOffice and Firefox are each popping up in just 2 seconds and ready to go - faster than my normal internal hard drive installs!

  8. @Andy Prough: Glad you are enjoying it! Now you can see the true magic of Linux in action. Take your drive with you, plug it in to other computers and see it boot seamlessly (try that with Windows!).

  9. hi,
    didn't umount the "inernals", messed a bit but managed to install a U 10.10 on an external HDD. but have no working wireless (broadcom 4313). My external HDD has 500 GB and a distro will not take more than 20 gigas. Using the MBR fstab, only 4 primary partitions may be created which leaves me either with 3 distros plus a swap partition, either with 4 distros and no swap. Is there a way to overcome this restriction on the number of primary partitions?
    :) regards

    1. Yes,
      Create 1 primary partition as normal,
      then - using all the free space remaining, create a logical partition. You can then create many more partitions within the logical partition. I'm not sure if there is a limit.

  10. I don't know of a way to work around that issue, no. I have read several forum threads on the subject and it was always regarded as a limitation, not something you can work around.

    Good luck and please post back if you find a solution!

  11. I'm new to Linux, & have been reading all the blogs etc. I have a Windows 7 desktop (dual core AMD Athlon), Windows 7 laptop (Intel I3-370) & a Mac Mini. I got a Patriot Rage XT (write -25, read-27). Used website to download Ubuntu 10.10 on the Windows 7 dual core Athlon - would not boot. Moved the thumb drive to Windows 7 dual core Intel - no problem. All was going well & it was about 11:00 PM. Thought the first thing I should do would be to update, so I selected all available updates (330) & clicked OK. It is now 1:17 AM & it looks like I have another hour to go. What's up with the snail's pace updating?? I don't understand what's going on. The updates only total 314 MB - why does it take hours to do it??

    The good news is that it all appears to be working well enough at this point. Thanks.

  12. For those of you trying the installation on USB, please be aware that installations and specially massive updates do take much longer than in a standard HD. Basically, I think a USB drive can´t handle the uncompression and installation of packages all that well and it is the one point where performance is significantly slower than on your hard drive. Other than that, they get pretty damn close!

  13. For those of you who don't know how to install a linux distro on a usb I recomend trying ubuntu. Its easy to try out cuz you can install it within windows without partitioning your hdd. I've been doing this for years and have never had any problems.

  14. Hint to anyone going to download the ubuntu 11.04 natty.

    once downloaded and installed, i also have mine on a usb hard drive. when downloaded and fully installed never download any updates for the ubuntu what so ever as it will make ubuntu crash complty alll the time espeicaly when using its shitty jdk java which i have no idea how to remove or upgrade even after following its instructions .... i reallly loved ubuntu at one point but absolouty am starting to hate it

  15. This is very simple folks and its been there for quite a while, i hope you enjoy!

  16. Great article. Thank you so much. I am gonna to try tonight

  17. Knoppix has a "copy to USB" functionality. First make a live CD and then copy it to USB.