May 29, 2008 · General · Email This Post

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

I was reading How to install Ubuntu Linux from USB Stick posted on this site a while ago, and found it to be quite some work to get Ubuntu working on a USB stick. Besides, having to prepare your USB device, creating a separate partition on it which will be more or less “useless” after the installation, giving up 750MB of space?

There had to be a better way.

Together with a colleague of mine, I decided to figure out whether there could be an easier way to install Ubuntu on a USB device.

I found a way of doing it in a much simpler way… without creating the separate partition to store the LiveCD:

A couple of assumptions to take into account when going through this manual:

  • My computer (Dell D820 laptop) has 1 internal disk, devided into 3 partitions (dell utility – windows – Ubuntu 8.04)
  • Just one USB device (in my case a 250GB harddisk
  • BIOS configured to enable boot from internal HDD, CD/DVD and USB Storage device

(I didn’t take screenshots, so I will be explaining a lot about the screens… It looks like a lot of work, but trust me: it is not, and it really is easy:-)

  1. Insert the LiveCD into your computer;
  2. Connect your USB device;
  3. Boot your computer from the liveCD;
  4. Once Ubuntu is started, go to System – Administration – Partition Manager
    This will open the Partion Editor. Select your USB device and delete all partitions on it. Click Apply and exit Partition Editor;
  5. Double Click the Install Icon. This will start the Installer;
  6. The Welcome Screen is shown. Choose your language and click Forward;
  7. Select your Time Zone and click Forward;
  8. Choose your Keyboard Layout and click Forward;
  9. The partitioner will be started, and you will be given the choice where to install Ubuntu. Choose Guided – Use entire disk, selecting your USB device (this will most likely be /dev/sdb, don’t choose /dev/sdb1!);
  10. The next sceen you will give your username/password information. Provide the required info and hit Forward;
  11. If there is anything to migrate from other installations on your computer (most likely not), do whatever you want, and click Forward;
  12. The next screen is important – It is titled: “Ready to Install”. Be careful here: before clicking on Forward, make sure you click on the “Advanced” Button!
    This will open a new screen, giving you the option whether and where to install the bootloader. Select your USB device (in my case it was /dev/sdb) to install the bootloader to;
    Exit this screen and click on Forward in the “Ready to Install” screen, which will be shown;
  13. The installation will be started now. Just be patient, grab a cup of coffee and come back 15 minutes later, your installation will be more or less finished by then.

So you have finished the installation. However, when you will be restarting your system from USB, you will find out that the partition you just installed Ubuntu to cannot be mounted.
Here comes the trick:

  1. Once the installation is finished, reboot your PC (this is the safest) from your LiveCD, with your USB device connected;
  2. Once started, open up a terminal (Applications – Accessories – Terminal);
  3. In the Terminal, type: sudo -i (which will give you root privileges, so be careful from now on!);
  4. Change directories to /media/disk/boot/grub – This will take you to the “/boot/grub” directory on the USB device;
  5. open menu.lst with vi (make a backup first!)
  6. Go to line 130 (or somewhere in that area).
    You will find a line looking like:
    ## ## End Default options ##
    And underneath it you will find three entries pointing to your Ubuntu you just installed:
    title         Ubuntu 8.04, kernel 2.6.24-16-generic
    root        (hd1,0)
    kernel     /boot/vmlinuz………
    initrd       /boot/initrd…….
    quiet
    (the above 5 lines repeat 3 times with slight differences)
  7. The magic trick is to change (hd1,0) into (hd0,0) for all these three entries.
    Why? Booting from USB device makes your USB device hd0, in stead of hd1 at time of installation.
  8. Search for the line starting with “# groot=(hd1,0)” and change (hd1,0) to (hd0,0) – Don’t delete the # at te beginning of this line!
  9. Once you did this, you can optionally remove the remaining of the file
    (everything underneath ### END DEBIAN AUTOMATIC KERNELS LIST);
  10. Save the file, make sure it is owned by root:ubuntu (chgrp ubuntu menu.* will do)
  11. Edit device.map (in the same directory) and change the mapping of hd0 to /dev/sdb.
  12. Reboot your machine, from USB, choose the Ubuntu installation from the Boot Loader and you are one happy person.

I guess that is it. If I missed something, please comment.

Regards,

  • Share/Save/Bookmark

Related Articles

39 Comments to “A much easier way to install Ubuntu on a USB device (Stick or HD)!”

  1. fear_nothing says:

    Great guide – I’ve searched the net high and low yours has proven to be the easiest to follow and understand. Simply put if you follow the directions given by the author this will work fine!

    Thanks

  2. Bill Cressey says:

    It works well as a stand alone Ubuntu desktop , however it is best to slim it down using either Gnome or KDE Desktop to save unecessary download updates. When Using the Ubuntu live CD ISO installer, mine was 8.04, do not tick any boxes for the transfer of other drives settings/ documents, it will then be independent of any computer system. It will update or upgrade as normal Ubuntu desktop albeit of course a little slower than a the normal hard drive installation.” To ease wear on the USB key in Terminal and avoid unnecessary writes ,edit the your /etc/fstab file , sudo gedit /etc/fstab edit the swap file by deleting it and type in the following :
    tmpfs /tmp tmpfs nosuid,nodev 0 0″
    Make a backup copy of the original fstab first to remind you what was there to begin with!
    “tmpfs , otherwise known as as a RAM disc , should if you have enough RAM be able to do without swap entirely,which neatly sidesteps this problem .” Thanks to Linux Format Jan 09 page 42 for this helpful tweak to installing USB.
    As an UBIE, it works out of the box, if you reduce the screen
    resolution to the minimum then it loads on laptops no problems.
    You may need to tweak your BIOS to allow a USB drive to boot.If you have problems with a particular PC, Google that OEM to see how other users have produced a work round for your PC.
    I’m taking my Ubuntu USB with all systems go, to Santiago,Falkland Islands, New Zealand and Singapore for 6weeks. it will be a breeze to send anything via the net with this system!

    Thank you Arnoud Roth, brilliant, I have tried 6 or 7 Distros but the permanent file partition did not always work and often crashed and had left creating USB distro for three months. This one works, it is a slimmed version of the hard CD drive ISO, using synaptic Package Manager to permanently remove unwanted packages. Regards Bill Cressey

  3. Bill Cressey says:

    Hi Arnould,
    I have just noticed that my quotes for Linux Format end on the line of the fstab insert , it needs to be deleted to avoid any problems.
    Regards Bill

  4. Martin Benson says:

    Just to let you know I used these instructions to install eeebuntu (NBR) on a usb hard drive attached to an Aspire One. It just worked, straight out of the box. Didn’t even need the magic tricks from steps 7 to 12 at the end. I’ve changed the boot order to boot off the USB disk first. So now, if I have the USB disk plugged in, it gives me a menu to boot either eeebuntu or the standard linpus; if I don’t have it plugged in, it just boots normally. Great!

  5. snipercup says:

    Hi,

    Same as martin benson, i installed easy peasy (eeebuntu) on a packerd bell easynote PB47R01086. Its based on ubuntu 8.10 (other than what was used in this tutorial) and doesnt use the root reference. It just has a UUID=r2329jf92-4f42f-g35gr-34tg5-4g4324ffdg name for the harddisk.

    I get the following:
    title easy peasy 1.0, kernel 2.6.27-8-eeepc
    uuid r2329jf92-4f42f-g35gr-34tg5-4g4324ffdg
    kernel /boot/vmlinuz-2.6.27-8-eeepc root=UUID=r2329jf92-4f42f-g35gr-34tg5-4g4324ffdg RO quiet single
    initrd /boot/initrd.img-2.6.27-8-eeepc
    quiet

    im testing it out right now, i already installed it on my eeepc900 (where im typing this from) and i like it.

  6. joey_oggie says:

    I followed everything quite good untill the 6th step. I don’t have a “root” line.

    QUOTE
    title ….
    uuid ….
    kernel ….
    initrd ….
    quiet ….

    title ….
    uuid ….
    kernel ….
    initrd ….

    title ….
    uuid ….
    kernel ….
    quiet ….
    /QUOTE
    I am using Ubuntu 8.10 btw.

  7. Jaystone says:

    Dude! you are a freakin genius. I’ve been trying to figure this out for two days. I’ve tried evrybody on the internets hairbrained ideas. I knew I just needed to edit the grub config files. I just couldnt figure out exactly how. Now I can run Ubuntu 9.04 on my work laptop and bypass all their encryption, monitoring and protection bs, without changing one bit on the hard drive. Thanks

  8. re3e says:

    well tried on 2 keys a 16Gb and a 4Gb kinsgston traveller , 16G crashes in the setup (same on 2 diff keys of the same 16Gb model ) but is flawless on the 4Gb , not even a grub mod needed , setup was done with jaunty and intrepid

  9. Antonio says:

    I installed Kubuntu Jaunty yesterday on a 320GB USB HD. In accordance with suggestions from other guides found on-line, before starting I physically removed the internal HD, in order not to risk anything on the existing Windows XP (that I can’t touch).

    I just followed the normal installation steps as per your guide but in step 9 I deviated from your suggestion and selected manual partition (the disk was seen as /dev/sda). I partitioned in the following way:

    A) 30GB ext4 for “/”
    B) 160 GB ext4 for “/home” (I find very useful a separate /home partition)
    C) 2GB for swap
    D) 120 GB Fat32.

    Please note that I went through step12 but the installer by itself proposed already Grub on /dev/sda. Very smart !!

    Once the installation was complete I rebooted and all was perfect. No need of any manual editing of any file (no tricks necessary). Grub already perfect…

    Finally I reinstalled the internal HD and verified that:

    1. if boot without connecting the USB disk, Windows XP starts, untouched, exactly as before

    2. if boot with the USB connected my Kubuntu starts perfectly.

    Thanks

Leave a Reply