CRUX: a tiny gem of a distro

CRUX (https://crux.nu/) is a slim, highly-customisable Linux distribution, designed with simplicity in mind. It usually stays out of the spotlights and scores below 100 in DistroWatch’s popularity rating (not that this means much). Nevertheless, the project is over 20 years old, mature, and provides a clean, transparent and elegantly laid out system. This review aims to cover some of its concepts.

CRUX is an independent distribution, created by Per Lidén in 2001. Version 0.9.1 was released on the 03 of October. The officially supported architecture since 2013 is x86_64, but the system is multilib-ready: the compiler can build 32bit applications and there’s an official repository for a 32bit “layer”. At the moment, CRUX is at version 3.7.

Getting started

The CRUX Handbook is excellent, covering everything you need in order to install and set up the system. The information is concise and well structured — it takes about an hour or two, to read it thoroughly. The text is always to the point, with nothing unnecessary or redundant. It can serve as an example of how documentation should be written. Apart from that, CRUX’s website has a small wiki, covering different settings, tips and tricks.

Release cycle

A new version of CRUX is released every year or so. The system receives frequent updates, with a pace that is on par with that of rolling-release distros. In addition to the official release ISO image, an updated (unofficial) install media is regularly prepared. So, if you want to install CRUX, say, half a year after its latest release, you can easily just grab the updated ISO.

Installation and configuration

The installation requires you to manually partition your hard drive, activate swap and format / mount your partitions. Contrary to what I have read in some other review, CRUX does have an installer, called simply setup. There, you can select the package categories you wish to install: core, opt and xorg. You can choose only core, if you want a really small system. Additional stuff is in opt, while the X series reside in xorg. You can also select packages individually, as the installer is dependencies-aware. You’ll be asked to install at least one bootloader: grub, grub-efi or syslinux. Below are a few screenshots from the process:

After packages are installed, some manual configuration needs to be done. There’s a script to easily chroot into your newly installed system so you can take it from there. Importantly, CRUX does not come with a pre-compiled kernel, just the source, so you need to build it yourself. The basic .config file in /usr/src/linux-??? can be used as a starting point; a user-contributed modular config file is also provided on the installation media. You should set up /etc/fstab, generate locales (quite automatic), etc., as well as edit the central configuration file of CRUX: /etc/rc.conf. There, you specify font, keymap, timezone, hostname, syslog and startup services. There’s no systemd, CRUX uses BSD-style init-scripts.

Ports and package management

CRUX features a ports system where produced packages are named as: name#1.0-1.pkg.tar.gz. Building and package management is done by own tools: pkgmk to build, pkgadd to install/upgrade and pkgrm to remove. I find it nice that the command names are short and roll smoothly on the keyboard. They are all part of the pkgutils suite, initially developed by Per Lidén. By default, packages are compiled with -O2 -march=x86-64 -pipe flags. Package building in CRUX is very well organized. For example, you can specify the following in /etc/pkgmk.conf: number of CPU cores to use when building, the place where you want sources to be downloaded, where packages to be built, where packages to be stored, etc. Installing, upgrading or removing the created packages is very fast. Seriously, to me the speed is just mind-blowing.

The ports collection that comes with CRUX is rather small, but contents are carefully selected. The system ships 5 categories: the three categories from the install (core, opt, xorg), compat-32 (for 32bit packages, inactive by default) and contrib (inactive by default). The latter is a collection provided by experienced port-maintainers, which however is not maintained by the CRUX development team. Categories are activated and their ports are synced with upstream through specific files for synchronization, found in /etc/ports. Ports themselves reside in /usr/ports. To sync (update) your ports:

# ports -u

Personal ports collections, submitted by other users, are available at the portdb section of the web-site. So, if you need something for which no port is available, you can check there. Or, you can create a port yourself (see below).

After a fresh install, all upcoming updates are carried out by building software from source. A tool called prt-get, provides an advanced ports management on top of pkgutils, by handling dependencies, facilitating updates and much more. You can view dependencies trees of ports or display reverse-dependencies (what depends on a port):

$ prt-get depends lynx
-- dependencies ([i] = installed)
[i] ncurses
[i] openssl
[i] zlib
[i] lynx

$ prt-get dependent lynx
xdg-utils

To check for potential updates and update them all by compiling packages in the correct order:

$ prt-get diff
# prt-get sysup

Another tool, pkg-get, aims to mimic prt-get but for a repository of ready packages. So, you can easily install packages created on one system to another. If you want a menu-driven program that deals with packages, you can check yapo from opt:

Creating a port

A CRUX port represents a folder named after the program/library to be built, containing a Pkgfile with build instructions. It is pleasantly clutter-free and can be as simple, as:

# Description: A sequence/alignment format checker and converter
# URL: ftp://ftp.pasteur.fr/pub/gensoft/projects/squizz/
# Maintainer: Petar Petrov, slackalaxy at gmail dot com
# Depends on:

name=squizz
version=0.99d
release=1
source=(ftp://ftp.pasteur.fr/pub/gensoft/projects/$name/$name-$version.tar.gz)

build() {
cd $name-$version
./configure --prefix=/usr

make
make install DESTDIR=$PKG

rm -rf $PKG/usr/share/doc
}

That’s all you need, in order to build squizz — a single Pkgfile. Conveniently, pkgmk automatically strips binaries and compresses man pages. Note that the download link has variables in it, such as $version, making one less thing to change when updating the port for a new version. The Handbook has very specific instructions about packaging: no national language support and no junk such as READMEs, making packages quite trimmed down. Rules about install paths are also clearly defined to ensure consistency.

In CRUX, libraries go to /usr/lib, with /usr/lib64 being a symlink to it. The compatibility 32bit libraries go to /usr/lib32. This eliminates two potential problems: 1) you do not need to worry about adjusting the libraries path, e.g. /usr/lib64; 2) when building, 64bit applications will not try to link against 32bit libraries. Apart from that, there are some peculiarities that I find nice. For example, there’s a /usr/etc folder, leaving /etc only for the most important system stuff.

