Diskless Boot a Linux System (Debian)

 
In order to boot a Linux system disklessly from a server on your local network, these steps outline the necessary steps. Beware that this is just a brain dump. This documentation is not intended to be fool proof nor is it a copy’n paste howto. It just gives an oversimplified guide to the process.

Configure and build grub

First, grub has to be built supporting network boot with a couple of network drivers (pxegrub). Therefore, a patch from http://os.inf.tu-dresden.de/~adam/grub/0.97/ needs to be applied to grub’s source. Then, the build process can be done with the following shell script:

#!/bin/bash
export CC=gcc-3.4
for i in 3c90x e1000 eepro100 pcnet32 rtl8139 r8169 tg3; do
        make clean
        ./configure --enable-diskless --enable-pxe --enable-$i
        make
        cp stage2/pxegrub /boot/pxe-boot/pxegrub/pxegrub.$i
done

make clean
./configure --enable-diskless --enable-pxe --enable-3c90x \\
       --enable-e1000 --enable-tg3 --enable-pcnet32
make
cp stage2/pxegrub /boot/pxe-boot/pxegrub/pxegrub.3c90x_e1000_tg3_pcnet32

Kernel build process

Now, a new kernel has to be compiled. Therefore, get the most recent kernel from http://www.kernel.org. Unpack and configure with IP: kernel level autoconfiguration = YES and IP: DHCP support from networking options and nfs from filesystem options.

Compilation is done by

make && make modules && make modules_install

or on AMD64 systems by

make ARCH=x86_64 menuconfig && make ARCH=x86_64 && make ARCH=x86_64 modules && make ARCH=x86_64 modules_install

Now, arch/i386/boot/bzImage can be taken as the new kernel.

Build new initramfs

Edit /etc/initramfs-tools/initramfs.conf to suit the netboot purpose:

MODULES=netboot
BOOT=nfs
NFSROOT=auto

Execute mkinitramfs -o initrd-netboot.img /lib/modules/<kernel_version>

Now, put the new initrd-netboot.img and bzImage into pxegrub’s menu.lst.

Preparation of the boot image

The debian package debootstrap help prepping the network boot image, but it need to be installed first:

aptitude install debootstrap

Now, the following line creates a fully functional boot image:

debootstrap --include=nfsbooted,dhcp3-client,procps,passwd,vim,\
                      less,configure-debian,udev,console-common \
            lenny . http://ftp.de.debian.org/debian/

A few customisations and then it’s done:

  • edit etc/hostname to your needs
  • create a valid hosts file: cp /etc/hosts etc/hosts
  • change root password by using chroot .
  • copy modules into new root: cp -a /lib/modules/<netboot_kernel_version> lib/modules/
  • boot!
  • Inside the new system: aptitude update && aptitude install openssh-server common-keymap && configure-debian --all

Leave a Comment