First of all, if you don't know what is Slax, it's a highly usable and compact slackware based GNU/Linux live CD distro just around 230 MB.
It's one of the most complete and flexible live CD around I've tried so far. With a stripped down KDE 4 desktop and precisely chosen applications. Here's the official site , you can download and try yourself.
Slax, despite it's small size, has many features like copy to RAM, load user made changes, act as a PXE boot server to boot other systems over network and many more.
Installing and managing software packages is also easy, squashfs based software packages are highly modular.
You can boot Slax from a CD or USB drive very easily. But, to boot it from network with the standard initramfs image(initrfs.img in this case), you've to pull some tricks.
Slax's default initramfs is very small(~ 750 KB) compared to other Linux distros. And it's without networking support, though enough for booting from CD/DVD or USB drive.
So you'll need a different initramfs image with networking support and different init script. How to generate this special initramfs image ?
This is another extension of main article about OpenWrt PXE server. So have a look there before going further.
Contents
1. Generate PXE boot capable initramfs
The Slax initramfs is called initrfs.img , there is a nice shell script named pxe under the /sbin
directory in Slax live to generate it automatically. To generate this, you have to boot Slax live CD and run
/sbin/pxe
Now copy the PXE boot capable initrfs.img file from the /var/state/dnsmasq/root folder to the OpenWrt PXE boot server. I did it by running Slax Live in Virtualbox and copied it to a USB drive.
cp /var/state/dnsmasq/root/initrfs.img /media/sdb2/initrfs_pxe.img cp /var/state/dnsmasq/root/PXEFILELIST /media/sdb2/
Note: Both of these commands are meant to be run on the Slax live environment and make sure that you changed the commands according to your system.
2. Copy the Slax data
This step depends on your Slax download, if you downloaded the zip archive simply unzip it to the right partition of the USB drive. Or if you downloaded the ISO file, loop mount it some where and copy the data. You can perform this on a PC running any Linux distro.
sudo mount slax_7.0.8.iso /mnt/ cp -r /mnt/slax/ /media/user_name/drive_name/ # example cd /media/user_name/drive_name/ mv initrfs_pxe.img slax/ sync
Note: Don't forget to modify the commands which matches to your system. Now un-mount the USB drive from the PC and connect it to the OpenWrt router.
3. Create the pxelinux configuration
Now login to your OpenWrt router using SSH, you need to run some commands below there.
First write the pxelinux configuration for the OpenWrt PXE boot server to boot Slax, assuming you have read the the previous guide of setting up OpenWrt PXE boot server.
You need to do one more step before editing the configuration, check the PXEFILELIST file to know about the absolute minimum number of files required for a successfull pxe boot.
cd /mnt/sda2 mv initrfs_pxe.img slax/ mv PXEFILELIST slax/ ln -s /mnt/sda2/slax/ /mnt/sda2/PXEboot/
Edit the /mnt/sda2/PXEboot/pxelinux.cfg/default file and add the configuration bellow
LABEL Slax PXE KERNEL /slax/boot/vmlinuz IPAPPEND 1 APPEND initrd=/slax/initrfs_pxe.img load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 slax.flags=xmode
As a note, on OpenWrt, the PXE server is also managed by dnsmasq alsong wth dns, dhcp and tftp.
4. Setup a HTTP server at port 7529 in OpenWrt
The Slax LiveKit init script will download the Slax data files from a HTTP server running at port 7529. Creating a lightweight HTTP server with OpenWrt is very easy with the uhttpd
. There is a good probability that your system has uhttpd installed, if not install it.
opkg install uhttpd
Now start the server at port 7529 binding all available interfaces
uhttpd -p 0.0.0.0:7529 -h /mnt/sda2/slax/
Check if the HTTP server is working or not
wget -q 192.168.1.1:7529/PXEFILELIST -O -
To start the http server automatically at boot up, add this line bellow
uhttpd -p 0.0.0.0:7529 -h /mnt/sda2/slax/
at the /etc/rc.local
file before the exit 0
line.
Now boot up a PC or virtual machine from the OpenWrt PXE server and select the Slax PXE to test this setup.
5. TO DO and conclusion
However, any user made changes are not saved form the changes.dat file. You can create a custom shell script and run rsync on a interfal to fix this issue.
It seems that currently the Slax copy to ram feature doesn't work while booting from PXE server. But the system will be as responsive as it's running from ram. Because the boot process downloads all the squashfs modules (sb files) to RAM. Use the losetup command to check all the mounted slax bundles while running.
losetup -a
This little guide will help you to boot Slax from a PXE server, please leave your suggestion or question through the comments. If you find this tutorial useful, please share it with your friends.
Miguipda says
Hi again,
I just found now the information concerning the Slitaz pxe at http://doc.slitaz.org/en:guides:pxe
Have a nice day and give us your next tutorial concerning pxe Slitaz through an OpenWRT server ๐
Have a nice day.
Arnab says
Thanks, I'll add slitaz very soon in the list, it will be great to boot Slitaz over PXE I! But currently I don't have the Slitaz ISO file.
Miguipda says
Hi,
nice tutorial.
1) at point 3. you wrote "OpwnWrt" in place of "OpenWrt".
2) the point 5. must be analysed to allow us to keep changes.
3) one thing that I still does not know. Does pxe boot distribution allow to get them in "toram" loading mode ? That will then give us a responsive distribution.
4) as already explained Porteus is also a great distribution that work like Slax (and was used by users when Slax was sleeping too long for new version). I means that copying the iso content will give you a bootable distribution. I presume then the pxe config file will be similar or also easy to create.
But ... because there is a but, I do not know if Slax is like Porteus with updating programs. Because even if it is only needed to copy the compressed file to get a working package it is difficult to have (by example) the last Firefox version (then stay in secure mode).
Please continue to share us this great multiboot pxe (with interesting distributions like Tails and Slitaz that give security and quick start with responsive interaction.
Have a nice day.
Miguipda ๐
Arnab says
First, thanks again for spotting the mistake, my quirky mind always tends to type something wrong
I'm also experimenting to load and save the changes over PXE boot.
I forgot check toram function over PXE before writing it, I'll update it very soon.
Yes Potreus is more updated than slax, but somewhat bigger than Slax, so didn't downloaded it !