Debian GNU/Linux Installation with Knoppix and debootstrap

Because Debian GNU/Linux 3.0 is a little bit old, it can happen that newer hardware isn't supported by the woody installer. That's bad, at least when you want to install Debian on a harddisk which is connected on a not supported controller.

There are a few ways to workaround this:

I think the last one is the easiest way, that's why I use this way to install Debian on newer hardware.

What you need is just a Knoppix CD and a possibility to access a Debian mirror from the machine. Insert the Knoppix CD, and boot the machine. Knoppix should detect your hardware automatically.

After the machine has successfully booted, check the partitions on your harddisk(s) with fdisk.

knoppix# fdisk -l

Disk /dev/sda: 18.2 GB, 18200739840 bytes
255 heads, 63 sectors/track, 2212 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/sdb: 18.2 GB, 18200739840 bytes
255 heads, 63 sectors/track, 2212 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
knoppix#
Create a new partition (or more), a swap partition and make the / partition bootable.
knoppix# fdisk /dev/sda

The number of cylinders for this disk is set to 2212.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2212, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2212, default 2212): +2048M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (251-2212, default 251): 
Using default value 251
Last cylinder or +size or +sizeM or +sizeK (251-2212, default 2212): +512M

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 82
Changed system type of partition 2 to 82 (Linux swap)

Command (m for help): a
Partition number (1-4): 1

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
knoppix#
Then create a filesystem on the partition(s) and set up the swap area.
knoppix# mkfs.ext3 /dev/sda1 
mke2fs 1.35-WIP (21-Aug-2003)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1038336 inodes, 2074393 blocks
103719 blocks (5.00%) reserved for the super user
First data block=0
64 block groups
32768 blocks per group, 32768 fragments per group
16224 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
knoppix# mkswap /dev/sda2
Setting up swapspace version 1, size = 8496709 kB
knoppix#
Mount the new / partition to /mnt and install the base system with debootstrap.
knoppix# mount /dev/sda1 /mnt
knoppix# debootstrap woody /mnt http://source.rfc822.org/debian
[...]
I: Base system installed successfully.
knoppix#
After debootstrap has finished, enter the just installed base system and run base-config to set up some basic configurations.
knoppix# chroot /mnt
chroot# base-config
[...]
If this step is finished, stay in the chroot, and copy /usr/share/doc/lilo/examples/conf.sample to /etc/lilo.conf and modify it so it fits your needs.
# /etc/lilo.conf: Sample LILO boot loader configuration.

boot=/dev/sda1
root=/dev/sda1
compact
install=/boot/boot.b
map=/boot/map
vga=normal
delay=20
image=/vmlinuz
        root=/dev/sda1
        label=Linux
        initrd=/initrd.img
        read-only
Then install the package mkinitrd-tools and modify /etc/mkinitrd/mkinitrd.conf so $ROOT points to your new root partition (autodetection will fail in chroot). These steps are only required if you want to use one of the Debian kernel-images.
chroot# apt-get install initrd-tools
Reading Package Lists...
Building Dependency Tree...
The following extra packages will be installed:
  ash cramfsprogs zlib1g 
The following NEW packages will be installed:
  ash cramfsprogs initrd-tools zlib1g 
0 packages upgraded, 4 newly installed, 0 to remove and 1  not upgraded.
Need to get 150kB of archives. After unpacking 512kB will be used.
Do you want to continue? [Y/n] 
Get:1 http://ftp.de.debian.org stable/main ash 0.3.8-37 [71.6kB]
Get:2 http://ftp.de.debian.org stable/main zlib1g 1:1.1.4-1.0woody0 [44.1kB]
Get:3 http://ftp.de.debian.org stable/main cramfsprogs 1.1-3 [19.1kB]
Get:4 http://ftp.de.debian.org stable/main initrd-tools 0.1.32woody.3 [15.1kB]
Fetched 150kB in 0s (807kB/s)
Preconfiguring packages ...
Selecting previously deselected package ash.
(Reading database ... 6065 files and directories currently installed.)
Unpacking ash (from .../archives/ash_0.3.8-37_i386.deb) ...
Unpacking zlib1g (from .../zlib1g_1%3a1.1.4-1.0woody0_i386.deb) ...
Selecting previously deselected package cramfsprogs.
Unpacking cramfsprogs (from .../cramfsprogs_1.1-3_i386.deb) ...
Selecting previously deselected package initrd-tools.
Unpacking initrd-tools (from .../initrd-tools_0.1.32woody.3_all.deb) ...
Setting up ash (0.3.8-37) ...

Setting up zlib1g (1.1.4-1.0woody0) ...

Setting up cramfsprogs (1.1-3) ...

Setting up initrd-tools (0.1.32woody.3) ...

chroot#
# /etc/mkinitrd/mkinitrd.conf:
#  Configuration file for mkinitrd(8).  See mkinitrd.conf(5).
#
# This file is meant to be parsed as a shell script.

# What modules to install.
MODULES=most

