[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ A ] [ next ]
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.
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:
Links from debian-installer
(make sure to look down to the bottom of the page)
Document
files in surversion repository as a part of alioth archive
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.
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):
Stage 1: booting initial system from CD
"El Torito" bootable CD format is loaded to PC.
Upon power-on, BIOS reads ISOLINUX bootloader on CD.
ISOLINUX reads CD and understanding ISO format.
ISOLINUX finds vmlinuz/initrd combination.
ISOLINUX presents multiboot options to the user.
ISOLINUX starts selected Linux kernel vmlinuz while copying
initrd to its RAMDISK (/dev/rd/0).
The GNU/Linux system is running its root filesystem on the RAMDISK.
Linux kernel execute the shell script /sbin/init in the RAMDISK
automatically.
copy the root file system in RAMDISK to tmpfs (2.4 ?) or shm (2.6 POSIX ?) to create a new root file system.
replace /sbin/init in the new root file system with
init from busybox.
pivot_root into the new root file system.
init from busybox in the new root file system parses
/etc/inittab.
run /etc/init.d/pcmcia to initialize PCMCIA.
run /etc/init.d/rcS which runs scrips in
/etc/rcS.d/S[0-9][0-9]* to di more initialization.
run debian-installer which runs scrips in
/lib/debian-installer.d/S[0-9][0-9]*.
CD is auto-detected and mounted to /cdrom.
USB stick, floppy disk, hard disk, network (DHCP), etc. are initialized and functional.
Do chore :)
Start menu with newt front end by practically running:
DEBIAN_FRONTEND=newt
export DEBIAN_FRONTEND
exec /usr/bin/debconf -o d-i /usr/bin/main-menu
Main menu is ordered using "installer-menu-item: nnn" entries in the
udeb's debian/control file. These will be gathered in
/var/lib/dpkg/status. (XXX Need to verify XXX)
prebaseconfig is run.
Selected items run in turn.
Stage 2: Main part of the installation.
get udeb packages and install them to the RAMDISK to expand debian-installer capabilities as needed from CD or from the Internet.
install a new minimum GNU/Linux system to the hard disk mounted on
/target using deb packages from CD or from the
Internet.
install bootloader GRUB on the hard disk.
reboot to enable the newly created minimum GNU/Linux system on the hard disk.
Stage 3: Configure the newly created system.
Configure the newly created minimum GNU/Linux system.
Add more deb packages from CD or from the Internet.
Configure the newly created GNU/Linux system.
Other boot methods differ slightly in implementation but the basics are the same.
Here are a list of popular bootloaders:
SYSLINUX: Floppy, CD, Net
boot.
Loadlin: DOS boot
Lilo: Smaller Linux MBR
GRUB: The big MBR
for everything
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.
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.
Here are some basic tips for the manipulation of the disk image file.
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
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
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
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
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, 2004osamu@debian.org