Showing posts with label Debian. Show all posts
Showing posts with label Debian. Show all posts

Wednesday, 8 September 2010

Creating Debian USB Installer

Prerequisites:

An already insalled and working linux distribution. My laptop already had Fedora Core 10.

Target OS

Debian Lenny 5.0.1 was used for this purpose. It can be downloaded fromhttp://cdimage.debian.org/debian-cd/5.0.1/i386/bt-dvd/

We also need a different installer kernel and initrd image as we will be installing from USB. In this case hd-image installers will be used. vmlinuz and initrd for hd-image installes can be downloaded from http://http.us.debian.org/debian/dists/lenny/main/installer-i386/current/images/hd-media/. It is very important to have correct installer image for a distribution.

Preparing USB disk:

We will create an ext2 partition with fdisk command. USB disk device name can be found from dmesg command output. Create a single partition on USB disk and make it bootable. All these activities are performed using fdisk commands. So if USB disk is called as /dev/sdb , it will have one partition as /dev/sdb1

Copy the required grub files to USB stick:
mount /dev/sdb1 /mnt
mkdir -p /mnt/boot/grub
cp /boot/grub/* /mnt/boot/grub
Copy the downloaded hd-media installer image and iso files to USB stick:
cp /home/test/Download/{vmlinuz,initrd.gz} /mnt
cp /home/test/debian-501-i386-DVD-1.iso /mnt
Configure and Install Grub:
Edit /mnt/boot/grub/menu.lst to have following contents only.
title USB Installer
root (hd0,0)
kernel /vmlinuz rootdelay=10
initrd /initrd.gz

It is important to have rootdelay option other wise installer will not kick off. This is required because USB flash drives take a bit longer to be prepared.

Now Install the grub bootloader to USB disk.
# grub
grub> device (hd0) /dev/sdb
grub> root (hd0,0)
grub> setup (hd0)
Thats it. Boot the system from USB disk.