Sunday, June 17, 2007

Installing a Linux distro without the need of an external media


Let me start by introducing the booting process in general.

When a computer boots, and has finished checking the integrity of the attached devices, the BIOS looks for the first sector of the media, hoping to find some executable that will takeover from there. Usually this executable is a kernel, or sometimes a bootloader. This kernel or bootloader can be located in different types of media, like CD drive, a hard disk partition, network server or a USB flash memory device. As long as it's located in the first sector, we're fine.

The idea is to create a small partition in the hard disk itself and make it act like a boot/installer disk. Since Linux distros come with a plethora of partitioning and mounting tools, if you already have an existing usable Linux installation in the same hard disk, and have a few hundred megs of hard disk space to spare (Depending on the size of the installer), things become really easy.

Basic outline (assumes a working Linux installation, from where the following steps would be carried out):

  • Download the installer ISO of the distro you intend to install.
  • Mount the installer ISO on a temporary directory
  • Create a new partition that would be used as bootdisk/installer disk, preferably in ext2 format. Let's call it "installer partition"
  • Copy the contents of the ISO from the temporary directory to the installer partition.
  • Update your grub by adding a new entry that points to the installer partition.
  • Reboot and boot from the installer partition
Additional notes:
1. Mounting the installer ISO on a temporary directory
Login as root (or do sudo)
Create a temporary directory /mnt/installcd
mkdir /mnt/installcd
Mount the iso file
mount -t iso9660 -o ro,loop=/dev/loop0 installer.iso /mnt/installcd
Where installer.iso is the installer ISO (Duh :P )

Now, you mount the installer partition to another directory /mnt/installpart
mount -t ext2 /dev/hdax /mnt/installpart
where /dev/hdax is your installer partition.

Copy the contents of the CD to installer partition
cp -rp /mnt/installcd/* /mnt/installpart

Now your installer partition has all the media needed to boot/install your new operating system.

The finale:
Now, all you need to do is to make an entry in your GRUB pointing to the boot partition.

Will update this section soon.

No comments: