Booting Ubuntu from an USB stick

Wednesday, May 12th 2010, 00:36

Booting Ubuntu from an USB stick is both fast and convenient: fast because an USB stick definitely has better R/W speeds than CDs, convenient because you can alter those files for how many times you want without buying several storage mediums (you could use a CD-RW, but that still would be slow). Nowadays USB sticks have become cheaper and offer much more GB/$ than they used to, so it’s not unusual to find affordable flash pens with 2+ GB storage space. Considering that an Ubuntu LiveCD has about 700MB, putting that on a 2GB flash pen will leave you with almost 1.3GB unused space. Wouldn’t that be a shame?

Of course, USB sticks can have multiple partitions (but not on Windows – and guys & girls, this is a feature, not a bug). While using your pen’s 2 partitions wouldn’t be a problem on Linux, this certainly is a debatable subject on Windows. Let’s make it clear: Windows only sees the first partition of a removable drive. What’s the solution if you want to use your USB stick for storage too?

How to

My stick for this job is a 4GB Patriot Xporter XT Boost, which is a pretty fast beast. I am assuming that you are working with Ubuntu (installed on your machine or running from a LiveCD, the differences are minimal). The tools used for the job are GParted and Ubuntu Live USB Creator. While the latter comes by default in Ubuntu, the former is only present on the LiveCD but can be installed easily:

sudo apt-get install gparted

The first step consists of creating the necessary partitions on your stick. Insert your stick to an USB port and open GParted (System » Administration » Gparted). Now select your USB pen (on my machine this is /dev/sdg) and delete all the available partitions. After this your stick should look like in screenshot 1.

GParted Unallocated Space

GParted Unallocated Space

Next you have to create the STORAGE partition and then the UBUNTU partition (screenshots 2, 3 and 4), where the UBUNTU partition should have about 714MB.

GParted - creating the STORAGE partition

GParted - creating the STORAGE partition

GParted - Creating the UBUNTU partition

GParted - Creating the UBUNTU partition

GParted - final partition layout

GParted - final partition layout

Then start Ubuntu Live USB Creator (System » Administration » Startup Disk Creator). Select your Ubuntu image/CD and from the partitions listed in the bottom frame select the one labelled UBUNTU (if your stick appears like /dev/sdg, this partition should be /dev/sdg2). By using the second partition for Ubuntu you assure yourself that you can use your stick for storing files on the first one using Windows machines (this also protects your second partition against accidentally being written by a Windows user). Once you’ve made these choices, click on Make Startup Disk and wait for the process to finish.

Ubuntu Live USB Creator

Ubuntu Live USB Creator

To boot a machine using your newly created Live stick, change the BIOS settings accordingly. This can vary from selecting the first boot device to be a Removable one, or setting your first hard disk to be your flash pen (this depends on the system to be booted). Now not only that you have a stick from which you can boot and install Ubuntu in a breeze, you also can use that extra space for platform independent storage.

You might also like:

2 Comments

  • Hi. Thanks for the guide. I set up exactly as you said. However, when using ubuntu, I cannot open or run any tar.gz or exe files. I want to have Truecrypt on the storage partition, and be able to run it in Ubuntu, w/o having to download it each time. Any thoughts?

    Thank you.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


CODE EXAMPLES: When you want to include source code or terminal output, please use the the following tags like in the next example:

    [language]
    code lines
    [/language]
	

where you substitute language with the programming laguage used throught the code example (for terminal output that would be bash), e.g:

    [bash]
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    [/bash]
	

To see a list of all the supported languages, please check this page.

If you want to include code bits inline, please use the code tags like in the following example:

    The <code>$USER</code> variable holds the current logged in username.
	

Projects that I support

Recent Comments

  • nope said:
    yeah that was my first thought too, but: mount: warning: seems to be mounted read-write. too bad, would have been just perfect. more»
  • Klaus Deiss said:
    Dear Radu, I tried it on Ubuntu 10.0.4.2 and 10.0.4.3 with different kernel versions (amd64 server 2.6.32 kernel). No... more»
  • scompo said:
    Nope.. Now it’s not working again.. This printer it’s a real pain in the butt.. The other hp printer I had... more»
  • Dmitrij said:
    Thank you Peter and Patrice. Could you please post the updated script? more»
  • hd_flash_pains said:
    didn’t work for me more»

Recent Tweets

Bear