User:BrianShowalter/Using customized kernels with FAI

From FAIWiki

Jump to: navigation, search

There may be times when a customized kernel is needed both for the initial boot done as part of the install process, and for booting the client after the install is complete. Such situations would most likely occur when dealing with hardware that requires drivers which are not configured or included in the stock FAI kernel packages. In that case, and when an NFS-mounted root is used for the initial install, it is necessary to configure and build two separate kernel packages. The first kernel must be configured to mount the root filesystem via NFS (CONFIG_ROOT_NFS flag) and must also have the network device driver compiled into the kernel. The second kernel must have the CONFIG_ROOT_NFS flag turned off and the hardware and filesystem drivers for the root filesystem compiled into the kernel.

Since I installed FAI from the Debian packages and not from source, this tutorial will be focusing on files in the /usr/share/fai tree. Other installations may have the same files under the /usr/local/share/fai tree. Use whichever is appropriate for your situation.

Preparation

Compiling a new kernel package requires that kernel-package be installed so that the make-kpkg command will be available. Installing a custom kernel as the client's primary boot kernel also requires that dpkg-dev be installed so that the dpkg-scanpackages command will be available. If either one of these is not present, then you'll need to install them as follows:

 # apt-get update
 # apt-get install kernel-package
 # apt-get install dpkg-dev

Let's assume that you want to install and configure a custom 2.6.12 kernel for use with FAI.

 # apt-get update
 # apt-get install linux-source-2.6.12
 # cd /usr/src
 # tar -xjvf linux-source-2.6.12.tar.bz2
 # ln -s linux-source-2.6.12 linux
 # cd linux

Creating the FAI install kernel

You can save some time by using a kernel configuration from the fai-kernels package as a template for configuring the new kernel, as follows:

 # zcat /usr/share/doc/fai-kernels/config-2.6.14.gz > .config
 # make menuconfig

Make sure that the "Root file system on NFS" option is set to "Y", that DHCP and/or BOOTP support is set to "Y", and that your NIC's driver is set to be compiled into the kernel (not set as a module). You can check those options by typing:

 # grep CONFIG_ROOT_NFS .config
 CONFIG_ROOT_NFS=y
 # grep CONFIG_IP_PNP_DHCP .config
 CONFIG_IP_PNP_DHCP=y
 # grep 8139TOO .config (replace 8139TOO with the name of the driver for your NIC)
 CONFIG_8139TOO=y
 ...

Then do the following to compile the kernel:

 # make-kpkg clean
 # make-kpkg --rootcmd fakeroot --append-to-version -fai-install --revision 1 kernel-image

This will produce a .deb kernel package in /usr/src which must then be copied to FAI's kernel directory.

 # cp /usr/src/kernel-image-2.6.12-fai-install_1_i386.deb /usr/lib/fai/kernel

Now, edit /etc/fai/make-fai-nfsroot.conf and set the KERNELPACKAGE variable to point to the new kernel package.

 KERNELPACKAGE=/usr/lib/fai/kernel/kernel-image-2.6.12-fai-install_1_i386.deb

Before exiting from the editor, check the FAI_LOCAL_REPOSITORY variable in /etc/fai/make-fai-nfsroot.conf. If it's commented out (as is the default setting), uncomment it to activate the local package repository.

 FAI_LOCAL_REPOSITORY="deb file:/fai/files packages/"

When these two items are complete, rebuild the FAI nfsroot so that it will use the new kernel. This command will also set up a PXE boot kernel in /boot/fai. If you just uncommented the FAI_LOCAL_REPOSITORY variable, then do not use the -K or -k flags as the entire nfsroot needs to be rebuilt in that case.

 # make-fai-nfsroot

Creating the post-install client boot kernel

Now it's time to make a few modifications to the kernel source and compile a kernel package that the client will use for post-install booting. Change back to the kernel source directory and reconfigure the kernel, as follows:

 # cd /usr/src/linux
 # make menuconfig

Make sure that the "Root file system on NFS" option is set to "N". Also, make sure that the device driver(s), chipset and filesystem that are used for your root filesystem are set to be compiled directly into the kernel, not configured as a module. For example, if you're using an IDE drive and the ext3 filesystem for your root, the kernel configuration should look like this:

<*> ATA/ATAPI/MFM/RLL support
<*>   Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support
<*>     Include IDE/ATA-2 DISK support
<*>     generic/default IDE chipset support

...

<*> Ext3 journalling file system support

Instead of the generic/default IDE chipset support, you could turn on support for the exact IDE chipset that you have in your client. For example, if you have the Intel PIIX4 chipset, the following could be set:

<*>         Intel PIIXn chipsets support

Of course, if your root is on a SCSI drive, then you'll have to set SCSI device support and SCSI disk support to be compiled into the kernel.

The stock FAI kernel configuration has the disk drivers and all filesystem (ext2, ext3, reiser, etc.) drivers configured as modules, so if you get a kernel panic after installing a client using this tutorial, you might want to double-check those settings.

If you previously compiled your network interface's driver into the kernel, it could now be configured as a module instead, since the root filesystem will no longer be mounted via NFS.

When done, save the new configuration and recompile the kernel as follows:

 # make-kpkg clean
 # make-kpkg --rootcmd fakeroot --append-to-version -fai-client --revision 1 kernel-image

After the new kernel package is built, it needs to be copied over to the FAI local repository. The local repository's Packages.gz index file also needs to be rebuilt.

 # cp /usr/src/kernel-image-2.6.12-fai-client_1_i386.deb /usr/share/fai/files/packages
 # cd /usr/share/fai/files
 # dpkg-scanpackages packages /dev/null | gzip -9 > packages/Packages.gz

Now the new kernel package can be specified for installation in one of the FAI package_config files, probably DEFAULT. To do so, add the line "kernel-image-2.6.12-fai-client" to /usr/share/fai/package_config/DEFAULT instead of the "kernel-image-*" line that was there previously.

One last item is to check whether certain modules which may be necessary for booting (such as the NIC driver) need to be added to the $moduleslist variable in /usr/share/fai/class/FAIBASE.var.

Now you're ready to proceed with client installs.

Personal tools