[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ A ] [ next ]


Hacking the debian-installer ISO image
Chapter 1 - Before hacking debian-installer


This document is created as my personal reminder. I also neglect all the glory details of debian-installer and all non-i386 architectures for simplicity. I have to confess that my computerml knowledge is quite limited. Thus, use this document with caution.

Please note that the author of this document is not a core developer of debian-installer. If you need to contact the debian-installer developer, contact them at their mailing list: debian-boot.


1.1 Prerequisite

There are few basics to learn before you start hacking debian-installer ISO image. If you are a complete newbie to the Debian system, please read my guide "Debian Reference" :) This is available in debian-reference-en package or links from Debian Reference.

Then you should at least browse through some basic Debian documents listed in Debian Developers' Corner.

For the latest debian-installer specific information, please look into:

Please report debian-installer related bugs to the psudo package installation-reports using Debian Installation Report Template.

If you find any commands used here is missing on your system, please install them yourself in advance. You may automate this by using auto-apt package.

Although many examples are shown to be run from root shell prompt for the simplicity, I actually run commands with sudo or fakeroot from a non-privileged account.


1.2 The debian-installer booting stages

Before we start hacking, let's understand the basics of the debian-installer. There are 3 distinct booting stages for the debian-installer to create a new GNU/Linux system on a hard disk. Following is the simplified flow of incidents for i386 (Linux 2.4 or 2.6 kernels):

Other boot methods differ slightly in implementation but the basics are the same.


1.3 Basics of the bootloader

Here are a list of popular bootloaders:

For more general information, see Linux Boot Loaders Compared.

The ISOLINUX bootloader is used for debian-installer CD. It is available as a part of syslinux package together with SYSLINUX and PXELINUX. Please read details in its documentation.

The use of shell script /sbin/init as the auto-started program and the use of pivot_root command as a means to move root of the running kernel are the special characteristics of the boot loader system.

See Making Bootable Linux CDs, and Timo's Rescue CD Set for more examples for bootloaders and rescue CDs in general.

Also Installing linux from windows, without any CD, floppy, USB-key, nor any other removable media is interesting read.


1.4 What is the initrd?

The initrd is the RAMDISK disk image file. Although CRAMFS is normally used for this purpose on Debian system, the debian-installer uses EXT2 file system and compresses it with gzip. Kernel can directly read this compressed initrd.gz.


1.5 How to hack the disk image file

Here are some basic tips for the manipulation of the disk image file.


1.5.1 Formating the floppy disk image

The formatted disk image file can be made using loop device. For example, formatted 2880 KiB MSDOS floppy image can be made:

     # dd if=/dev/zero of=imagefile0 bs=$((2880*1024)) count=1
     ...
     # losetup /dev/loop0 imagefile0
     # mkfs -t msdos -v -F12 -S512 /dev/loop0
     mkfs.msdos 2.10 (22 Sep 2003)
     /dev/loop0 has 2 heads and 18 sectors per track,
     logical sector size is 512,
     using 0xf0 media descriptor, with 5760 sectors;
     file system has 2 12-bit FATs and 2 sectors per cluster.
     FAT size is 9 sectors, and provides 2863 clusters.
     Root directory contains 224 slots.
     Volume ID is 40d73f42, no volume label.
     # losetup -d /dev/loop0

1.5.2 Formating the hard disk disk image

Formated 10 MiB EXT2 hard disk image can be made with a single small text file in it:

     # dd if=/dev/zero of=imagefile1 bs=1024 count=$((10*1024))
     ...
     # losetup /dev/loop1 imagefile1
     # mkfs -t ext2 -v /dev/loop1
     ...
     Block size=1024 (log=0)
     Fragment size=1024 (log=0)
     2560 inodes, 10240 blocks
     512 blocks (5.00%) reserved for the super user
     ...
     # mount -t ext2 /dev/loop1 /mnt/imagemnt1
     # cd /mnt/imagemnt1
     # echo "Hello small file" >small_file
     # cd /mnt
     # umount /dev/loop1
     # losetup -d /dev/loop1

1.5.3 Mounting the hard disk image

These formatted disk image files can be directly mounted to the file system and contents can be modified.

     # mount -t ext2 imagefile1 /mnt/imagemnt1
     # cd /mnt/imagemnt1
     # vim small_file
     ... edit and :wq
     # cd /mnt
     # umount /mnt/imagemnt1

1.5.4 Checking the size of the hard disk image

The information and free space in the disk image files can be obtained with the same tool as the normal file system. For example:

     # ls -l imagefile1
     ... External file size of the disk image
     # tune2fs -l imagefile1 |less
     ... Abstract information in blocks
     # mount -t ext2 -o loop imagefile1 /mnt/imagemnt1
     # df -h | grep imagefile1
     ... Easy to read file usage in the disk image
     # umount imagefile1

If you want to get an idea on the disk size needed for the tree /some/where, run following first:

     # du -hs /some/where

1.5.5 Resizing the hard disk image

These formatted disk image files can be resized. For example, expanding 5 MiB:

     # ls -l imagefile1
     -rw-r--r--  1 root  root 10485760 2004-06-22 19:38 imagefile1
     # dd if=/dev/zero of=imagefile1 bs=1 seek=10485760 count=$((5*1024*1024))
     # losetup /dev/loop1 imagefile1
     # resize2fs /dev/loop2
     ...
     # tune2fs -l /dev/loop2 | less
     ... 
     # losetup -d /dev/loop2

See mount(8).


[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ A ] [ next ]


Hacking the debian-installer ISO image

20th of June, 2004

Osamu Aoki osamu@debian.org