Install Ubuntu (alternate) from USB drive
Since unetbootin and usb-creator were not working for me I created my own bootable USB image from the alternate Ubuntu iso.
I tried this with desktop and alternate installer of Ubuntu 9.04 (Jaunty Jackalope) amd64.
The following tutorial is based on information from Overclockers Australia Forums and launchpad.
Creating the bootable memory stick
- Plug in your USB flash memory stick
- Open up a terminal window
- Type in
$ sudo fdisk -l
...and you will get something similar to the following for each physical storage device on your PC:Disk /dev/sdb: 2063 MB, 2063335424 bytes 255 heads, 63 sectors/track, 250 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x000d4ddc Device Boot Start End Blocks Id System /dev/sdb1 * 1 250 771088+ 6 FAT16 $This is a 2GB USB flash drive. It is mounted as /dev/sdb and has one partitions: /dev/sdb1.
You don't have to partition your stick but you may. NOTE: If you already have a hard-drive called SDB then your USB stick will appear with a different name, eg: SDC, SDD, etc etc. Make a note of it and substitute in this guide as necessary. - In the case of your fresh, unused USB stick, it will only have one partition, will be formatted to FAT16 or FAT32 and generally will not be bootable.
- We need to make the stick bootable, so first unmount it (but leave it plugged in) with:
$ sudo umount /dev/sdb1
(Repeat the above command for every partition on your stick only.) - Now type in:
$ sudo fdisk /dev/sdb
...and you will be presented with the FDISK command prompt, to perform operations on your USB stick at /dev/sdb. - Press "P" and hit enter. Your partitions will be listed. You will note there is a "Boot" column which should be empty. If the first partition shows an asterisk "*" in this column, then your stick is already bootable and you can skip to Step 11.
- Press the letter "A" on your keyboard and hit enter to set the Bootable Flag.
- You will be prompted for a partition number. Enter "1" and hit enter.
- Now type in "P" and hit enter. This will re-list the partitions on your USB stick. You should now see that the first (or only) partition now has an asterisk "*" next to it in the "Boot" column. If it does NOT have the asterisk shown, then repeat the "A" command again because it acts as a toggle - your stick might have already been made bootable and you've just made it unbootable.
- Now type in "W" and hit enter to write your changes to the USB stick and exit FDISK. Your USB stick should be automatically re-mounted at this time. If not, just unplug it and re-insert it.
- Now we need some extra software to complete the basic setup of your USB stick:
$ sudo apt-get install syslinux mtools
- When available, type:
$ sudo syslinux -sf /dev/sdb1
...which will install the bootloader needed for your USB stick to boot from. - Now we will copy the LiveCD. If you use a burnt-on-disc version, insert it now, otherwise if you have the downloaded ISO, then mount it with the following commands:
$ mkdir /mnt/livecd $ cd /path/to/my/downloaded/iso $ sudo mount -o loop ubuntu-8.04-alternate-amd64.iso /mnt/livecd
...the above commands will mount the ISO to your RAM disk in the directory called "livecd". - Change over to the content of the disc with:
$ cd /media/cdrom
...or for ISO users, switch to the mountpoint:$ cd /mnt/livecd
- Now begin the actual copy process with:
$ sudo cp -rfv casper disctree dists install pics pool preseed .disk isolinux/* md5sum.txt README.diskdefines ubuntu.ico casper/vmlinuz casper/initrd.gz /media/ubuntulive/
This copies everything off the disc/ISO except for the MS Windows related stuff to your USB stick. This may take a minute or two. IGNORE THE SYMLINK AND STAT ERRORS that are returned from the cp command. - We're nearly there! One last thing to do and that is to convert the startup from ISOLINUX (for CD's) to SYSLINUX (for storage devices like hard-drives and your USB stick):
$ cd /media/ubuntulive $ cp isolinux.cfg syslinux.cfg $ cp isolinux.txt syslinux.txt
- Your Ubuntu LiveUSB stick is ready. More details are to be found at the originate tutorial as mentioned above.
Working around the "missing cdrom" issue during install
As we copied all files from the cd-installer there is a problem with one of the scripts, which looks for package sources.
If you run into problems (this might be fixed by now), switch to another bash and apply the following patch at /var/lib/dpkg/info/...
The bug report is located at https://bugs.launchpad.net/ubuntu/hardy/+source/usb-creator/+bug/234185, the patch is:
--- initrd-org/var/lib/dpkg/info/cdrom-detect.postinst 2008-05-21 19:11:52.000000000 -0400 +++ initrd/var/lib/dpkg/info/cdrom-detect.postinst 2008-05-21 18:20:48.000000000 -0400 @@ -32,9 +32,10 @@ do mounted=0 - devices="$(list-devices cd; list-devices maybe-usb-floppy)" + devices="$(list-devices cd; list-devices partition; list-devices maybe-usb-floppy)" for device in $devices; do - if mount -t iso9660 -o ro,exec $device /cdrom; then + if mount -t iso9660 -o ro,exec $device /cdrom || \ + mount -t vfat -o ro,exec $device /cdrom ; then log "CD-ROM mount succeeded: device=$device" mounted=1 db_set cdrom-detect/cdrom_device $device
September 25th, 2009