Ubuntu:Install from USB drive
From Linux 101, The beginner's guide to all things Linux.
Installing Ubuntu from a USB drive provides an alternative installation method to users without an optical drive or access to an Ubuntu network install server. The files associated with this article refer to Ubuntu 5.04. If you wish to install a different version of Ubuntu with your USB drive, make sure you find the appropriate files.
Contents |
[edit] Requirements
Installing Ubuntu from a USB drive will require a computer capable of booting from USB, a hard drive setup to permanently hold Ubuntu (just means some place to hold the installation), a USB drive, the appropriate Ubuntu files, and access to a computer running Linux to put the bootloader, syslinux, on your USB drive. You should make certain the first two requirements are met before proceeding with the steps described herein.
[edit] Can I boot from USB?
To determine if it is possible for the computer to boot from USB, you should turn off the computer, plug in a USB drive, and power on the computer. Once the computer is turned on, you will need to find the boot options. Viewing the boot options varies from computer to computer, but generally this can be done by pressing F8 or F12 shortly after turning on the computer. If a menu pops up showing the boot options, look for something like "USB drive." If this is present, you can boot from your USB drive. If F8 or F12 didn't do the trick, try F1 or the delete key to enter the BIOS. Do not change any settings in the BIOS; simply look for a menu concerning boot options or sequence. In this menu look for something like "USB drive," and if this is present, you can boot from USB. If you don't see an option for a USB drive, it still may be possible to boot from USB by upgrading your BIOS. Once you've determined your computer can boot from USB, continue with the directions.
[edit] Setting up your hard drive
You must also have a hard drive on your computer ready for the installation of Ubuntu. If you've started out with a blank hard drive, or you've decided to erase it completely, then you don't need to worry about this requirement. However, if you would like to dual-boot Ubuntu and another operating system that possibly already resides on your hard disk, you must setup your hard drive appropriately. This process requires partitioning and/or re-sizing of partitions with a program like qtparted, but such a task is outside the scope of this article; however, realize that this may be necessary if you wish to keep files or operating systems already on your computer.
[edit] The Quick Method
For Ubuntu get boot.img.gz from http://archive.ubuntu.com/ubuntu/dists/intrepid/main/installer-i386/current/images/hd-media/ For Kubuntu boot.img.gz is available from http://darkstar.ist.utl.pt/kubuntu/archive/dists/hardy/main/installer-i386/current/images/hd-media/
Alternative CD ISO : http://www.ubuntu.com/getubuntu/downloadmirrors#alternate
Plug in your usb drive
Unmount the usb drive: type umount /dev/sdb1 (or whatever device your pen drive is).
Type sudo zcat boot.img.gz > /dev/sdb (this will extract the contents of boot.img.gz into the usb stick),
You may get a permission denied message when you try this, if so type: sudo chmod 666 /dev/sdb and then type sudo zcat boot.img.gz > /dev/sdb (it should now work)
Unplug and replug stick. This will cause usb stick to mount automagically. If not, mount it manually.
Copy alternative cd iso onto stick or the root of a partition on the HD of the target machine.
Reboot using usb and enjoy!
[edit] The Slow Method
[edit] Getting the Files
You will need three files for a complete Ubuntu installation: initrd.gz, vmlinuz, and the Ubuntu 8.10 ISO. initrd.gz and vmlinuz must be downloaded from the Ubuntu archives. It is important that you download the files from this address, because these are specific to installing from a USB drive. The Ubuntu 8.10 ISO can be downloaded from the ubuntu site.
[edit] Setting up the USB Drive
Your USB drive will be used to install Ubuntu. If your USB drive is large enough (greater than 610MB), you can store the ISO file, and the entire installation process will occur from your thumb drive. If your USB drive is not large enough, the Ubuntu installer will also look on local hard drives or the network for the Ubuntu ISO.
[edit] Initial Setup
You must first make sure your USB drive is formatted as FAT16. Most likely this is the case. If you wish to re-format anyway to make sure it is setup correctly, the ubuntu archives suggests to "use cfdisk or another partitioning tool for creating a FAT16 partition and then type:"
-
mkdosfs /dev/sda1
|
Note: It is assumed your USB drive is /dev/sda. PLEASE designate the correct device. Running mkdosfs on your main hard drive will erase it! |
[edit] Installing the Bootloader
Once your USB drive is formatted correctly it's time to install the bootloader. We will use syslinux as the bootloader. On your Linux computer, make sure you have the syslinux package installed (it is in the Ubuntu repositories). You also need the package mtools (also in the Ubuntu repositories). Once you have these packages, install syslinux on your USB disk by issuing this command:
-
syslinux /dev/sda1
|
Note: Make sure your USB drive is unmounted before running this command. |
[edit] Copying the files
Now mount your USB drive and copy the initrd.gz, vmlinuz, and ISO files to it. Simply copy the ISO file exactly how it is to your USB drive. You do not need to "burn" it to your USB drive like you would a CD. Also, you need to create a file on your USB drive named syslinux.cfg. This file controls the bootloader and only contains two lines:
default vmlinuz
append initrd=initrd.gz ramdisk_size=10000 root=/dev/rd/0 init=/linuxrc devfs=mount,dall rw
Don't include 'init=/linuxrc' from the above for use with Feisty.
|
Note: The ramdisk_size may need to be increased based on what image you're using. |
Create this file and save it to your USB drive. Setting up your USB drive is now complete.
[edit] Setting up the BIOS
Now that you have a bootable USB drive, you must make your computer boot from it rather than its own hard drive. You can do this one of two ways. If you can access a boot options menu by pressing F8 or F12 shortly after powering on your computer, you can simply choose the USB drive option. If you can't get to that menu, you will have to change the boot order in your BIOS. Enter your BIOS by pressing the delete key or F1 soon after your computer is turned on. Once in the BIOS, look for the bootup sequence menu. You may have to look around a bit. Once you find the menu, change the sequence so that the USB disk is booted prior to the hard disk. After you have installed Ubuntu, you should change it back.
[edit] Booting up and Installing
After you have setup your USB drive and configured your BIOS, you are now ready for installation. Installation from your USB drive will proceed almost exactly as from a CD. The only difference is the Ubuntu installer will eventually ask you where your ISO file resides. After pointing the installer to your ISO file, the installation will proceed as normal. Once Ubuntu is installed, congratulate yourself on a great choice!
[edit] Possible Errors
After taking the necessary steps to setup your USB drive and your BIOS, you may still not be able to boot from it. You may receive an error like "Not a bootable drive." If this occurs, check your USB drive to make sure the partition is flagged as bootable/active. If this does not work, the ubuntu archives states, "If your system refuses to boot from the memory stick, the stick may contain an invalid master boot record (MBR). To fix this, use the install-mbr command from the package mbr:"
- #
install-mbr /dev/sda
|
Note: Again, this is assuming your USB drive is /dev/sda |
Note by Peter: If you do not have the install-mbr tool (which is Debian specific) you could transfer the /dev/sda1 partiton to the beginning of /dev/sda drive. To do that I would usually copy entire /dev/sda1 partiton to a file and then transfer it to /dev/sda:
dd if=/dev/sda1 of=tempfile
dd of=/dev/sda if=tempfile
To make the tempfile smaller I would append the count=N option to the first dd (causing only partial copy) and copy iso files after moving the partition. Number N that worked for me was 40960 on a 700MB partition.
| Navigation: Ubuntu Index |

