Boot and Run Ubuntu From a Flash Drive

581,531

150

127

Posted

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.

Share

    Recommendations

    • Microcontroller Contest

      Microcontroller Contest
    • Science of Cooking

      Science of Cooking
    • Pocket-Sized Contest

      Pocket-Sized Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    127 Comments

    It's much easier than that.

    1. Download Rufus (google for it)
    2. Download the Unbuntu desktop iso (google that too)

    run rufus with your pendrive plugged in, select the unbuntu ISO as source for the bootable disc. Press 'Start'. Done.

    Don't forget to press F12 or whatever key is needed to get your pc into the boot selector. In some configurations you may have to enable the menu in the BIOS.

    No... that makes the USB boot to the Ubuntu setup, which installs Ubuntu on the computer.

    Any help pls.. not Able to Do

    hi rohit9999, IMHO this instructions is outdated for a while, try using the instruction on http://www.pendrivelinux.com/put-ubuntu-10-04-on-f...

    Basically, u need to download the ubuntu iso, burn it to a DVD

    boot it your laptop/computer from the DVD

    create a ext4 journaling file system using min 7G (or all the usb space - the swap space(use in next step)) and mount as /

    create a swap space using the swap space reserve in previous step.

    then install the OS on the USB stick

    last, try boot using the USB

    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!

    Try doing what I'm doing. As I write this I am running Ubuntu 14.04 and I just grabbed a .iso of it and put it on a USB drive. Then I booted from the USB drive, plugged another 16 gig thumbrive into my second port and ran Ubuntu setup on that. More complete instructions can be found on the Ubuntu forums.

    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

    Try mounting the Ubuntu iso.

    yeah, eventually, I figured that out. A few hours later, I got it sorted out. Cheers.