...making Linux just a little more fun!

Knoppix Boot From PXE Server - a Simplified Version for Broadcom based NICs

By Krishnaprasad K., Shivaprasad Katta, and Sumitha Bennet

Why this article?

The intent of this article is to exhaustively capture every step of booting Knoppix Live CD from a PXE Server. Booting Knoppix from PXE is a straightforward task. But here we would like to pinpoint some areas where we faced difficulties in booting Knoppix from a PXE server so that it may be useful for those who might be facing the same issues. We were attempting to automate system maintenance tasks such as performing system BIOS updates, updating firmware of system peripherals such as storage controllers, NICs, etc. We planned to boot Knoppix from PXE and then customize it to execute the .BIN upgrade packages (For upgrading system component firmware). We came across the Knoppix Live CD and its' Howtos but we still hit roadblocks which had to be sorted out before we could boot Knoppix successfully from PXE on a Broadcom NIC-based system.

Introduction:-

Knoppix is an amazing "one CD does it all" distro where you can customize it and use it for running your customized programs. About 1900MB of software compressed and stuck on a 700MB CD, with everything from sed to Openoffice. Knoppix 6.2 DVD comes with lot of packages so most of the needed programs / packages are covered in the DVD. Making it network boot capable will be an advantage as we dont need to run around for a CD/DVD. This article talks about how to create Knoppix Live CD/DVD PXE Boot capable and the points to be noted if you use any Broadcom card as the PXE Bootable NIC

Our setup:-

This article does not cover on how to create a PXE setup assuming that the readers will have the knowledge to setup a PXE server. Refer the following link for setting up a PXE Server.

Requirements:-

  • A system with a CD/DVD Drive to boot Knoppix Live CD (preferably Knoppix 6.2.1 which is the latest release) .
  • A PXE server configured in your network.
  • A system running a NFS server. This is for holding the content of the images that we are going to PXEBoot. The same PXE server can be used for setting up the NFS Server for holding root filesystem.
  • Now you need the Knoppix Live CD ISO image burnt onto media. If you have downloaded a Knoppix version of different langauage other than English, you need to pass the param lang=us while booting to the live CD. No one will download a different language version but it can happen. :-)

That's it. You are ready to start...

Generating the required files - kernel (named vmlinuz) and initrd images

Knoppix has the built-in ability to auto-configure itself to network boot itself, and this makes the process rather easy. Boot into the Live CD (runlevel 5 - default one). Follow the steps to create the necessary files:

Create an entry for Knoppix in your PXE Server menu (/tftpboot/pxelinux.cfg/default) as below:

label Knoppix
kernel /path/to/vmlinuz
append nfsdir=NFS Server IP:/path/to/knoppix-CD-DVD-contents/ nodhcp lang=us ramdisk_size=100000 init=/etc/init apm=power-off nomce vga=791 initrd=/path/to/miniroot.gz

- where vmlinuz is the kernel image that we created from Knoppix Live CD and miniroot.gz is the initrd image. Note that the complete Knoppix CD/DVD contents is available at the NFS Server mentioned in the Requirements list.

NFS Server Configuration

Installing an NFS server is beyond the scope of this document; however, this will give you what's needed to configure your NFS server.

In /etc/exports on the system (NFS Server), make sure that the share noted below is exported:
/path/to/Knoppix-CD-DVD-contents *(ro,no_root_squash,async)
Note how this matches up with the initial nfsdir parameter in the original knoppix pxelinux.cfg/default file. Do exportfs -a to make the share visible to the outer world.
...<NFS Server IP>:/path/to/knoppix-CD-DVD-contents/...

As mentioned above, copy the entire Knoppix CD/DVD contents to the above-mentioned NFS share. Knoppix expects to mount a directory over NFS and see the folder "KNOPPIX" right there. So In our NFS Server setup we changed nfsdir line to match our server's IP address, and then added an export on our NFS server as above.

That's it. Your NFS Server is ready with Knoppix contents and now it's time to boot the client boxes with Knoppix.

Hold on... Do you use Broadcom Network cards as PXE Bootable devices in your client boxes??

This is the heart of this article. Till now you may have seen other documentation which talks about booting Knoppix from Intel-based PXE. If your setup has a Broadcom-based PXE-enabled NIC, the same steps wouldn't get you to boot your system successfully. This article highlights why you run into those issues and how you can get rid of them.

The Knoppix initrd image (miniroot.gz) is going to fail in the client boxes where you use Broadcom cards... why? :-( Here is the solution :-)

As far as Broadcom drivers (eg/- bnx2) are concerned, it is required to load the firmware image while loading bnx2 driver module to the kernel. Under some circumstances, as explained below, it would be interesting to keep firmware images in non-swappable kernel memory or even in the kernel image (probably within initramfs).

- If the device that needs the firmware is needed to access the filesystem. If due to some error the device has to be reset and the firmware reloaded, it won't be possible to get it from userspace.
example:- A diskless client with a network card that needs firmware. The filesystem is stored in a disk behind a scsi device that needs firmware. This is because in our case, real Knoppix image sits in NFS share which needs to be accessed via the NIC that we boot the kernel and initrd image of Knoppix.

