Booting A Modern Linux Desktop In Just ~200MB

Written by Tomas Matejicek in Operating Systems on 26 December 2012 at 01:35 PM EST. Page 1 of 3. 10 Comments.

Unlike many of the Linux distributions out there today that are little more than minor user-facing changes to Ubuntu or another tier-one Linux operating system, Slax for the past many years has followed its own dance. Slax, a LiveCD Linux distribution built around Slackware, is very lightweight and calls itself a "pocket operating system" as with the most recent release it can fit a full Linux OS with the KDE4 desktop in about 200MB. Slax is also intended to be quite easy for others to modify and create custom images via Slackware packages and Slax modules. The recent Slax 7.0 release was the first update for the open-source operating system in several years. For those interested in knowing how this very lightweight and customizable operating system can work so efficiently, Tomáš Matejícek, the Slax creator, has written an exclusive Phoronix article about the process.

What Is Slax

Slax is a Live operating system based on Linux. Live means it runs from an external media without any need for permanent installation. Slax boots from USB mass storage devices such as Flash Drive keys as well as from regular hard drives and CD/DVD discs.

Slax Directory Structure

All Slax data files are located on the boot media in a single directory. It is no surprise that the name of that directory is 'slax'. All the magic happens inside. Here is an overview of simplified directory structure; directories are red, some interesting files are mentioned as well, using italic:

Booting The Linux Kernel

When your computer's BIOS boots Slax, it actually just runs SYSLINUX boot loader. The boot loader itself is stored either in file isolinux.bin or ldlinux.sys, depending on your boot media - CD/DVD uses isolinux.bin, USB disk or hard drive uses ldlinux.sys.

As soon as the SYSLINUX boot loader is executed, it learns what to do next from its configuration file (you guessed it) syslinux.cfg. In Slax, this configuration file contains instructions to show some cool boot logo and optionally provide boot menu if the user hits a key before timeout. When the timeout counter reaches zero or the user exited boot menu, SYSLINUX boot loader loads two files into memory: vmlinuz (Linux kernel) and initrfs.img (base root filesystem). The progress is indicated by continuous stream of dots printed on screen. Once the files are loaded, the vmlinuz binary is executed to start the Linux kernel.

Pre-Init

Under normal conditions (when a standard Linux distribution is starting from a hard drive), the Linux kernel would mount the root filesystem from the hard drive and /sbin/init would be executed as the main process which takes care of system startup. In Slax, the situation is different - there is no hard drive to mount the root filesystem from, yet the kernel surely needs some init process to be started. For that purpose, Slax carries a base filesystem in the initrfs.img file - it is a compressed CPIO archive with some directories and files inside, including core Linux tools (commands) and the desired init.

So after the Linux kernel has successfully initialized and has a full control of your computer, its last task is to find the mentioned CPIO archive in memory (it was loaded there from file initrfs.img by syslinux boot loader as you surely remember), extract it (into a memory area which acts as a temporary root filesystem, called initramfs) and execute the temporary /init process from there.

Related Articles