Compile a Custom FOG Kernel

*FOG Refers to the Free and Open Ghost project accessible at http://www.fogproject.org

**Ever try to image a new machine with FOG only to have it successfully PXE boot and then sit at a screen that states “Checking Queue” and continues to increment every 5 seconds.  It is most likely due to your FOG linux kernel not supporting the NIC (Network Interface Card) in the system you are trying to image.  To test this, you can cancel the active imaging task, boot to the FOG PXE menu, choose the Debug Mode option, wait for it to boot, then issue the command ifconfig.  If all you see is the lo or loop-back adapter, then it didn’t successfully load your NIC.  You can issue lspci and it should show you that it sees the NIC, who the vendor is, and the vendor ID that you can use to look up information / get drivers for it with.

***My reason for building a custom kernel was imaging a Toshiba Satellite L50-A with an Atheros Wired NIC; specifically a 1969 / 1091 ver10 identified with the lspci linux commandline utility.

****This guide makes some general assumptions.  First and foremost, is that you already have FOG installed and functioning on Ubuntu Linux; as of this writing I am using version 12.04.4 LTS, Precise Pangolin.  I will also be making the assumption that you have SOME experience with Linux and running commands in a terminal.

1.)Launch a terminal and sudo -s
     A.)Please note that this keeps you logged in as the root user so you can really muck stuff up if you don’t watch what you are doing.
     B.)Some say it is best to stay a standard user and preface all commands with sudo, but I live on the dangerous side….
2.)Run the following commands from the terminal to get the components you will need to compile the kernel
     A.)apt-get install fakeroot build-essential crash kexec-tools makedumpfile kernel-wedge
     B.)apt-get build-dep linux
     C.)apt-get install git-core libncurses5 libncurses5-dev libelf-dev asciidoc binutils-dev
3.)Get the latest version of the kernel
     A.)cd /usr/src
     B.)ftp ftp.kernel.org
          a.)enter anonymous as the username
          b.)enter your e-mail address as the password
          c.)***This is how things were done in the old days kids :-)
     C.)cd pub
     D.)cd linux
     E.)cd kernel
     F.)cd v3.x
     G.)ls linux-3.*
          a.)This command will show you all versions of the kernel starting with version 3
          b.)You could do ls linux-3.13* and it would show you all versions of the 3.13 kernel (3.13.1 and 3.13.2 as of this writing)
          c.)Note: you will see multiple copies of each version of the kernel, the .sign is a digital signature and the .tar.xz and .tar.gz are just two different forms of compression
     H.)get linux-3.13.2.tar.gz
          a.)You would, of course, replace with the version of the kernel you wish to compile
          b.)This will download the linux source tarball to the current directory; /usr/src
     I.)quit
4.)Now we will extract the source tarball we just downloaded
     A.)tar -zxvf linux-3.13.2.tar.gz
          a.)give it some time, there is a lot there
5.)Now we need to copy the FOG kernel config file over to the linux kernel source directory we just created by extracting
     A.)cp /opt/fog_0.32/kernel/kitchensink.config /usr/src/linux-3.13.2/.config
          a.)The above is assuming that /opt is where you extracted the fog source tar ball
          b.)Obviously, update the fog_0.32 and linux-3.13.2 versions to match the versions of the software you are using
6.)Finally, we are ready to configure, build, and use our kernel
     A.)cd /usr/src/linux-3.13.2
     B.)make menuconfig
          a.)you will be presented with a command line based menu for choosing configuration options
          b.)the .config copied earlier will select some defaults required for FOG
7.)Two places of note for compilation are as follows:
     A.)Networking Support —> Networking Options —> IP: BOOTP support
          a.)FOG uses this to mount the linux system used in the imaging process
     B.)Device Drivers —> Network Device Support —> Ethernet Driver Support —>
          a.)This is where you will find all the network interface cards (NIC) that the kernel supports.  You will want to mark the ones you wish to be included with a * not an M as M stands for module which is loaded after the kernel boots; and in this case, not at all.
8.)After you have selected what you want included in your kernel, then choose exit and choose YES to save your new configuration
9.)Now, simply type make and go get a coffee / tea / red-bull / play a video game / do your taxes / it’s gonna take a while; most likely hours :-)
10.)Upon completion you should be able to find your kernel under /usr/src/linux-3.13.2/arch/x86/boot/bzImage
11.)My suggestion to anyone using a new kernel for FOG for the first time is to make a backup of the original kernel
     A.)cp /tftpboot/fog/kernel/bzImage bzImage.orig
12.)Then you can add your new kernel to the same directory
     A.)cp /usr/src/linux-3.13.2/arch/x86/boot/bzImage /tftpboot/fog/kernel/bzImage.ver3_13_2
          a.)It doesn’t really matter what you name it, but I suggest including the kernel version since, now that you know how, you’ll probably be compiling kernels left and right :-)
13.)Now, when you want to put the kernel in place to use simply
     A.)cp bzImage.ver3_13_2 bzImage
          a.)Make sure you HAVE made a copy of the original in case you want to revert
          b.)You can also goto http://www.fogproject.org —> downloads —> kernels to obtain more pre-built kernels.  As of this writing there were none that I could find to support the Atheros NIC I had
     B.)Upon putting the kernel in place, simply start the imaging task and image away, if you did well in compiling and your kernel does indeed now have the correct driver incorporated, the imaging task will start

Comments

Popular Posts