How-to: PXE - Packing the KNOPPIX image in initrd

Forum: DSL Tips and Tricks
Topic: How-to: PXE - Packing the KNOPPIX image in initrd
started by: jungle

Posted by jungle on Nov. 06 2006,06:25
There is a very interesting site < > that discusses booting DSL over PXE. The author of the mentioned site, had the rather ingenious idea of loading the whole dsl distro into the initrd, eliminating the need for an nfs server and continued internet access. The problem is: all the files on his ftp are for DSL 1.5.  At the time of this writing, the lastest version is 3.0.1.  After studying Mattias' files, I have come up with this method for converting the latest version of DSL to boot over PXE from initrd.  Hopefully, this will be useful to others in the future for future versions of PXE.  I document this method also for my own benefit :).

Booting DSL over PXE with the KNOPPIX image
embedded in the initrd.

0. Background: (What is PXE? Setting up a server?)

If you already know this kind of stuff, skip down to step 1.

A good tutorial to set up a server is here:< PXE tutorial >.  But you don't have to do everything it says there.  So read what i have to say first unless you know what you're doing already. Also, take a look at the links referenced in the beginning of that article.  They are very good.  

PXE stands for Preboot eXecution Environment.  The idea is to load the operating system via a network PXE server instead of a hard drive.  Basically, when you turn on the computer, it goes through its POST normally.  But when it comes time to actually boot an operating system, the computer loads a very limited set of tools from ROM located on the ethernet card.  

Then the computer sends a DHCP request to the network to get an IP address.  (So you need a dhcp server).  The DHCP server assigns an ip address and also sends a location where the operating system can be found (on a tftp server).  Sadly, the DHCP servers on most routers are not capable of sending this tftp server location.  Therefore, you will probably have to disable the DHCP server on your router (if you are using one) and run one on another computer on the network.  Wireless should be able to work correctly even if the DHCP server on the router is turned off.  It is possible to run a tftp server and a dhcp server on the same computer.  For my implementation, i used a PXE bootloader called pxelinux, so the file that I told the computer to download via tftp was called pxelinux.0.  Here is a clip from my dhcpd.conf

