Ubuntu Feisty on your USB drive – finally!

IMPORTANT NOTE: Unless for some specific reason you want to run Ubuntu version 7.04 specifically from your USB Drive, this tutorial is deprecated. I’ve written an updated and much easier tutorial on how to run the latest version of Ubuntu from your USB flash drive.

Important: As SurJector mentions, he has found another workaround that is much less work. After you have followed his instructions, you can skip on to the partitioning part (i.e. that part that is very similar to almost my whole post about putting Xubuntu on your USB drive).

Update: I now also have a guide on putting Xubuntu Feisty on your USB drive.

Note: All screenshots are also available as a slideshow.

When, in June 2006, Ubuntu Dapper Drake was released, it introduced a very exciting new feature: the ability to run it from a USB drive (also pendrive, USB bar or memory stick). This would work just like a LiveCD, with the big improvement that all your data could be saved onto the USB drive! This means not just your documents, but also e.g. network settings or your desktop background. You were practically carrying around a fully-functional operating system on your USB drive!

However, as Ubuntu 7.04 “Feisty Fawn” contained some new packages, it also introduced a bug due to which your data would no longer be saved. When it was released, this bug still wasn’t fixed. It is expected to be fixed in the next release, 7.10 “Gutsy Gibbon”, to be released in October of this year. Up until then, we’re out of luck.

You’d think. However, thanks to the hard work of Mike (mjpca on the Ubuntu Forums) and some others (see the bug report on Launchpad and the thread on the Ubuntu Forums) there is now a way to work around this bug, which I’m going to show you in this post.

The basic idea is that the files that prevent persistence (the ability to save your data to the USB drive) from working can be replaced by their previous versions as present in Ubuntu 6.10 “Edgy Eft”. However, because files on the LiveCD are compressed so they can fit on one CD, replacing these files requires quite some effors. Luckily, Mike has done all the hard work for you and has created a new hybrid Edgy/Feisty image. To use it, your computer needs to be of the type Intel x86. Don’t worry, if you don’t know what this is, you probably use it. Furthermore, I recommend you use a USB drive of at least 2 GB, because the image is quite large.

For those with 1GB USB drives or who prefer Xubuntu (which would be me ;)) I plan on creating a Xubuntu image, but I’m not quite sure if I’m able to. If it works out, of course I’ll post on this blog.

Note: This tutorial is adapted from this How-to from Debuntu.org.

To start, fire up Gparted from Applications->System->GNOME Partition Editor (note: for those that do not use Xubuntu, you’ll have to find the applications yourself). On the top, right-hand side, you can select which drive you want to partition — select your USB drive. Be careful not to select any other drive, because you will be erasing all data that is available on that drive! You first have to delete all existing partitions, which will erase all existing data. Note down or remember the name of your drive, because you’ll need it later. Mine is /dev/sda

We then create the first partition, which will contain Ubuntu. Set its size to 840 MB (which is the same as MiB), its filesystem to FAT16 and leave the rest as is.

We will then create the second partition, which will hold all of our data. Just let it take all of the remaining space and set the filesystem to ext2 .

Make sure that every partition is unmounted. If a partition is not, right-click it and select unmount.

You then see an overview of how the drive will be partitioned — click the checkmark or select Edit->Apply to apply your actions.

It will ask you if you are sure, because it will erase all your data. If you’re fine with that, select Apply.

You’ll then have to wait a little while Gparted applies the operations. When it’s finished, you can close Gparted.

Now you need to format each partition and give it a label. The name of the first partition, which holds Ubuntu, does not matter that much, however, the partition that needs to hold your data needs to be named casper-rw.

To partition and label the first partition, run the following command, in which you replace /dev/sdx with the name of your drive (Remember? Mine was /dev/sda). Note that I named it UbuntUSB (how original) but if you want, you can just use another name:

$ sudo mkfs.vfat -F 16 -n UbuntUSB /dev/sdx1

This won’t take long. For the second partition, you run this command, again, replacing /dev/sdx with the name of your drive (but keep the name casper-rw!):

$ sudo mkfs.ext2 -b 4096 -L casper-rw /dev/sdx2

This will take a bit longer, and will also output more.

And here comes the fun part. You need to download the image that Mike created (generously hosted by pepeio. Use the second ISO he created). After it has finished downloading (can take quite a while) you need to extract the .iso file using Xarchiver. I recommend you to save it to a folder in /tmp so that it will be deleted on shutdown, because you don’t need it after you’re finished. I saved it to /tmp/ubuntu-livecd . Make sure you check “Extract files with full path”.

