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:25There is a very interesting site < http://www.damnsmalllinux.org/talk/node/248 > 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
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. 192.168.0.0 = 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.
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.
4. Copy all the files from the dsl initrd to the new one
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.
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.
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
8. Gzip the new initrd
9. put it in the 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.
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:37A 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:36Newbie questions....
In Jungle's Step 7 above the command
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:29Nice. 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:59hrwusesdsl:
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.
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
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:29In 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:47I 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:
Kernel panic: VFS: Unable to mount root fs on 03:01
My pxelinux config is:
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:37More info: I took out the "quiet" boot flag, and see a lot more information.
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"
"/etc/init: Out of file descriptors
Kernel panic: Attempted to kill init!"
Posted by rja on Nov. 16 2006,20:59In 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?
"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:57here'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.
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:08Hm, 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:04i think that is the problem. stupid permissions. The how-to has been updated
Posted by RigasW on Dec. 01 2006,18:34Hello 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:15I 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 ...)
Posted by ^thehatsrule^ on Dec. 02 2006,20:42Yes, 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:01Thanks ... I just did what you advised ... and now, voila ... it works.
Posted by RigasW on Dec. 04 2006,15:10Just 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:09they aren't related - so I'd doubt it.
Posted by RigasW on Dec. 07 2006,20:04Hello,
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:48I 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.
Posted by RigasW on May 20 2007,12:25Just 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
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:30Does 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 changed...it goes through all the hardware detection fine.
Thanks in advance.
Posted by rja on June 26 2007,23:42I 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:
This uses separate directories in /tftpboot for each version.
Posted by rja on June 27 2007,00:23Here is the diff from the linuxrc for dsl-3.3 to allow frominitrd:
Posted by RigasW on July 07 2007,15:46I 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.