So for making the Knoppix PXE Bootable in this case, you will have to have the firmware images available in the initial ramdisk image (initrd) and then make it available at the time of driver load. Here are the steps/commands with a small piece of code for doing the same :
  1. You need to recreate the initrd image by having the firmware images available in it.
  2. In your PXE Server, copy the initrd image (miniroot.gz) to a temporary directory (let's create /tmp/temp_knoppix in the PXE Server itself).
  3. Unzip the initrd image copied to the temporary directory using gunzip miniroot.gz
  4. Extract the contents of initrd image using cpio -id < miniroot
  5. - Note that this command will extract miniroot cpio package and hence it would be better to create a temporary directory and extract the contents to it.
  6. Now you can see a bunch of directories created in the temporary directory.Create a directory for copying the firmware image
  7. cd /tmp/temp_knoppix
  8. mkdir lib/firmware/ -p
  9. Copy the firmware images from Knoppix Live CD to the initrd image using scp
  10. - Note that it's better to copy the whole lib/firmware directory to initrd as there are different firmware images of different drivers. In the future it will help if you want to make use of same initrd for different devices.
  11. Once firmware images are copied create a hotplug script to load the firmware image to the kernel when insmod is called. Create a directory sbin in initrd image using mkdir sbin/
  12. Create a script named hotplug inside the sbin directory. The content of the script is as below:
    	
    		#!/bin/sh
    		[ -z "$FIRMWARE" ] && exit 
    		echo 1 > /sys/$DEVPATH/loading
    		cat /lib/firmware/bnx2/$FIRMWARE > /sys/$DEVPATH/data
    		echo 0 > /sys/$DEVPATH/loading
    		
    		
  13. - Where $DEVPATH and $FIRMWARE are already defined in the environment. Note that this script is for loading bnx2 driver successfully while PXE-Booting Knoppix. if you use any other Broadcom devices which make use of other broadcom drivers (like bnx2x) , you need to change the script and mention the path to that driver's firmware path.
    Refer to know more about the need of loading the firmware image while loading the driver.
11. Make the script executable by chmod +x sbin/hotplug
12. Now we have made changes to the initrd content and it's time to recreate the initrd image.. Follow the instructions as below
13. cd /tmp/temp_knoppix/
14. find ./ | cpio -H newc -o >../initrd.cpio
15. cd ..
16. gzip initrd.cpio
17. mv initrd.cpio.gz miniroot.gz

Now Replace the old initrd inside /tftpboot/path-to/miniroot.gz by newly created miniroot.gz inside /tmp/

There you go - you are done with the configuration and recreation of initrd!

Test your Knoppix Boot from PXE!

Boot your client boxes to PXE menu and enter Knoppix as the boot option. This will load vmlinz and miniroot.gz. There you go! You can change the miniroot.gz initrd image to add your own programs and executables such that you create your own live CD booting from PXE Server.

There are lot of advantages as you can test your own program if any during/after bootup, with out installing it on any OS. This is completely driven out of NFS share! This setup can be used extensively in academic institutions, schools and for hands-on sessions in workshops with addition of ample custom settings.

We would like to convey our gratitude and thanks to Knoppix User Forum for helping us to solve this problem!
Share

Talkback: Discuss this article with The Answer Gang

Krishnaprasad K.


[BIO]

I am a strong follower and a big fan of GNU/Linux from India. I really admire the freedom, stability and strength offered by Linux. I must thank my guru, Mr. Pramode C. E., for introducing me to the wonderful world of Linux. I completed by B.Tech in Computer Science from Govt. Engineering College, Sreekrishnapuram, Palakkad (Kerala, India). Currently I work with Dell Inc. Bangalore, India, as a Software Engineer. My passion and ambition is to provide some useful things to the community, be it code or articles.


Shivaprasad Katta


[BIO]

I work with Dell Inc. Bangalore, India as a Software Engineer. I did my B.Tech in Computer Science from JNTU, (Hyderabad, India) and am currently working on my MS in Software Systems from BITS Pilani through the Work Integrated Learning Program. I am a strong believer in and a follower of linux. My first exposure to Linux was during my graduation days and I was impressed with the effective utilization of resources. I love to work on Linux and am a great fan of its stability, freedom, and its capabilities over other operating Systems. My passion for Linux steered me toward work in the areas of Grid Computing and High Performance Computing Clusters. I can proudly say that these areas are dominated by Linux. I love to share the knowledge and experience that I've gained with the Open Source community through articles, tips, and code.


Sumitha Bennet


[BIO]

I hold a Bachelor's degree in Electrical and Electronics Engineering from Bharathiyar University, Coimbatore, India and am currently serving as a software Engineer at Dell Inc. in Bangalore, India.

I'm a strong proponent and follower of free and open-source software, which promotes and encourages the development of enhanced software capability through a community of like-minded and self-less folks with a passion for making software affordable and accessible to all.

I look forward to learning from the rich community of enlightened folks & wish to give back in any humble capacity I can. :)

Wanna call out my buddy, mentor, and colleague, Krishnaprasad K who instilled in me the same passion that he holds for Linux and free/open-source software in general.


Copyright © 2010, Krishnaprasad K., Shivaprasad Katta, and Sumitha Bennet. Released under the Open Publication License unless otherwise noted in the body of the article. Linux Gazette is not produced, sponsored, or endorsed by its prior host, SSC, Inc.

Published in Issue 176 of Linux Gazette, July 2010

Tux