# The length (in seconds) of the startup delay during which linuxrc may be
# interrupted.
DELAY=0

# If this is set to probe mkinitrd will try to figure out what's needed to
# mount the root file system.  This is equivalent to the old PROBE=on setting.
ROOT=/dev/sda1

# This controls the permission of the resulting initrd image.
UMASK=022

# Command to generate the initrd image.
MKIMAGE='mkcramfs %s %s > /dev/null'
If this is done, mount /proc and install a kernel image (kernel-image-2.4.18-foo, where foo in 386, 586tsc, 686, 686-smp, k6, k7, k7-smp) with apt-get, If you prefer a more up to date kernel, you can also use a self-compiled kernel or a kernel from backports.org (you need to add an additional line to your sources.list in this case, see below).
chroot# mount /proc /proc -t proc
chroot# apt-get install kernel-image-2.4.18-686                                  
Reading Package Lists...                                                            
Building Dependency Tree...                                                         
The following NEW packages will be installed:
  kernel-image-2.4.18-686 
0 packages upgraded, 1 newly installed, 0 to remove and 1  not upgraded.
Need to get 8696kB of archives. After unpacking 23.8MB will be used.
Get:1 http://ftp.de.debian.org stable/main kernel-image-2.4.18-686 2.4.18-5 [8696kB]
Fetched 8696kB in 2s (3938kB/s)
Selecting previously deselected package kernel-image-2.4.18-686.
(Reading database ... 6104 files and directories currently installed.)
Unpacking kernel-image-2.4.18-686 (from .../kernel-image-2.4.18-686_2.4.18-5_i386.deb) ...

You are attempting to install an initrd kernel image (version 2.4.18-686)
This will not work unless you have configured your boot loader to use
initrd. (An initrd image is a kernel image that expects to use an INITial 
Ram Disk to mount a minimal root file system into RAM and use that for
booting).
As a reminder, in order to configure lilo, you need to
add an 'initrd=/initrd.img' to the image=/vmlinuz
stanza of your /etc/lilo.conf
I repeat, You need to configure your boot loader. If you have already done
so, and you wish to get rid of this message, please put
  `do_initrd = Yes'
in /etc/kernel-img.conf. Note that this is optional, but if you do not, 
you'll contitnue to see this message whenever you install a kernel 
image using initrd.
Do you want to stop now? [Y/n]n
Setting up kernel-image-2.4.18-686 (2.4.18-5) ...
/boot/initrd.img does not exist. Installing from scratch, eh?
Or maybe you don't want a symbolic link here. Hmm? Lets See.
I notice that you do not have initrd.img symbolic
link. I can create one for you, and it shall be
updated by newer kernel image packages. This is
useful if you use a boot loader like lilo.
Do you want me to create a link from /boot/initrd.img-2.4.18-686 to initrd.img?[Yn] 
/vmlinuz does not exist. Installing from scratch, eh?
Or maybe you don't want a symbolic link here. Hmm? Lets See.
Could not find where the current root file system is mounted!
Please make some arrangements for your system to boot the new
kernel (like running LILO, loadlin, SILO, QUIK, VMELILO, or  
getting a boot floppy).                                      
Please hit return to continue.                               
chroot#
If you want to install a more recent kernel, add the following line to your sources.list:
deb http://www.backports.org/debian woody kernel-image-2.4.26-i386
Then install kernel-image-2.4.26-1-foo as shown above. Don't panic if apt tells you that some packages (initrd-tools and modutils) will be updated, they are required for the newer kernel images.

The last things you have to do is to fill /etc/hosts, /etc/resolv.conf, /etc/modules, /etc/fstab and /etc/network/interfaces with adequate values. You can use and modify the files from your running Knoppix.

# /etc/hosts
127.0.0.1       localhost
192.168.1.2		rollcage.inittab.de		rollcage
# /etc/fstab
/dev/sda1       /               ext3    errors=remount-ro       0       1
proc            /proc           proc    defaults                0       0
# /etc/resolv.conf
search inittab.de
nameserver 192.168.1.1
# /etc/modules: kernel modules to load at boot time.
#
# This file should contain the names of kernel modules that are
# to be loaded at boot time, one per line.  Comments begin with
# a "#", and everything on the line after them are ignored.
tulip
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

# The loopback interface
auto lo
iface lo inet loopback

# The first network card - this entry was created during the Debian installation
# (network, broadcast and gateway are optional)
auto eth0
iface eth0 inet static
        address 192.168.1.2
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.254
Don't forget to add the initrd to lilo.conf and run lilo again before leaving the chroot.

That's all. Now you can exit the chroot, reboot the machine, and remove the Knoppix CD.

chroot# exit
knoppix# umount /mnt/proc
knoppix# umount /mnt
knoppix# reboot
Thanks to Sebastian Muszynski, Sven Hoexter and Goswin Brederlow for their feedback.
Norbert Tretkowski
Last modified: 2004/05/04 22:04:05