Monday, November 27, 2006

Ubuntu HOW-TO : Ubuntu Edgy from USB

Last revision : February 18th, 2007

Perhaps you've run into this situation before : what to do with a machine that has no CD reader ? Or maybe you have simply no mean of getting your hands on a Ubuntu CD ?

Now you can install Ubuntu Edgy (or any other Ubuntu version) on it using a USB key as small as 64 mb.

Debian users had a method for installing from USB that worked very well (here it is). But this it new to Ubuntu.

Here is how to do it.


  • Prerequisites


You'll need a USB key (of at least 64mb). Beware that all previous data on this key will be lost.

Then you have to install some packages.

sudo apt-get install lilo dosfstools util-linux syslinux mtools


A word of caution :

Yes, we install lilo, but there is no harm in doing that, we'll only use it on the USB key : so do not follow lilo's instructions (otherwise it will overwrite GRUB and install itself on the MBR).

Now plug in the USB stick and issue that command :

dmesg | grep -C6 "USB Mass Storage"


Which should output something like that :

[17182459.364000] usb 5-7: new high speed USB device using ehci_hcd and address 5
[17182459.576000] Initializing USB Mass Storage driver...
[17182459.576000] scsi4 : SCSI emulation for USB Mass Storage devices
[17182459.576000] usb-storage: device found at 5
[17182459.576000] usb-storage: waiting for device to settle before scanning
[17182459.576000] usbcore: registered new driver usb-storage
[17182459.576000] USB Mass Storage support registered.
[17182464.580000] Vendor: Flash Model: Drive UT_USB20 Rev: 0.00
[17182464.580000] Type: Direct-Access ANSI SCSI revision: 02
[17182464.580000] SCSI device sdb: 128000 512-byte hdwr sectors (66 MB)
[17182464.580000] sdb: Write Protect is off
[17182464.580000] sdb: Mode Sense: 00 00 00 00
[17182464.580000] sdb: assuming drive cache: write through


In this case, that means /dev/sdb is the USB key, which is the one I'll be using from now on.


  • Preparing the USB key


First make sure that the key is unmounted :

sudo umount /dev/sdb


Then partition the USB stick :

sudo cfdisk /dev/sdb


Make one primary partition, which includes the whole drive. This partition must be made bootable, and must be of type FAT16 (so type 06 in cfdisk). In the end, don't forget to write those changes to disk !

Finally you must format the drive in FAT16 :

sudo mkdosfs -n "Edgy" /dev/sdb1



  • Putting the Edgy installer on the USB key


Actually putting an Edgy installer on the USB stick can be done following these steps .

First, download the installer :

wget http://us.archive.ubuntu.com/ubuntu/dists/edgy/main/installer-i386/current/images/netboot/boot.img.gz

Of course, you can replace edgy with any other Ubuntu version, like the upcoming feisty for example (by downloading this installer instead).

Then you can proceed with the rest and uncompress the installer on the USB key :

gunzip boot.img.gz
sudo mount -o loop boot.img /mnt
sudo mount /dev/sdb1 /media/Edgy
sudo cp -r /mnt/* /media/Edgy/
sudo umount /dev/sdb1
sudo syslinux /dev/sdb1
sudo lilo -M /dev/sdb mbr


That's it !

Now you simply have to boot from that USB key, and you are good to go.

My source :
http://ubuntuforums.org/showthread.php?p=1827836

7 comments:

Anonymous said...

sudo lilo -M /dev/sdb1 mbr

should be

sudo lilo -M /dev/sdb mbr

Hugues said...

You are completely right. My bad, it is corrected now.

Thanks,

Hugues

ildella said...

Hi. I am following your instructions to put a feisty boot image on an ipod. My ipod is already partitioned with a linux partition (I have put on it iPodLinux and Rockbox). I have created a new FAT16 partition and copied on it the uncompressed image files. I am at the point to give the last command:

sudo lilo -M /dev/sdb mbr

but I am wondering about that "mbr" option. It is no problem on a dedicated key but I do not want that lilo becomes the main bootloader cause I already have my own one on the first ipod partition.

Does the mbr options overwrite ipod mbr?
If so, is there a chance to use the /dev/sdb4 partition to boot? I do not think so...

Thanks.

Hugues said...

Hi ildella,

I tried Rockbox in the past and really enjoyed it. As for iPodLinux, I don't have much experience with it.

I know that with Rockbox you can reinstall the boot loader quite easily. I do believe (as you mentioned) that you have no choice but to let lilo overwrite the MBR (if you want the Ubuntu installer to be functional).

There is always the possibility that I am wrong. I guess you can ask Google, as it knows more about those things then I do.

Thank you for your comment,

Hugues

Nicholas said...

This installs the complete Feisty disc?

Hugues said...

Hi Nicholas,

This method provides a "netinstaller". So only the basic packages are on the USB key. The rest is downloaded from the Internet has the installation takes place.

It is an excellent system if you have a fast and reliable Internet connection.

Thank you for your commnent,

Hugues

kuhlmann said...

For a simple way to create a bootable USB stick for the full Ubuntu ISO install (not netinstall), try alternative 1 here:
https://help.ubuntu.com/community/Installation/FromUSBStick

Worked great for me with Hardy.