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, with a stripped down KDE 4 desktop and precisely chosen applications. If you don’t have it, download and try it from the official site .
Despite it’s small size, Slax provides many features like copy to ram, load user made changes, act as a PXE boot server to boot other systems over network etc. etc. Installing and managing software packages is very easy, squashfs based software packages are highly modular.
Lets start, booting Slax from a CD or USB drive is easy, but it could not be used to boot from network with the standard initramfs image(initrfs.img in this case). The standard Slax initramfs is very small(~ 750 KB) compared to other Linux distros, without any networking support, though enough for booting from CD/DVD or USB drive.
So we 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 it’s good to have a look there before going further.
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
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. This step is to be done 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: Dont forget to modify the commands which matches to your system. Now unmount the USB drive from the PC and connect it to the OpenWrt router.
3. Create the pxelinux configuration
Now 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. This step is to be done on the OpenWrt router.
Just one thing to do before editing the configuration, the PXEFILELIST contains name of the Slax data to be downloaded from the http server.
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
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/
/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. There are many way to setup a small HTTP server, read more here.
5. TO DO and conclusion
This setup could not load or save the any user made change form the changes.dat file, this thing needs to be fixed.
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 running from ram, because all the Slax squashfs modules (sb files) are downloaded to RAM. Checking this with the command.
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.