Now you need to copy some files (which contain Ubuntu) to your USB drive, onto the first partition (which I named UbuntUSB). First copy the folders casper , disctree , dists , install , pics , pool , preseed and .disk (to see this one, select View->Show Hidden Files). Then we need the files md5sum.txt , README.diskdefines and ubuntu.ico . Then move to the folder “isolinux” in the extracted folder (so for me, that would be /tmp/ubuntu-livecd/isolinux ), but do not change your location in the USB drive. Copy all the files that are present in the isolinux folder to your USB drive. Then, move into the “casper” folder in the extracted folder ( /tmp/ubuntu-livecd/casper ) and copy vmlinuz and initrd.gz to your USB drive. Finally, move into the “install” folder in the extracted folder ( /tmp/ubuntu-liveusb/install ) and copy mt86plus to your USB drive.

Now, on your USB drive, rename the file isolinux.cfg to

syslinux.cfg .

Replace all its contents with the following:

DEFAULT persistent

GFXBOOT bootlogo

GFXBOOT-BACKGROUND 0xB6875A

APPEND file=preseed/ubuntu.seed boot=casper initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --

LABEL persistent

menu label ^Start Ubuntu in persistent mode

kernel vmlinuz

append file=preseed/ubuntu.seed boot=casper persistent initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --

LABEL live

menu label ^Start or install Ubuntu

kernel vmlinuz

append file=preseed/ubuntu.seed boot=casper initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --

LABEL xforcevesa

menu label Start Ubuntu in safe ^graphics mode

kernel vmlinuz

append file=preseed/ubuntu.seed boot=casper xforcevesa initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --

LABEL check

menu label ^Check CD for defects

kernel vmlinuz

append boot=casper integrity-check initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --

LABEL memtest

menu label ^Memory test

kernel mt86plus

append -

LABEL hd

menu label ^Boot from first hard disk

localboot 0x80

append -

DISPLAY isolinux.txt

TIMEOUT 50

PROMPT 1

F1 f1.txt

F2 f2.txt

F3 f3.txt

F4 f4.txt

F5 f5.txt

F6 f6.txt

F7 f7.txt

F8 f8.txt

F9 f9.txt

F0 f10.txt



Save that and close. For our last step, we need the packages syslinux and mtools , so fire up Synaptic (Applications->System->Synaptic Package Manager) and install them. Make sure that your USB drive is unmounted, then go into a terminal (Applications->Accessories->Terminal) and enter the following command, replacing /dev/sdx with the name of your drive:

$ sudo syslinux -f /dev/sdx1

Well, all that is left now is to test it, so boot from your USB drive, and then you’ll (if everything went right) be greeted with a screen like the one I was greeted with:

If this tutorial worked for you, please leave a reply in the comments here. If it didn’t work, you can also leave a comment, or rather (if you have an account) post a message in the Ubuntu forums thread, so we can find a way to fix it.

Note: If you want to create a new user, be sure to grant administrator rights, otherwise it may cause errors.

Troubleshooting

Toad mentions that he could not boot from his USB drive, but he fixed it: I finally got the computer to boot from the USB stick. I had to set the fat16 partition to bootable. ‘cfdisk /dev/sdx’ should do the trick, just press enter on the set bootable option.

If this worked, but after a while it doesn’t anymore, you can remove any edits you did to restore it to the point where it worked (all your settings will be lost though):

$ sudo mkfs.ext2 -b 4096 -L casper-rw /dev/sdx2

(Thank zenobiaflex for this one)

$ (Thank zenobiaflex for this one) If you want more than the two partitions described here on your disk, be sure that the first partition needs to be the FAT16 partition, as that’s where the bootloader gets loaded which needs to be on the first partition. Thanks Matt.

If your drive won’t boot correctly, your Master Boot Record may be corrupted. You can repair it with Lilo (so open up Synaptic from Applications->System->Synaptic Package Manager and install the package lilo ) using the following command from the terminal:

$ sudo lilo -M /dev/sdx

(From PiterP)

) using the following command from the terminal: $ (From PiterP) If, during shutdown, the screen switches from the shutdown screen with the Xubuntu logo with the progress bar to a black screen, possibly with error messages, then you computer is probably just shutting down the normal way without notifying you of its status. At a certain moment (not too long after the screen turned black) it will have reached the point where it would have normally said something like “remove the disk, close the tray (if any) and press enter”. So when the screen turns black, you just have to try to press enter a little while after it has turned black.