March 27, 2007 Archives

27-03-2007 07:22

How to bootstrap Ubuntu

Originally from http://nsaunders.wordpress.com/2006/11/06/a-usb-stick-grub-and-ubuntu/

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.

  • 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".
  • Run fdisk: "fdisk /dev/sda".
  • Type "p" to see existing partitions. Type "d" and select partition numbers until all existing partitions are gone.
  • Type "n" to create a new partition. Accept the defaults ("enter" twice for one partition on the whole stick).
  • Type "t" for the partition type and "6" for FAT16.
  • Type "a" to toggle the flag of the partition to bootable.
  • Type "w" to write the partition and exit.
  • Now create the FAT16 filesystem using "mkdosfs /dev/sda1".
  • "sudo apt-get install mbr" if you don't have it.
  • 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.

  • Create /boot/grub on the stick: "mkdir -p /media/usbdisk/boot/grub".
  • Copy over grub files: "cp /lib/grub/i386-pc/* /media/usbdisk/boot/grub/".
  • Create grub device map: 'echo "(hd0) /dev/sda" > /media/usbdisk/boot/grub/device.map'.
  • 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

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. These instructions derived in large part from Rene Mayrhofer.

Well there you have it folks. Alhough my attempt at this works for the booting part, but fails when looking for and iso image. Not sure why. Back to google...


Posted by DaveQB | Permanent Link