Introduction: Boot and Run Ubuntu From a Flash Drive

Running an operating system, like Windows, off of your flash drive can be very useful sometimes. You can recover your data from a hard drive and copy it to an external hard drive if that computer won't boot up or scan that computer for viruses and so on... This Instructable will show you how to install, boot, and run the popular Linux distro, Ubuntu from your flash drive. You will be able to automatically save your changes and settings back to the flash drive and restore them on each boot using a second partition.

You can run Ubuntu will all your settings and files, even if you don't have your own computer with you. You will have a whole, powerful operating system in your pocket!

Sorry for the not very helpful pictures. It was to hard to document each little step for each step. Hopefully it is still easy to follow...

I'm not liable for any damage done to your computer and/or flash drive. However, I haven't ever had a problem. Just make sure to follow each step carefully.

*This process is no longer needed as of Ubuntu 8.10 because a USB Ubuntu Creator is built in.

Step 1: Get Materials

Here are the materials needed:
  • USB 2.0 Flash drive (at least 1G) (You could use USB 1.1, but everything will take 5x longer)
  • Computer w/ CD Drive (Must be able to boot from USB. Newer motherboards will work. Motherboards older than 2 years old probably won't work. A BIOS update from your computer manufacturer might work.)
  • Ubuntu LiveCD (You don't need this if your computer already has Ubuntu installed on it)
  • You should also be somewhat computer-savvy and comfortable with command prompt/ terminal.

I used a 4GB Sandisk Cruzer Micro and Ubuntu 7.10 (current one at time of writing)

You can get the Ubuntu LiveCD at ubuntu.com. Download the Ubuntu Desktop LiveCD iso and burn it on a CD using Nero or another program. You could also request a free Ubuntu CD but that takes 6-10 weeks to ship.

Step 2: Changing BIOS Boot Order

We will need to change the boot order of your BIOS throughout this Instructable. Turn on your computer and while it turns on press the button to access the BIOS Setup Utility. Usually F2 or Delete. Navigate around the setup until you find something about the boot order. You can change it so if that first device is their, it will boot up from that device. If the device isn't their, it will keep going down the order/list until their is one with that device plugged in.

Also, when you boot up you might have an option to temporarily boot up from a certain device. You could use this if you want to only boot up from a device once.

Step 3: Boot From the Ubuntu LiveCD

Once you have Ubuntu, turn off your computer and stick the CD in it. Turn on you computer and setup the BIOS to boot from the CD. It will load and then you will see Ubuntu!

You can skip this if your computer has Ubuntu installed on it. Just turn it on and log in.

Step 4: Format the Flash Drive

Now that you're in Ubuntu, it is time to format the flash drive. We will make two partitions, one for the actual Ubuntu OS, and another to automatically save your changes and settings back to the flash drive and restore them on each boot. You can also store personal data on the second partition.

Backup all your data on your flash drive before doing this. This will erase all your files on you flash drive

0. Backup the data on your flash drive.

1. Open Terminal, under Applications

2. Type in "sudo su"

3. Type in "fdisk -l", and identify which device is your flash drive. Mine was "sdb". Whenever I type "sdb", put in your flash drive identification. For example, if your flash drive was sda, and I typed "format sdb1" then you would type "format sda1".

4. Type "umount /dev/sdb1"

5. Type "fdisk /dev/sdb"
  • type p to show the existing partition and d to delete it
  • type p again to show any remaining partitions (if partitions exist, repeat the previous step)
  • type n to make a new partition
  • type p for primary partition
  • type 1 to make this the first partition
  • hit enter to use the default 1st cylinder
  • type +750M to set the partition size
  • type a to make this partition active
  • type 1 to select partition 1
  • type t to change the partition filesystem
  • type 6 to select the fat16 file system
  • type n to make another new partition
  • type p for primary partition
  • type 2 to make this the second partition
  • hit enter to use the default cylinder
  • hit enter again to use the default last cylinder
  • type w to write the new partition table

6. Type "umount /dev/sdb1", then "umount /dev/sdb2".

7. Type "mkfs.vfat -F 16 -n Ubuntu /dev/sdb1". This formats the first partition.

8. Next, type "mkfs.ext2 -b 4096 -L casper-rw /dev/sdb2", to format the second partition.

9. Exit terminal, then unplug your flash drive.

Step 5: Install Ubuntu to the Flash Drive

Now that you have finished formatting the drive, you can now install Ubuntu onto the flash drive partitions.

1. Insert flash drive.

2. Open Terminal.

3. Type "apt-get update".

4. Go to Ubuntu Packages and download Mtools and install. Afterward, download Syslinux and install.

5. In terminal, type "syslinux -sf /dev/sdb1".

6. Type "cd /cdrom"

7. Type "cp -rf casper disctree dists install pics pool preseed .disk isolinux/* md5sum.txt README.diskdefines ubuntu.ico casper/vmlinuz casper/initrd.gz /media/Ubuntu/".
  • Ignore any "cannot create symbolic link" errors.

8. Go to first partition of the first flash drive and rename "isolinux.cfg" to "syslinux.cfg".

9. Edit "syslinux.cfg" so that it looks like the attached text file.

Finally... You are done!

Step 6: Conclusion

Now you're done! Just reboot the computer, set it to boot from the flash drive in the BIOS, and let it load!

If your can't get Ubuntu to boot, your flash drive may have a corrupted MBR. To repair the MBR of your USB device, at the terminal in Ubuntu type "sudo apt-get install lilo " followed by "lilo -M /dev/sdb".

You can now run Ubuntu anywhere and still have all your settings and files.

Pocket-Sized

Participated in the
Pocket-Sized

The Instructables Book Contest

Participated in the
The Instructables Book Contest