1. Computers
  2. Display Drivers
  3. Graphics Cards
  4. Memory
  5. Motherboards
  6. Processors
  7. Software
  8. Storage
  9. Operating Systems


Facebook RSS Twitter Twitter Google Plus


Phoronix Test Suite

OpenBenchmarking.org

Booting A Modern Linux Desktop In Just ~200MB

Tomas Matejicek

Published on 26 December 2012
Written by Tomas Matejicek
Page 3 of 3 - 10 Comments

Putting It Together With AuFS

Various parts of the final root filesystem are now mounted read-only under separated folders in /memory/bundles. Core Linux system utilities and libraries such as /bin/bash or /lib/ld-linux.so are located in /memory/bundles/01-core.sb/, files related to KDE desktop environment can be found in /memory/bundles/04-kde.sb/, and so on. Combining them into a single root filesystem, which is even writable, is only possible thanks to AUFS - an union-like filesystem developed by Mr. Junjiro Okajima. AUFS is capable of taking several folders (so called branches) and combining them together to a single directory. That is exactly what happens next, the separated parts are combined, together with a directory /memory/changes/, to AUFS union, which gets mounted at /memory/union.

Changes

The empty directory /memory/changes is writable, thus the entire AUFS mount in /memory/union happens to be writable as well. All new or changed files inside the union are copied-up to this empty directory before the system creates or modifies them. Since the directory for changes resides on tmpfs (that is in RAM), all new and modified files are stored in RAM and thus are lost on reboot.

Yet if Slax is started from a writable media such as USB device or hard disk, it recognizes that and mounts the writable drive over /memory/changes before it is joined with the other branches in union, which effectively means that changed and new files will be stored on the boot device rather than in RAM, and reboot won't erase them. This feature is called Persistent Changes and can be turned on or off by a boot menu setting.

Switching To The Real Root

At this point, fully writable final root filesystem has been built in /memory/union. The temporary init's life is coming to its end. It uses pivot_root and chroot system calls to make /memory/union the new root, transferring the temporary tmpfs root to /mnt/live/ in the new root. Blue and green stars at the diagram below denote what moves where. Finally, the real /sbin/init from aufs root filesystem is executed. The booting of Slax operating system just begins.

Adding Modules To Slax On The Fly

The root filesystem is writable and we could install new software packages while running Slax just the usual way, by unpacking them. Yet there is another possibility to add new files and directories to Slax on the fly without installing any packages. Thanks to the fact Slax is running with AUFS as root, we can take some other squashfs compressed filesystem, loop-mount it over a directory which resides outside of the aufs tree (for example over /mnt/live/memory/bundles/name.sb/ which is on tmpfs), and then issue a remount command which adds the newly mounted directory to aufs as a new branch.

All the files and directories from the new squashfs module will instantly appear as like if they were installed in the system from the beginning, while decompression is done on the fly, only for the files which are actually accessed.

Similarly, we can remove a previously added AUFS branch (mounted squashfs) from the aufs root by another remount command. The files which were part of the branch will instantly disappear from the system, which effectively uninstalls the package.

Slax Shutdown

When Slax is shutting down either for reboot or for system power off, it performs all the standard tasks as every other Linux would do, like unmounting all partitions mounted by the user, terminating all processes, and so on. But since the boot device may be still mounted and used for persistent changes at the very end, some more steps need to be done before the real power off is issued, to ensure the boot device is cleanly unmounted.

Instead of turning the system off at the moment when init thinks it should do that, Slax executes a cleanup script which resides in /mnt/live/lib/cleanup. This script calls pivot_root and chroot as we know it in order to change the root filesystem back to the tmpfs again. That is exactly the opposite of what was described in the sections called Switching to the real root.

When the root filesystem is switched back to tmpfs, 'telinit u' is executed to inform the current init process to terminate (it would otherwise block the union from unmounting) and re-execute the cleanup script as a new init. The union is no longer blocked since there are no open files and no running processes on it any longer. It is properly unmounted, all loop-mounts disconnected and the boot device is cleanly ejected. At the end, the computer reboots or shuts down, depending on what the user intended to do.

Download the latest release of Slax Linux at Slax.org.

Latest Linux Hardware Reviews
  1. ASRock X99 Extreme3 Is An Affordable Choice For Linux Users
  2. A Walkthrough Of The New 32 System Open-Source Linux Benchmarking Test Farm
  3. Habey MITX-6771: Mini-ITX Board With Quad-Core J1900 Bay Trail
  4. OCZ Vector 150 SSD On Linux
Latest Linux Articles
  1. 17-Way Linux Graphics Card Comparison With Civilization Beyond Earth
  2. AMD Kaveri: Open-Source Radeon Gallium3D vs. Catalyst 14.12 Omega Driver
  3. 12-Way AMD Catalyst 14.12 vs. NVIDIA 346 Series Linux GPU Comparison
  4. AMD Catalyst 14.12 Omega Driver Brings Mixed Results For Linux Users
Latest Linux News
  1. Features Of The Linux 3.19 Kernel: Graphics & Disks Rule
  2. Orange Pi Is The Latest Raspberry Pi Inspired ARM Board
  3. An Open-Source Hardware Ambient Light Sensor Is Brought Up
  4. Heterogeneous Memory Management Is Coming Along For The Linux Kernel
  5. NTP Is The Latest Project Struck By Security Issues
  6. LDC 0.15.1 Released For A D Compiler In LLVM
  7. Fedora Doesn't Yet Enable F2FS File-System Support
  8. XZ 5.2 Adds New Multi-Threaded Options
  9. Intel 2.99.917 X.Org Driver Released, 3.0 Release Finally Near
  10. Server-Side XCB Is Being Discussed For The X.Org Server
Latest Forum Discussions
  1. Looking for an nVidia GPU, but not sure how well they are supported.
  2. No OpenCL with latest driver updates on Ubuntu?
  3. Need some hand holding with upgrading xserver
  4. Maker3D - create your 3D RPG
  5. FPS capped on Linux (AMD fglrx drivers)
  6. Speeding up systemd networking service
  7. Major Performance Breakthrough Discovered For Intel's Mesa Driver
  8. Are there an app using HSA ?