There’s a collection of additional port/package management tools, called prtutils, that’s very useful. For a new port, a template Pkgfile can be generated by prtcreate. You can use finddeps and findredundantdeps to easily determine the dependencies of your port. Quality check of the package is done by prtverify. Importantly, after a prt-get sysup, it is good to check if something needs recompiling, by revdep.

Desktop environments

CRUX officially comes with openbox, available from opt. I hear using it with tint2 is quite popular; you can find it in contrib. You will need to set up a ~/.xinitrc file yourself. There’s no KDE or Gnome. Unofficially, there’s LXQT and MATE at portdb, however I do not know if these are updated for CRUX 3.7. Also, I have seen Xfce appear every now and then there, but I cannot find it at the moment of writing this.

Community

CRUX has a small, friendly and very competent community in its IRC channel #crux at libera.chat. There, I have received great help with the distribution, compiling and Linux in general. The off-topic discussions that start every now and then are also quite fun. There’s a mailing list, as well.

Using CRUX

I would prefer if CRUX moved at a slower pace with the updates, but on the other hand, no one forces me to constantly update it, right? I normally run prt-get sysup weekly, when I know I’ll have the time to fix things that might break. What does this mean? Sometimes, after a library is updated, packages that depend on it may need to be rebuild against the new version. The process is rather easy, by using revdep to report what needs a rebuild. In a more rare case, however, something may fail to build against the updated library, so I need to find a solution.

Apart from this, I maintain my own repo, which I update when I feel like it.

Conclusions

I suppose, we can call CRUX a semi-source and semi-rolling distribution, offering the best of both worlds: you get an always up-to-date system, that gets cleanly rebuild between releases. The distribution can be easily set up exactly to my liking thanks to its flexibility, its excellent package management tools, and the utilities to help with ports maintenance. Whether you will like it or not is a matter of taste, really; also it depends on what you expect from the distribution: do you want things preconfigured for you, or you want to do it yourself? CRUX is great if you like to tinker with your system and if you are ready to do some (re)compiling. If you are into compiling, you’ll find that dealing with ports and packages is a breeze. I also like the web-page quite a lot — the design is simple and does not get in your way; everything you need is there, in a single, centralized place. Not to mention, the penguin is nothing, but cute!

As a whole, I really like how CRUX is designed. The project may not be big, but I find the result to be a real gem of a distro.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s