Ubuntu on an External USB harddrive


Goal

Ubuntu on an external USB HD, which can be plugged in to any USB bootable computer (x86) and run. This entails:

  • GRUB on the HDs MBR
  • Hardware auto-detection at boot time

Our setup

I worked on this with a friend. We used:

  • HP Compaq dc7600 computer
  • Western Digital 80 GB USB laptop hard drive (bus powered)
  • Ubuntu Edgy (6.10) Desktop install CD

This page is OLD and probably contains errors, out of date information, security flaws or other problems. I am keeping it around because it might be helpful to someone. If you can believe it, back in the day (Ubuntu 6.10) installing Ubuntu on an external drive really was a good  bit of work. In my opinion, making the X server basically always work has been the greatest improvement in Linux Land since 2006.

How to

  1. Remove all internal HDs from the computer
    • GRUB by default installs to the first HD. We found this to be the simplest way to make it install to the correct location
  2. Boot from the Ubuntu install CD, with the USB drive connected
  3. Run the Ubuntu installer
    • You may want to manually partition the drive so that you have a portion of the disk in FAT 32 format. If you do this, be sure to mark the linux partition as bootable! That will make it easy to access your files from the USB drive without booting into Linux
    • When you’re done with the installer CONTINUE USING THE LIVE CD
  4. Modify GRUB’s menu.lst file on the new install
    • Use the Gnome Partition Editor (System->Administration menu -> GNOME Partition Editor) to mount the newly created root partition
    • Locate the menu.lst file. It should be at boot/GRUB/menu.lst
    • Open a terminal and type “gksudo gedit “, then drag the menu.lst file to the terminal, then press ENTER. The file should open
    • Find the line in the menu.lst file that says “kopt=root=UUID=(Long HEX number here)”. Copy from “root=UUID=” through the end of the HEX number.
    • Replace all instances of root=/dev/sda1 (where sda1 is the partition you installed to) and replace them with the “root=HEX-NUMBER” line.
    • This is to make GRUB find the HD no matter what device it shows up as.
    • Save and close the file
  5. Modify the gdm init script to reconfigure the graphics card each time it starts
    • In the terminal, type “gksudo gedit ” again, but this time drag the file etc/init.d/gdm from the new install
    • Find the line that says “start)”.
    • Insert a new line below the “start)” line that says “dpkg-reconfigure -fnoninteractive –no-reload -phigh xserver-xorg” (this auto reconfigures the xserver. I believe it’s the same command used in the Ubuntu Live CD)
    • Save and close the file

  6. Add an updated sources.list
    • For some packages that we need to install, we will need to access more than the default set of software Ubuntu provides. To do this, we will update our apt config file. Another page on this site talks more about apt.
    • Download this new sources.list file to your desktop.
    • In a terminal type “sudo cp ~/Desktop/sources.list “
    • Find the old sources.list file at etc/apt/sources.list on your new install, and drag it to the terminal
    • Press ENTER and the old file will be overwritten
  7. Shutdown, disconnect the HD, and you should be set!

Issues

  • GRUB wants to be on hd0 (the first HD the BIOS sees). In some BIOSes, simply selecting to boot from USB is enough to make this the case. On others, the boot order makes a difference. If you are selecting to boot from USB, but get GRUB errors, try changing the default boot order.
  • This would probably work in a very similar fashion on other distros. Ubuntu Edgy uses volume IDs in the fstab which helps this work. That may not be the case for other distros
  • Other? — We only had a handfull of computers to test this on so far

This entry was posted in Computers, Projects and tagged , , . Bookmark the permalink.

Leave a Reply

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