Table of Contents

Introduction

I always have a USB drive with a Linux Live in case of emergency. Sometimes I also like to use the operating system entirely from RAM: if I know I just need to browse the web, why bother to mount the hard drive? We can always mount it in a second moment if we change our mind. Moreover, in the case of an SSD device, this approach will reduce the overall number of writes improving the life of the device (even if you are not doing anything special, at least the system logs usually write something).

At the moment I have my usual Slackware 15 Live and XUbuntu which I have to use to boot Windows laptops when Secure Boot is enabled.

I am looking for another Linux Live because Slackware is great, but it might contain too much software I don’t really need on a Live session.

I remember I used once Slax Linux[1] which was great because at the time you could select just the modules you required (more or less one module was one program) and then you could compose your fully customized Linux Live.

Like many others, at the time, it was based on Slackware. I am not sure exactly what happened to the project, but after a while I saw they moved from being Slackware-based to Debian-based and the full customizability was gone.

It was probably not well maintained (or difficult to maintain) because on the website of Porteus Linux we can read[2]:

Porteus started out as a community remix project to keep the Slax OS up to date.

At first I had other candidates in mind: Porteus, Puppy, Tiny Core Linux; however I decided to check out also the website of Slax. I was pleasantly surprised when I found out the Slackware-based flavor was back. Full of curiosity I thought “Let’s see if the old glory of the project is back”. Unfortunately after clicking on “Get Salix” and having selected the base system (Debian or Slackware) and the architecture (32 bit or 64 bit), instead of letting you choose the modules, it asks for an email to receive the download link. The text says:

Enter your email address below to receive your download link. Why is this necessary? I would like to stay in touch with you after your download. Don’t worry, you can disable any further mailings easily if you do not wish to hear from me anymore.

This is a big turn off for me: yes, it says I can get my download and then unsubscribe from its mailing list, but why today everybody is interested in your personal data? I cheated and used a temporary email address to get my download and this annoying guy asking for my email didn’t even create a blacklist to prevent me to do so.

I am noticing only now that there is a very small text in light gray under the subscribe button which allow to download the ISO image without a subscription. It is clearly put that way to be hidden and it is in contrast with the instruction in the box above.

Not a good start, but let’s try this thing.

The size of the download is around 500 MB and I like lightweight software. +1 for Slax on this.

My experience with Slax

I already have a bootable USB key with the ISO of Slackware Live and some space I can use for Slax. Unfortunately, like many other projects, the documentation is not great and I wasn’t able to find the boot options on the website to check if it can be booted by an ISO file on the flash drive. I could have restarted my laptop and proceeded with a trial and error, but I decided just to follow the saying “the best documentation is the source code”. In my case it means let’s mount the ISO image on a loop device and check the configuration of the bootloader.

mount o loop,ro -t iso9660 slax-64bit-slackware-15.0.4.iso /mnt

The content of the image is a README file with some instructions for Windows users and a folder called slax. In slax the usual boot folder with the kernel, the initramfs and the configuration of Syslinux[3] (the bootloader).

In the file isolinux.cfg there is a useful entrance with the parameters to run the distro entirely from RAM. The common approach followed by most of the Linux Live distributions is to mount the boot device as a read-only filesystem and keep it mounted all the time. I have plenty of RAM on this laptop so I prefer to use it and unmount the USB partition as soon as my system is running.

Let’s proceed with the next step in order to configure my bootable USB drive.

Configuration of the USB device

I already have Grub2 installed on my USB drive and 500 MB of space available in the second partition. To get my Slax working I need to copy the slax folder from the mounted image and translate the entry from isolinux.cfg to my grub.cfg.

mount /dev/sda2 /media
cp -r /mnt/slax /media
vi /media/grub/grub.cfg

In grub.cfg I put:

menuentry "Slax 15 USB Live" {
    load_video
    insmod gzio
    insmod ext2
    set bootparms='vga=normal initrd=/slax/boot/initrfs.img load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 consoleblank=0'
    search -f /slax/boot/vmlinuz --set=root
    linux     /slax/boot/vmlinuz $bootparms locale=en_US.utf8 tz=UTC ipv6.disable=1 toram 3 # debug=3 rescue
    initrd    /slax/boot/initrfs.img
}

As soon as I have created my first configuration I am wondering if it is going to work. At the moment we are sure the bootloader (GRUB2) is able to load the kernel and the initramfs, but will the kernel be able to mount the proper device and find the slax folder? We didn’t specify anything related to it.

Let’s check again the documentation to see if it describes how Slax finds its module folder during bootstrap. Luckily I find a page where the boot process is described in good detail[4]:

  • the bootloader on the USB device loads the kernel and the initramfs and execute the kernel
  • the kernel fully initializes and uses the initramfs as the original filesystem
  • the kernel run /sbin/init in the initramfs
  • the article describes well the problem of escaping initramfs (another +1 for Slax here)
  • the kernel mount a tmpfs (a temporary file system created in the volatile memory) and use the systemcall switch_root to change the origin of the filesystem to it
  • the previous step is necessary to be able to use the syscall pivot_root which is required later to change again the root of the filesystem to reach the final configuration
  • the boot process continues mounting the Slax modules (some files containing squashfs filesystem)
  • then AUFS joins the filesystems of the modules in one single hierarchy
  • the init script calls pivot_root to change again the root of the filesystem so the folder mounted by AUFS becomes the new /
  • at this point /sbin/init is executed to take care of the rest of the bootstrap (this is a different init from the one we ran in the initramfs)

