Instructables
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.
 
Remove these adsRemove these ads by Signing Up

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 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.
1-40 of 120Next »
fretted1 year ago
I've got the ubuntu disc and a flash drive to tell you the truth i don't know what i could use it for what uses can it render on my computer what programs can i run with it ?
taylud2 years ago
would this work on a 2gb memory stick
and if i download ubuntu from the site do i still need a live cd thanks in advance
lopez86756 years ago
for part 4, if you have windows could you do that step in it? i no you can format it, but can you partition it?
Try this!

http://lifehacker.com/391067/fedora-9-puts-your-desktop-on-a-usb-drive

It's Not Ubuntu, it's better! FEDORA!!!
even better, install ubuntu fully directly to your usb, no hacks or 3rd party software, ubuntu has the option to install to a usb flash/hard drive and it runs fine, just make shore that you select your usb drive for boot loader and installation and swap space if use and volla! ubuntu on usb
BrianKT (author)  lopez86756 years ago
Not really; that is what the Ubuntu LiveCD is for...
either way, can you partition a flash drive in windows?
BrianKT (author)  lopez86756 years ago
Yes
Derin BrianKT6 years ago
how
ReCreate Derin5 years ago
google is your friend,not mine,google is my enemy,it does not find me anything
leon-geyer2 years ago
Just for people who has problems like mine
I am installing from a Netbook already with Ubuntu on it. So no CD-Drive.
Using a downloaded Ubuntu.iso (10 LTS), and had this "can not stat" = didn't find original files to copy.

I figured out: Mount and uncompress files, then drag the folder into the terminal to have the path (like user/home/desktop/folder) to put before cd.

If this ain't right, please correct me.

Question: didn't find «disctree», «ubuntu.ico» and «casper/initrd.gz», not in the folder. Last needed for boot. What can I do? best greetings, thnx
leon-geyer2 years ago
Just for people who has problems like mine
I am installing from a Netbook already with Ubuntu on it. So no CD-Drive.
Using a downloaded Ubuntu.iso (10 LTS), and had this "can not stat" = didn't find original files to copy.

I figured out: Mount and uncompress files, then drag the folder into the terminal to have the path (like user/home/desktop/folder) to put before cd.

If this ain't right, please correct me.

Question: didn't find «disctree», «ubuntu.ico» and «casper/initrd.gz», not in the folder. Last needed for boot. What can I do? best greetings, thnx
henry94192 years ago
ok i have a problem when i try to enter +750M to set the partition size it just says value out of range and gives me the option to try again? but this time i just hit enter and set it to the default of 749 but the other steps are messing up...Please help me!!! Thanks!!!
did you remember to put the M? I had your answer when I forgot it
Jolum2 years ago
I realize this thread is probably dead, but I am trying to intall Ubuntu 11.10 onto a flash drive, so far I have completed all steps save for step 5 bullet 7:

"cp -rf casper disctree dists install pics pool preseed .disk isolinux/* md5sum.txt README.diskdefines ubuntu.ico casper/vmlinuz casper/initrd.gz /media/Ubuntu/"

I get the following error:

cp: target `/media/Ubuntu/' is not a directory

Any Suggestions? Thanks!
jsebíň2 years ago
I have troubles with step #5, where it shows:
syslinux: invalid option -- 's'
syslinux: Unknown option: -s

And also in step #7, where it shows
cp: target `/media/Ubuntu/' is not a directory

What should I do with these?

Thanks.
what about my login? what will it be when I log in?
what you set it up to be during the installation
meowzers6 years ago
I just wanted to ask, how do you get a Mac computer to boot from a USB? Macs don't seem to have a BIOS. Thanks!
They have an efi not a bios. I found away to run ubuntu off a usb on a mac but it is a risky process as it will most likely delete the contents of your internal hard drive so remove that before you install it onto a usb. oh you should have at least a 4 gb usb.

DISCLAIMER: I AM IN NO WAY RESPONSIBLE FOR ANY OF THE INFORMATION BELOW ANY THING THAT MAY HAPPEN BECAUSE OF IT TO YOU OR YOUR PROPERTY INCLUDING BUT NOT LIMITED TO YOUR COMPUTER, HARD DRIVE, USB, INSTALLATION DISC'S OR SOFTWARE. BELOW I SHOW A METHOD THAT WORKED FOR ME I AM NOT SAYING THAT IT WILL WORK FOR YOU. TRY THIS AT YOUR OWN RISK.

1. open disk utility and make 3 partitions on your usb the first a 25 mb mac os extended journaled partition which you will install refit on, the second a 100 mb fat 32 partition which will be used as the linux root partition & the third just takes up the remaining space as a fat 32 partition
2. remove your internal hard drive and boot off the linux cd install it to your usb make sure to specify partition 2 as the root partition and partition 3 as the one you want to install the os on. wait for the install to finish.
3.Put your internal hard drive back in boot up your computer with the usb in the slot then restart it hold down option it will ask you whether you want to start up using os x or refit select refit. the refit menu will load and it will ask you whether you want to boot os x or linux from hd select linux and it will boot linux off your usb.
WARNINGS: it is important to remove your hard drive because if you don't all the information on it will somehow get deleted the turning on then restarting is only necessary the first time because refit does not complete installing itself to the usb until the computer has been restarted.
If you don't listen to me and leave your hard drive in during the installation you will find that it will be unbootable and you will have problems reinstalling os x on it heres what you do : boot up off the os x installation disc WITH NO USB DEVICES PLUGGED IN except a keyboard and a mouse select disk utility from the top menu and zero out your hard drive then try doing a custom install of os x installing only the os it should work if not keep trying heck even try a 35 pass. After the installation install the remaining things from the os x installation disc.

