The Home of C&P Software on the Web

Home
Blogs
About us
Why Choose Us?
What Are People saying?
OneClickAway PC Support
Professional Profile
Free Software here!!!
Contact Us
Privacy Notice
Useful Links
NLP

Creating an Ubuntu installer USB stick

1. Prepare the USB stick This assumes that you have a working machine on which to mount the stick. All operations should be run as su or sudo.

  1. Plug it in and determine the device either by typing “mount” or looking at “tail /var/log/syslog”. The device is pretty likely to be “/dev/sda”.
  2. Run fdisk: “fdisk /dev/sda”.
  3. Type “p” to see existing partitions. Type “d” and select partition numbers until all existing partitions are gone.
  4. Type “n” to create a new partition. Accept the defaults (”enter” twice for one partition on the whole stick).
  5. Type “t” for the partition type and “6? for FAT16.
  6. Type “a” to toggle the flag of the partition to bootable.
  7. Type “w” to write the partition and exit.
  8. Now create the FAT16 filesystem using “mkdosfs /dev/sda1?.
  9. “sudo apt-get install mbr” if you don’t have it
  10. Add a master boot record to the stick: “install-mbr /dev/sda”.

You should now have a bootable stick with a single FAT16 partition (/dev/sda1).

2. Add GRUB bootloader to the stick Mount the stick again. We’re assuming that the mount point is /media/usbdisk.

  1. Create /boot/grub on the stick: “mkdir -p /media/usbdisk/boot/grub”.
  2. Copy over grub files: “cp /lib/grub/i386-pc/* /media/usbdisk/boot/grub/”.
  3. Create grub device map: ‘echo “(hd0) /dev/sda” > /media/usbdisk/boot/grub/device.map’.
  4. Install grub to the stick: “grub-install ––root-directory=/media/usbdisk /dev/sda”.

Now use an editor (e.g. nano) to open /media/usbdisk/boot/grub/menu.lst and add these lines:

title           Ubuntu
root            (hd0,0)
kernel          /vmlinuz root=/dev/rd/0 /init=/linuxrc rw
initrd          /initrd.gz
boot

You can also add a “ramdisk_size=” parameter to the kernel line. These lines tell grub which files to use when booting. We don’t have these files yet, so…

3. Copy required files to stick

  1. Head over to http://archive.ubuntu.com/ubuntu/dists/dapper/main/installer-i386/current/images/hd-media/ (or the appropriate directory for your distro and architecture).
  2. Grab the files “boot.img.gz”, “vmlinuz”, “initrd.gz” and copy to the root directory of the stick.
  3. Finally, get yourself any Ubuntu ISO image. If your stick is 1 GB or larger, the normal installer images (something like ubuntu-6.06-alternate-i386.iso) will fit just fine.

4. Boot and install You’re ready to go. You might have to enter the BIOS to make sure that your machine can boot from a USB device and change the boot order. My BIOS has a “USB-HDD” option which works for sticks - this is quite common, but there are variations. In theory the machine will now boot from your stick, GRUB will start up, find the kernel and ramdisk images, locate the ISO and the installer will run as it would from a CD.