I found that page very informative and interesting.

Back to my problem: how does the bootstrap process find the folder /slax in my device?

In some distro the label of the filesystem is used for this purpose since a specific partition is always mountable from /dev/disk/by-label/<LABEL>. However this will work only when the ISO image is copied with dd on the flash drive (this way the partition table and the labels of the filesystems are copied as well).

The page describing the boot process of Slax says that all partitions will be mounted looking for a valid directory.

What is a valid directory? Is it the directory containing the modules or the main slax folder? I also don’t like too much this method of mounting and looking inside my partitions.

It is also mentioned a folder changes which is supposed to keep what we update in the system if the device is mountable with write permission. This is something I don’t want, but unfortunately there is no detail explaining if my boot option toram is sufficient to disable this feature or how it works.

To answer my questions I can check if the /sbin/init in the initramfs is readable with a text editor:

file  /mnt/slax/boot/initrfs.img    # XZ-compressed cpio archive

mkdir /dev/shm/initrfs
xzcat /mnt/slax/boot/initfs.img | cpio -iv -D /dev/shm/initrfs
emacs --no-splash -mm  /dev/shm/initrfs/sbin/init

Luckily it is a bash script with a couple of sourced files from the folder /lib. Reading this I found these two interesting points:

  1. To activate the folder changes for persistency it is not sufficient to have a writable destination as the documentation said, but it is necessary to use an explicit boot parameter perch (which can be remembered from the words persistent changes).
  2. It is possible to pass the parameter from= to avoid the mounting of all the devices and specify which one contains the slax folder.

Let’s add our new findings to grub.cfg and reboot and test this system:

menuentry "Slax 15 USB Live" {
    load_video
    insmod gzio
    insmod ext2
    set bootparms='vga=normal initrd=/slax/boot/initrfs.img load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 consoleblank=0'
    **set slaxfolder='from=/dev/sda2/slax'**
    search -f /slax/boot/vmlinuz --set=root
    linux     /slax/boot/vmlinuz $bootparms **$slaxfolder** locale=en_US.utf8 tz=UTC ipv6.disable=1 toram 3 # debug=3 rescue
    initrd    /slax/boot/initrfs.img
}

In my first copy and paste from isolinux.cfg there was another suspicious parameter: automount. This tells the system to automatically scan and mount all the available partitions. I didn’t realize this before, so my first action was to remove automount from my boot configuration in grub.cfg and reboot.

My Slax started in text mode which is the default in Slackware; also I have specified runlevel 3 in my configuration. Nothing weird here.

The text message before the prompt says the root user has password toor so I used it to successfully login.

In the file /etc/passwd I discovered the existence of a user called guest and in the file /etc/shadow you find it is locked. Let’s fix it with:

passwd guest

It is also a good idea to change the password of root.

After having logged in as guest, I tried the standard way to start the graphical session (xwmconfig and startx) but it failed. I also checked my wifi card, but it looks like there is a problem with the firmware (used dmesg to check).

I see a weird “Starting X…” in the last messages of the bootstrap procedure (before the first login prompt), but I didn’t specify runlevel 4 in the boot options, so I don’t expect Xorg to start automatically.

I restarted the system removing 3 from my boot parameters and I found no difference since runlevel 3 is the default anyway.

My investigation brought me to the file /etc/rc.d/rc3.d/Slax* which is a simple script calling another script XDetect. The content of XDetect is an attempt to generate an automatic xorg config and run startx; in case of failure the script deletes the config file and try again startx.

For some reason nothing worked and the logs /var/log/XOrg*.log showed a failure when XOrg tried to load the driver amdgpu. The error message says there is a missing library called libgpm.so. Never heard of that before.

At this point I tried to use the vesa driver, but it complained and I couldn’t use it. My last chance was to mount the root filesystem of my Slackware 15 (which is installed in my laptop) and see if I have this file. It turned out I had it and since the Slackware package manager uses simple text files to keep track of which packages are installed and what file belongs to each package, I could find my package with a simple grep:

$ mount -oro /dev/disk/by-label/slack15 /mnt  # my installed system
$ grep libgpm /mnt/var/lib/pkgtool/packages/*
/mnt/var/lib/pkgtool/packages/mesa-XYZ:  usr/lib64/libgpm.so

Bingo! It is the package Mesa that is missing in Slax.

I am also wondering why my WiFi card is not working since Slax is based on Slackware 15 and I have no problem with it in my installed system. Looking for the name of the package “firmware” I see Slax is using a different package for the firmware (taken from Debian). Why the Slax guys didn’t use the same package of Slackware is out of my knowledge and I got tired of all of my tests. That’s enough for today.

Conclusion

Thanks for the interesting article on the boot process, but Slax is not my cup of tea.

I will probably try Tiny Core Linux even though it was freezing during the boot when I tried to use it last time. It was like 8 years ago, so maybe in the meantime they have fixed it.

The other option would be Porteus which I have successfully used in the past.

References

[1] https://www.slax.org/

[2] http://www.porteus.org/faq.html#one

[3] https://wiki.syslinux.org/wiki/index.php?title=The_Syslinux_Project

[4] https://www.slax.org/internals.php