DISCLAIMER: I AM IN NO WAY RESPONSIBLE FOR ANY OF THE INFORMATION ABOVE ANY THING THAT MAY HAPPEN BECAUSE OF IT TO YOU OR YOUR PROPERTY INCLUDING BUT NOT LIMITED TO YOUR COMPUTER, HARD DRIVE, USB, INSTALLATION DISC'S OR SOFTWARE. BELOW I SHOW A METHOD THAT WORKED FOR ME I AM NOT SAYING THAT IT WILL WORK FOR YOU. TRY THIS AT YOUR OWN RISK.
luke meowzers6 years ago
i have a macbook (white) and at the moment i use osx 10.5.2 (leaopard) and the latest ubuntu. if its a intell mac you need a app called " refit " i think that if its a PPC mac you dont have that much of a chance luke
mage luke5 years ago
the reason why it wont work is because macs have no souls. rofl
Derin meowzers5 years ago
because they probably have CIOS BIOS:Basic Input Output System CIOS:Confusing Input Output System (no experience with mac,just insulting macs)
LeeRus014 years ago
thanks for this tutorial... i just have a few questions. i've read that u3 in pendrives nowadays are only compatible with windows os. can i run ubuntu with this same tutorial on a pendrive which is already pre-installed with u3? or should i uninstall the u3 feature before i commence with the installation?
Yes
would this work to boot a computer with no opererating system, or a corrupted one?
Deez236 years ago
Hello...great tutorial, but I am stuck on Step 7. I'm running Ubuntu 7.10 now and do not have a CD drive. Do I still execute "cd /cdrom"? When I execute the command in step 7, the cursor moves down to the next line and then...nada. I completed the rest of the steps with no problem. Can you help me? Cheers and great work!
kevinsa5 Deez234 years ago
I'm having the same problem. I got everything to work up until that point, but when I do step 7, the cursor goes to the next line and nothing happens. I tried it a few times, and right now I can hear the disc drive going nuts, which didn't happen before. Any ideas?
okay, I think I fixed that. turns out I needed to do "cd /media/cdrom" for step 6.

So I did it and now there are a bunch of files on my drive. I edited isolinux.cfg (by the way, the original was like five lines long and looked nothing like the new version) and booted into OSX to change the boot order. However, my flash drive doesn't show up in the available disks for startup.

If it helps, I'm doing this in system preferences --> startup disk and am dual booting ubuntu and OSX. I followed all the steps in ubuntu, of course.
Deez23 Deez236 years ago
I tried it again, both in 'cdrom' and in root: This is what I get. cp: cannot stat `casper': No such file or directory cp: cannot stat `disctree': No such file or directory cp: cannot stat `dists': No such file or directory cp: cannot stat `install': No such file or directory cp: cannot stat `pics': No such file or directory cp: cannot stat `pool': No such file or directory cp: cannot stat `preseed': No such file or directory cp: cannot stat `.disk': No such file or directory cp: cannot stat `isolinux/*': No such file or directory cp: cannot stat `md5sum.txt': No such file or directory cp: cannot stat `README.diskdefines': No such file or directory cp: cannot stat `ubuntu.ico': No such file or directory cp: cannot stat `casper/vmlinuz': No such file or directory cp: cannot stat `casper/initrd.gz': No such file or directory
BrianKT (author)  Deez236 years ago
Try mounting the Ubuntu iso.
Deez23 BrianKT6 years ago
yeah, eventually, I figured that out. A few hours later, I got it sorted out. Cheers.
cormac30505 years ago
Couldn't you just use slax instead? You don't have to install it on your computer or even format your usb drive!! 9Great to use on school computers! :P)
Plzz help how do i add Slax on my USB and run at school (they block scripts,cmb,run and command propt.)
poulina4 years ago
This is great

Greetings Rocky
this is amazing! thank you so much!
HI, I tried the instructions on Pendrivelinux.com, which are very similar to these, and when writing to the "Ubuntu" partition, it says "No free Space" or something similar. Should I try a bigger partition size? And also, can I use Disk Utility in OS X?
I tried that same tutorial on a 2 Gig PNY Attache USB stick. After completing everything, and setting my BIOS to boot from USB, i got the error No bootable partition in table. Also, did you format your flash drive before completing the tut? Make sure you tell windows to format it as FAT32. Anybody else get the error that I did? How do you fix this?
do i still have to format the flashdrive
yes, but that doesn't do anything but erase all the files.
1-40 of 120Next »