Getting to the CRUX of it: Notes on a Great Exploration
CRUX is a lightweight Linux distribution for the x86-64 architecture targeted at experienced Linux users. The primary focus of this distribution is keep it simple, which is reflected in a straightforward tar.gz-based package system, BSD-style initscripts, and a relatively small collection of trimmed packages. The secondary focus is utilization of new Linux features and recent tools and libraries. CRUX also has a ports system which makes it easy to install and upgrade applications.
The handbook of CRUX be found at:
https://crux.nu/Main/Handbook3-8
I recommend you check it out on a regular basis.
Unless stated otherwise all installation steps are performed by the root account. Obviously all steps are based on my hardware and preferences. Your mileage will vary.
Installation notes
Download a recent crux-3.8 iso from:
https://crux.ninja/updated-iso/
These are technically unsupported but usually contain either no changes aside from package updates, or minor functionality changes to the kernel or similar. It saves you time later on in the system update.
Boot into the iso and at the (root) prompt type:
- setfont -d
Check the name of your disk with:
- lsblk
Open cfdisk and partition the disks:
- nvme0n1p1- 512Mb , type EFI
- nvme0n1p2 - 8Gb, type Linux swap
- nvme0n1p3 - 30Gb, root, type Linux filesystem
- nvme0n1p4 - the rest, home, type Linux filesystem
Create the filesystems:
- mkfs.fat -F32 /dev/nvme0n1p1
- mkswap /dev/nvme0n1p2
- mkfs.xfs /dev/nvme0n1p3
- mkfs.xfs /dev/nvme0n1p4
Be aware that I'm using xfs here. This has an implication for the kernel compilation config later on. If you use ext4 here, you don't need to change flags in your kernel config later on. Ext4 is the default in there.
Mount the filesystems:
- mount /dev/nvme0n1p3 /mnt (root filesystem)
- mkdir -p /mnt/{boot/efi,home} (create additional directories)
- mount /dev/nvme0n1p1 /mnt/boot/efi/ (efi directory)
- mount /dev/nvme0n1p4 /mnt/home/ (home directory)
- swapon /dev/nvme0n1p2
Doublecheck the setup with lsblk.
Installation:
- setup
The first steps are self-explanatory, just follow and answer them.
Select the following package collections:
- core
- opt
- xorg
We are going to start out the Slackware way, install everything, so we can't miss anything ;-)
Select bootloader:
- grub2-efi
Chroot into the new system:
- setup-chroot
Create root password:
- passwd
Edit fstab:
vim /etc/fstab (nano is also available from the iso)
Uncomment the variables related to your setup and change the descriptive names (#XFS_HOME) to the actual device id's (/dev/nvme0n1p4).
Setup rc.conf:
- vim /etc/rc.conf
- Adjust according to your situation (hostname, timezone etc.)
- echo "your-hostname" > /etc/hostname
! add dbus to SERVICES !
Create locale:
- vim /etc/locale.gen uncomment your locale, then:
- /usr/sbin/locale-gen
Edit the hosts file:
- vim /etc/hosts
- Under IPv4 add: 127.0.1.1 "your-hostname"
Configuring the kernel:
- cd /usr/src/linux-x.x.x
The easy config:
- zcat /proc/config.gz > .config
- vim .config
Options to change:
- CONFIG_XFS_FS=y
- CONFIG_PCI_MMCONFIG=y
- CONFIG_DRM=y
- CONFIG_DRM_"specific gpu (in my case AMDGPU)"=y
Then:
- make olddefconfig
Check the created .config file for the changes above. Remember these options should be adjusted to your setup!
Prepare kernel compilation:
- nproc (this will tell you the number of available cores, in my case 12)
Run that first compile:
- make -j12
Then:
- make modules_install
- cp arch/x86/boot/bzImage /boot/vmlinuz-x.x.x (fill in the number of the kernel you have compiled, in my case vmlinuz-6.18.40)
- cp System.map /boot
Install grub and reboot:
- grub-install /boot/efi
- grub-mkconfig > /boot/grub/grub.cfg
Subsequently:
- exit
- umount -R /mnt
- swapoff /dev/nvme0n1p2
- reboot
Post Installation
Ports live in /usr/ports and are organized by collection. Each port is a directory containing a Pkgfile (basically a shell script that downloads, builds and packages sofware).
We now have the Core, Opt and Xorg collections earmarked for the system, but there are more unoffical ports collections that can be found at:
https://crux.ninja/portdb/
There's also a large collection of ports available in Contrib, but it is disabled by default.
Port management is done throught prt-get, so let's first enable Contrib:
- vim /etc/prt-get.conf
- Uncomment prtdir /usr/ports/contrib
- Rename /usr/ports/contrib.rsync.inactive > contrib.rsync
Download all activated ports onto the system:
- ports -u
Let's install mc (Midnight Commander) and make our life a bit easier by using prt-get (a package mgmnt frontend for Crux):
- prt-get depinst mc
By using 'depinst' dependencies will be downloaded and installed as well. You could of course also go to:
- /usr/ports/opt/mc
- pkgmk -d
- pkgadd mc#x.x (x.x refers to the actual version number of mc)
In both cases it is wise to edit /etc/pkgmk.conf and enable parallel processing by uncommenting:
- export JOBS=$(nproc)
- export MAKEFLAGS="-j $JOBS"
Let's add a regular user:
- useradd -m -G wheel $USER
- passwd $USER
- visudo > uncomment the infamous %wheel line
I install opendoas later and add the regular user to /etc/doas.conf.
Kernel update
One of our chores is compiling and updating the kernel on a regular basis. This is how I do it:
- prt-get depinst wget
- wget https://cdn.kernel.org/pub/linux/kernel/v7.x/linux-7.2.6.tar.xz (check for the latest stable version)
- tar -xvpf linux-7.2.6.tar.xz
- mv linux-7.2.6 /usr/src/linux-7.2.6
After that follow the instructions above for kernel compilation and grub-mkconfig.
Over time you can start removing older kernels, but I'd always keep one 'old' working kernel as a fallback.
Additional ports
The basic ports provided in Xorg, Core, Opt and Contrib are already a pretty big collection. But the fun is of course in adding and enabling 3rd party ports databases. As mentioned before you can find a lot of them @ https://crux.ninja/portdb/.
As always I urge you to check out the related repo's before enabling them. Some I found were pretty old and seemed almost unmaintained; others deliver the latest and greatest. It is your personal choice and responsability, but let me show you how to enable a 3rd party repo.
In this example I'll enable the Portastrophe repo, which provides a great collection of stuff. I've known Jay (the maintainer) for a couple of years now, and he's become a trusted source of great software for me.
First download the necessary files:
- wget --no-ch https://codeberg.org/jlngn/portastrophe/raw/branch/3.8/portastrophe.httpup
- wget --no-ch https://codeberg.org/jlngn/portastrophe/raw/branch/3.8/portastrophe.pub
Move the downloaded files to the proper folder:
- sudo mv portastrophe.httpup portastrophe.pub /etc/ports/
Create the dir where the ports will be contained:
- sudo mkdir /usr/ports/portastrophe
Add the specific ports line in your /etc/prt-get.conf to fetch the repo:
- prtdir /usr/ports/portastrophe
Update the repo onto your computer:
- sudo ports -u portastrophe
You can now install things like niri, noctalia, fuzzel and ghostty onto CRUX!
Final steps
During installation some optional dependencies might not have been installed. That feature is being worked on as we speak, but it is recommended to rebuild all locally installed packages after you've finished your base install with a command like this:
cd /usr/ports/{opt,xorg,contrib,portastrophe}; for i in *; do prt-get update -fr "$i"; done
This will ensure all ports are recompiled and any optional depends are picked up along the way.
If you only installed the "core" ports when initially installing CRUX, this may be a required step.
Later on we will use this to update our system:
- prt-get sysup
Now you're good to go to use CRUX and build your own system ;-)
Shoutout for inspiration and tips to:
Jay Lanagan @ https://lngn.net/
Tony Banters @ https://tonybtw.com/
Feel free to use these builds and dots as you like. I do not, however, imply any form of support or ongoing maintenance.
And of course, you use them entirely at your own risk. Have fun!