Code Sample
host tablet {
       hardware ethernet ************; //MAC address of pxe booting computer
       fixed-address;   //ip of pxe booting computer
       option host-name "tablet";
       filename "pxelinux.0";           //file should be in the tftp root dir
       next-server;       //this can be the same as the dhcp server

Back to the process...

Once the computer obtains an ip address and download location, it uses a tftp client to access the tftp server.  TFTP stands for  trivial file transfer protocol (i believe).  It's been around forever, from what i read.  Using pxelinux, the file downloaded will be pxelinux.0.  This tells the computer to look for a pxelinux config file in the directory pxelinux.cfg/ in the tftp root directory.  There are several naming options for the config file.  You can do per-MAC-address configurations by naming each config file the MAC address of the computer that will be accessing the tftp server.  This name should include dashes and start with "01-"  followed by the MAC address.  Also, you can use a hex representation of the IP address that will be accessing the tftp server.  Truncating the hex IP address allows you to represent multiple ip addresses, (i.e. = c0a8).  Each number in the ip address corresponds to two hex digits.  Finally, if no suitable config file is found, "default" is used.  The computer downloads the config file and proceeds according to it.

In my case, the computer then downloads the vmlinuz compressed linux image and the minirt24.gz (compressed initrd image).  After that, the boot process is the same as if you were booting from a hard drive.  The parameters passed to the kernel are written in the pxelinux config file.  It is possible to use other boot loaders, but I haven't investigated that.  If you just copy the isolinux.cfg file into the pxelinux.cfg/ directory and rename it appropriately, the boot process will be exactly the same as with the dsl cd (complete with the logo and boot prompt).  Mind you, you should copy all the files from the isolinux directory into the tftp root directory if you wish to do this.  

That is a lot of background, but the general idea is this:  you can boot a computer without any kind of bootable media (hard drive, floppy, usb boot support, cd drive) using PXE provided you have a network connection and  a computer running tftp and dhcp.  If you did not load the KNOPPIX cd image into the initrd (as we will do in a second) you would also need a nfs server to host the root filesystem for the computer you wish to boot via PXE.  Now let's actually get started...

1. Download latest DSL distribution iso and mount it.
   We will need the following files from the cd.

KNOPPIX/KNOPPIX         //compressed image
minirt24.gz                        //original initrd
vmlinuz24                         //kernel image

   keep it mounted, because we will need to copy from the
   isolinux.cfg file later.

2. unzip minirt24.gz and mount it in an appropriate location.
For those of you who don't know, an initrd is merely a gzipped
ext2 filesystem in a file.  
Code Sample
gunzip minirt24.gz
mkdir /mnt/initrd-dsl
mount -o loop ./minirt24 /mnt/initrd-dsl

3. Make a new initrd.  As I mentioned, an initrd is just a gzipped ext2 filesystem in a file.  So we are going to make a blank one big enough to hold the files from the original initrd plus the KNOPPIX image.  For me, 53MB was large enough to hold everything.  And since DSL vows to never exceed 50MB, I doubt that the size will ever need to grow.  Of course, if you remaster it (my next project) it might.

Code Sample
touch initrd
dd if=/dev/zero of=./initrd bs=1M count=53
mke2fs ./initrd
mkdir /mnt/initrd-custom
mount -o loop ./initrd /mnt/initrd-custom

4. Copy all the files from the dsl initrd to the new one
Code Sample
cp -a /mnt/initrd-dsl/* /mnt/initrd-custom/

Using cp -a will reserve the ownership, not dereference symlinks, and copy recursively.  
****Note: this is a correction from the original ******

5. Add the compressed KNOPPIX image to the new initrd.  DSL expects the KNOPPIX image to be on the burned DSL cdrom inside the KNOPPIX directory (where you found it in the iso).  So that is where we must put it.  We will later modify the linuxrc to check for the image in /cdrom/KNOPPIX before mounting anything in /cdrom.

Code Sample
mkdir /mnt/initrd-custom/cdrom/KNOPPIX
cp /path-to-KNOPPIX-file /mnt/initrd-custom/cdrom/KNOPPIX/

6. Edit the linuxrc file based on the diff file.  This is straight from the site listed at the top of the how-to.  The linuxrc file should go inside the initrd in the top directlry. It may have to be executable, I'm not sure.  The linuxrc file is a big part of what governs the linux boot process.  If you watch the boot messages as they come up, you can see where the "Accessing KNOPPIX image at...from initrd" message shows up.  To make the correct changes in the linuxrc script, I just looked at the diff file and inserted the lines manually.  It will be difficult to try to apply a diff file to patch the linuxrc when the surrounding text and line numbers will probably change with every release of DSL.  Here is what was in the original diff file.
*** linuxrc.orig 2005-09-16 13:46:47.000000000 +0000
--- linuxrc 2005-09-16 13:46:33.000000000 +0000
*** 323,328 ****
--- 323,330 ----
 test -n "$FOUND_SCSI" -a -z "$NOSCSI" && DEVICES="$DEVICES /dev/sd?[1-9] /dev/sd?[1-9][0-9]"
 DEVICES="$DEVICES /dev/hd?[1-9] /dev/hd?[1-9][0-9]"
 case "$CMDLINE" in *fromhd=/dev/*) DEVICES="$fromhd"; ;; esac
+ # Unset all devices if bootet from initrd
+ case "$CMDLINE" in *frominitrd*) DEVICES=""; ;; esac
 for i in $DEVICES
 echo -n "${CRE}${BLUE}Looking for CDROM in: ${MAGENTA}$i${NORMAL}   "
*** 338,343 ****
--- 340,355 ----
+ # Look for KNOPPIX directory without mounting anything
+ case "$CMDLINE" in *frominitrd*)
+ if test -f /cdrom/$KNOPPIX_DIR/$KNOPPIX_NAME
+ then
+ echo -n "${CRE} ${GREEN}Accessing DSL image at ${MAGENTA}/cdrom/${KNOPPIX_DIR}/${KNOPPIX_NAME}${GREEN} on initrd...${NORMAL}" ;
+ FOUND_KNOPPIX="initrd" ;
+ fi
+ ;;
+ esac
 # Harddisk-installed script part version has been removed
 # (KNOPPIX can be booted directly from HD now).

The line numbers in 3.0.1 are close to those listed in the diff file.  For those of you who don't know how to read a diff file (and I was very recently one of you) you should add the lines with the +'s between the lines without the +'s.  Ok, maybe it's self-explanitory, but for the sake of being user-friendly I spell it out.  The linuxrc looked very much the same for the 3.0.1 version.  It added some usb recognition stuff, from what I remember, so it was a bit longer.  Anyway, put the text in the right place and go on to the next step.  

7. Unmount the two initrds
Code Sample
umount /mnt/initrd-custom /mnt/initrd-dsl

8. Gzip the new initrd
Code Sample
mv initrd minirt24
gzip minirt24

9. put it in the tftpboot
Code Sample
cp ./minirt24.gz /tftpboot

10. create the appropriate pxelinux.cfg/default or specialized file based on the isolinux.cfg file found in the dsl iso.  Make sure you add the "frominitrd" option so that it will trigger the modified linuxrc. Other than that,  you will basically copy the isolinux.cfg from the DSL iso and rename it accordingly.  This step is a bit beyond the scope of this little how-to.  There are plenty of excellent tutorials about PXE configurations out there.  Mattias provided a tar file on his server that includes the pxelinux.0 file and default config files.  

On a side note, however... Personally,  I didn't want to be prompted for the boot options, so I cut the config way down.  All you need is the default and append options with a prompt option.  you may be able to cut out the prompt, I'm not sure.   Here is my auto-booting config file that includes some options I added myself.  

DEFAULT linux24
APPEND ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=789 initrd=minirt24.gz nomce noapic quiet BOOT_IMAGE=knoppix frominitrd nopcmcia noagp noswap base

That's it.  I hope that I haven't made any mistakes here.  And I hope the post will be useful to those wishing to do something like this.  Keep in mind that DSL will be loaded and run entirely from ram.  It runs fine for me on 192Mb.  Also, the thing goes to sleep and wakes up in about 2 seconds. :) Good luck.


Posted by ^thehatsrule^ on Nov. 06 2006,15:37
A nice guide - quite clear and concise :)

About the diff stuff - you can use "patch -p0 < file.diff"
Why do you want to use diffs? Takes less time, and there's less human error when changing the lines manually.

This is interesting though... placing it in the initrd.  This could help some who can't solve their "no knoppix image found" problems - guess the only drawback is the memory requirement.

Posted by hrwusesdsl on Nov. 10 2006,04:36
Newbie questions....
In Jungle's Step 7 above the command
umount  /mnt/intrd-custom
apparently copies the contents of the new modified ramdrive back into the source image file "initrd".  

Correct?  I have looked and looked at linux man pages and other web sources and never come across such obscure tips.  What is the best source for such?  Harcopy books?  Got a title?

Posted by Winter Knight on Nov. 10 2006,14:29
Nice. It's missing some parts though.

- It doesn't mention what PXE booting is. Or who might need/want it.
- Requirements are never mentioned (two systems? big requirement).
- It doesn't mention what tftp is.
- It mentions linuxrc, but does not specify what it does. Or where to find it, or where to put the modified version.

It really glosses over everything PXE. It doesn't say what it is, how to set up a server or client, or where on the network to put these files that the user creates. If knowing how to boot PXE is assumed prior knowledge, that should be mentioned at the top under pre-requisites.

It seems all this tutorial does it create the files. That is an ok tutorial, but, if that is the case, it should say so at the top. The promise at the top is: "I have come up with this method for converting the latest version of DSL to boot over PXE from initrd."  This should be reworded if you aren't actually going to explain how to boot.

Thanks for taking the time out to write this. I didn't mean to bag or sack or anything, I just thought I might be helpful.

Posted by ^thehatsrule^ on Nov. 10 2006,14:59
umount is to unmount that file system (ie unlinking that file system from the target directory).  It's not obscure - I use it manually and the mount tool in DSL uses it.

Winter Knight:
I think your first 3 points are covered under the first if the reader knows how a general PXE environment is like.  I suppose a link to a wikipedia article or something could help though.

About linuxrc: it's found in the root of the mounted initrd dir, and in the given in the directions, initrd-custom is where to place the files for the newly modified initrd.

Posted by Winter Knight on Nov. 10 2006,21:45
Quote (^thehatsrule^ @ Nov. 10 2006,06:59)
I suppose a link to a wikipedia article or something could help though.

A link like that would be a nice thing. It is more important, however, to state that prior knowledge is necessary, and that this tutorial does not explain what PXE is, or how to set up a PXE server.
Posted by jungle on Nov. 12 2006,22:29
In my mind, the focus was not on PXE but on putting the cd image in the initrd.  Setting up PXE is rather beyond that scope.  I will add a few notes about that sort of thing though.  


Posted by bohiti on Nov. 15 2006,15:47
I don't know if it's appropriate to request assistance in this thread, but I'll give it a go.  Jungle, those were great instructions, quite honestly exactly what I've been looking for.  I've set up a pxelinux launchpad for my company for all sorts of boot disks, and I would like to get DSL on there without going the knoppix/NFS route.

I followed your instructions well, I believe, as they were very straight forward.  I must have done something wrong, as it doesn't work for me.  Here's what I get:

Loading linux24.....................
Loading minirt24.gz...............................................................................
(clear screen)
(penguin logo)
Kernel panic: VFS: Unable to mount root fs on 03:01

My pxelinux config is:
Code Sample
KERNEL dsl/linux24
 APPEND ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=791 initrd=dsl/minirt24.gz nomce noapic quiet BOOT_IMAGE=knoppix frominitrd

Any quick thoughts?  Thanks.  I can post my linuxrc file if you'd like, but I agree that's pretty easy as well.

Posted by bohiti on Nov. 15 2006,16:37
More info:  I took out the "quiet" boot flag, and see a lot more information.
Code Sample
RAMDISK: Compressed image found at block 0
Freeing initrd memory: 49032k freed
VFS: Mounted root (ext2 filesystem).
kmod: failed to exec /sbin/modprobe -s -k ide-cd,errno = 2
VFS: Cannot open root device "" or 03:01
Please append a correct "root=" boot option
Kernel panic: VFS: Unable to mount root fs on 03:01

Shooting from the hip, I put in boot option "root=/dev/ramdisk rw" and end up with the following line repeated many times:
"/etc/init: /linuxrc: not found"
and then,
"/etc/init: Out of file descriptors
Kernel panic: Attempted to kill init!"

Posted by rja on Nov. 16 2006,20:59
In step 1, you mention "vmlinuz24" as the kernel image.

Are you using a custom compiled kernel image "vmlinuz24" or
in step 1, should it be "linux24" as the kernel image?

Also should
"In my case, the computer then downloads the vmlinuz compressed linux image"
be changed from "vmlinuz compressed linux image" to "linux24 kernel image"?

You might want to add that linux24 (or vmlinuz24) should be copied to
the tftpboot directory along with minirt24.gz

Posted by jungle on Nov. 22 2006,20:57
here's an idea...

I am very embarassed to say that there may be a big mistake in this how-to about creating the initrd.  for now, goto the site mentioned in the beginning and download the old minirt24.gz from his files link.  

1. gunzip the file and mount it.

gunzip minirt24.gz
mount ./minirt24 /mnt/initrd-custom

2. delete everything out of the initrd

rm -rf /mnt/initrd-custom

3. follow the instructions as if you had created the initrd file.

i will do some more research about that initrd.  if anyone sees a problem, please say so.


Posted by ^thehatsrule^ on Nov. 22 2006,21:08
Hm, I think you could just copy the initrd then edit it directly, which may be easier in the long run.

Taking another look, it maybe you have a problem with cp -R ? maybe try cp -a.

Posted by jungle on Nov. 22 2006,22:04
i think that is the problem.  stupid permissions.  The how-to has been updated


Posted by RigasW on Dec. 01 2006,18:34
Hello everybody,

an hour ago I found the impressive DSL 1.5 PXE image on the internet, copied it to my running tftp server ... works like a charme. THANKs a lot, this is wonderful!!!

I have been looking for this for quite a while ....

And now my question / is there a 3.1 DSL PXE version to download anywhere.



Posted by RigasW on Dec. 02 2006,20:15
I tried to do it myself and created a new version of "minirt24.gz".
It was loaded over the lan, hardware detection started, but then I got the "message" "KNOPPIX not found" and was left alone with a very basic linux version ...

I probably did not enter the correct changes in linuxrc ... (I really did not understand the part of the howto, where it comes to the diff file ...)

Any ideas?



Posted by ^thehatsrule^ on Dec. 02 2006,20:42
Yes, you would get that error if you did not modify linuxrc.

You can either use the program "patch" to automatically do that for you. (see my first post in this thread, probably could apt-get it)
Or manually edit the file ( In the first column, "+" means to add that line, "-" means to delete that line )

Posted by RigasW on Dec. 02 2006,21:01
Thanks ... I just did what you advised ... and now, voila ... it works.



Posted by RigasW on Dec. 04 2006,15:10
Just a question: could the fact, that I start DSL via PXE, be the reason, that both of the CD-drives in my computer are not reachable in xMMs?



Posted by ^thehatsrule^ on Dec. 04 2006,17:09
they aren't related - so I'd doubt it.
Posted by RigasW on Dec. 07 2006,20:04

has anyone ever  tried to permanently install a myDSL package in a PXE installation.

As far as I understand the wiki I just have to copy the package´s *.gz file(s) to the root (/) directory of minirt24.gz (I have to unzip mount that first ...)

After copying I have to gzip the file again und copy it to tftpboot.

I will give that a try.


Posted by RigasW on Dec. 07 2006,20:48
I tried to add the package nxclient as described above. After booting the following message shows up:

"Checking for myDSL Apps ....
nxclientgzip: short read

After that message X starts.

But there is no icon for the nxclient software.
"find / -name nx*" also only shows the nx....gz archive file and no installed nx client software.

Any ideas?


Posted by RigasW on May 20 2007,12:25
Just a little update half a year later:

To got mydsl applications running, I had to do the following:

I created a larger (100 MB instead of 50 MB) minirt24.gz and copied the mydsl archive files on the highest level there ( / ).

After starting DSL, the appletes did not start by themselves ...
So I just wrote l little script with a line like

mydsl-load jre1_5_0.tar.gz

So this script installs the jre mydsl package ...

User DSL must be owner of the script, group must be staff ...

So I can run DSL on every computer in the house that is connected to the network .. I neither do need a usb-stick nor a CD any more .... pretty cool.


Posted by Screwba on June 26 2007,20:30
Does anyone know if this works for 3.3?

I am getting the 'Can't find KNOPPIX filesystem...' message.  I believe my linuxrc file is properly goes through all the hardware detection fine.

Thanks in advance.

Posted by rja on June 26 2007,23:42
I have setup both 3.3 and 3.4rc1 to pxe boot using these instructions.  I didn't try adding any extra packages.

It does sound like you need to re-check the linuxrc that needed
to be modified.

I'll try to make a diff of what I did to my  linuxrc for 3.3.

Also, make sure that you have frominitrd in your pxelinux.cfg/default or whatever config file you setup.  I have this:

Code Sample

LABEL dsl-3.4RC1
KERNEL /dsl-3.4RC1/linux24
APPEND ramdisk_size=100000 init=/etc/init lang=us vga=791 initrd=/dsl-3.4RC1/minirt24.gz quiet BOOT_IMAGE=knoppix syslog dma usb2 host=keyhole tz=America/Chicago frominitrd base norestore noswap

LABEL dsl-3.3
KERNEL /dsl-3.3/linux24
APPEND ramdisk_size=100000 init=/etc/init lang=us vga=791 initrd=/dsl-3.3/minirt24.gz quiet BOOT_IMAGE=knoppix syslog dma usb2 host=keyhole tz=America/Chicago frominitrd base norestore noswap

LABEL dsl-1.5
KERNEL /dsl-1.5/linux24
APPEND ramdisk_size=100000 init=/etc/init lang=us vga=791 initrd=/dsl-1.5/minirt24.gz quiet BOOT_IMAGE=knoppix syslog dma usb2 host=keyhole tz=America/Chicago frominitrd base norestore noswap

This uses separate directories in /tftpboot for each version.

Posted by rja on June 27 2007,00:23
Here is the diff from the linuxrc for dsl-3.3 to allow frominitrd:

Code Sample

--- linuxrc.orig        2007-06-26 19:07:56.000000000 -0500
+++ linuxrc-frominitrd  2007-06-26 19:04:00.000000000 -0500
@@ -334,6 +334,8 @@
test -n "$FOUND_SCSI" -a -z "$NOSCSI" && DEVICES="$DEVICES /dev/sd?[1-9] /dev/sd?[1-9][0-9]"
DEVICES="$DEVICES /dev/hd?[1-9] /dev/hd?[1-9][0-9]"
case "$CMDLINE" in *fromhd=/dev/*) DEVICES="$fromhd";;; esac
+# Unset all devices if booted from initrd
+case "$CMDLINE" in *frominitrd*) DEVICES="";;; esac
for i in $DEVICES
echo -n "${CRE}${BLUE}Looking for CDROM in: ${MAGENTA}$i${NORMAL}   "
@@ -349,6 +351,16 @@

+# Look for KNOPPIX directory without mounting anything
+case "$CMDLINE" in *frominitrd*)
+if test -f /cdrom/$KNOPPIX_DIR/$KNOPPIX_NAME
+echo -n "${CRE} ${GREEN}Accessing DSL image at ${MAGENTA}/cdrom/${KNOPPIX_DIR}/${KNOPPIX_NAME}${GREEN} on initrd...${NORMAL}";
# Harddisk-installed script part version has been removed
# (KNOPPIX can be booted directly from HD now).

Posted by RigasW on July 07 2007,15:46
I added some packages to my DSL 3.3 iso image. The packages are copied onto the image and their installation is started with some simple bash scripts. (There are several Remaster howtos in this forum that show you, how you can add files to your image.)

Using scripts that are called from .xinitrc the packages are installed every time my installation boots (mydsl-load is used for that.).

If you would start DSL from a CD, packages could be installed automatically, if they are in a certain directory (/tmp I suppose).
This mechanism does not work with pxe. Therefore I had to use the scripts. For details see this thread: < see here >

The iso-image I converted to a pxe file as desribed in this howto.


Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.