A simple Void Linux base installation
This blog entry will demonstrate how to install a luks encrypted x86_64 Void Linux musl/UEFI signed UKI operating system on a ext4 filesystem. This entry is based on the Void Handbook and the Void man pages.
Provisioning
Flash the Void Linux musl ISO. After booting the ISO, partition the disk with either fdisk or cfdisk. Create an EFI System partition (ESP) and a Linux Filesystem partition (LFP).
It should look something like this:
| Partition | Size | Type |
|---|---|---|
| 1 | 512MB | EFI System |
| 2 | Rest | Linux filesystem |
Format the ESP with a FAT 32 filesystem:
Encrypt the LFP with luks:
Open the encrypted partition and format it with a ext4 filesystem:
Installation
To install Void Linux on the system, the ESP and LFP have to be mounted to the live (ISO) environment:
sh# mount -t ext4 /dev/mapper/root /mnt
sh# mkdir /mnt/efi
sh# mount -t vfat /dev/disk/by-label/esp /mnt/efi
Now we may install Void Linux musl with xbps-install:
sh# xbps-install -Sy -R https://repo-default.voidlinux.org/current/musl -r /mnt base-system cryptsetup openntpd
To have a functional chroot into the system, copy resolv.conf and bind the system process directories:
sh# cp /etc/resolv.conf /mnt/etc/
sh# for dir in dev proc sys run; do
> mount --rbind --make-rslave /$dir /mnt/$dir
> done
sh# chroot /mnt
Configure some key aspects of the system:
sh# echo <hostname> > /etc/hostname
sh# ln -sf /usr/share/zoneinfo/<area>/<subarea> /etc/localtime
sh# ln -s /etc/sv/dhcpcd /var/service/
sh# ln -s /etc/sv/opennptd /var/service/
sh# ln -s /etc/sv/acpid /var/service/
sh# passwd root #(1)!
- The root password does not really matter because it is going to be locked after a user has been created.
Add the encrypted partition to the crypttab:
-
The simplest way to add the
uuidinto/etc/crypttabis by performing:
and enable the crypttab module for dracut:
Edit the fstab to set the correct mounts:
/dev/disk/by-label/root / ext4 defaults,noatime 0 1
/dev/disk/by-label/esp /efi vfat defaults,nodev,nosuid,noexec,umask=0077 0 2
tmpfs /tmp tmpfs rw,nodev,nosuid,noexec,mode=1777 0 0
proc /proc proc nodev,nosuid,noexec,hidepid=2 0 0
Configure the kernel command-line:
hostonly="yes"
kernel_cmdline="rw rd.luks.name=<uuid>=root root=/dev/mapper/root quiet splash" #(1)!
-
The simplest way to add the
uuidinto/etc/dracut.conf.d/cmdline.confis by performing:
Install the bootloader systemd-boot and some hooks for dracut (1) necessary for building and signing the Unified Kernel Image (UKI):
- The initramfs builder.
Verify that secureboot mode is in
setup modewithsbctl status.
Replace the default dracut kernel hooks with those provided by dracut-uefi:
and set the directory where the UKI will be deposited:
Create and enroll the secureboot keys into the system:
- Whilst enrolling the keys it might be necessary to add the
--microsoftflag if you are unable to use custom keys.
Set the key and certificate required for signing the UKI:
uefi_secureboot_cert="/var/lib/sbctl/keys/db/db.pem"
uefi_secureboot_key="/var/lib/sbctl/keys/db/db.key"
Install the bootloader:
Configure the bootloader:
Sign the bootloader with sbctl:
Finally, reconfigure the kernel to execute the dracut-uefi hook:
One may verify the signed files by running
sbctl verify.
Now exit the chroot, unmount the filesystem and reboot:
Post installation
Firmware and drivers
Install the device firmware for either AMD or Intel:
Swap
Add swap by creating a swapfile:
- To create a swapfile of different size (now 4 GB), change the
countto the desirable size.
Assign the correct permissions to the swapfile and make swap from the swapfile:
Enable the swap:
and make it persistent by adding it to the fstab:
Reconfigure the kernel:
Users
To run processes securely, in an environment with fewer privileges, a user is necessary.
Before creating the user, install doas, to be able to "do as" root when it is required:
and configure doas by editing:
The alternative package sudo that is present in the base-system will be removed, since it is bloatware. To persist this, that is sudo will not be installed ever again on the system, insert:
and remove sudo:
Create a symbolic link from doas to sudo to impose backward compatiblility:
We can add a user, set its password and add it to the wheel group with:
You may have to change the shell of the user in /etc/passwd from /sbin/nologin to a shell from /etc/shells. Void Linux comes with /bin/bash by default:
If you have checked that doas works with the user then you can lock the root account because it imposes security risks if it is kept open. This can be done with:
and by changing its login shell to:
Networking
For desktop use NetworkManager is preferred over dhcpcd as network daemon, due to its versatility, i.e. Wi-Fi and VPN compatibility, MAC randomisation, et cetera. Install NetworkManager with:
Configure NetworkManager with MAC randomisation:
[main]
hostname-mode=none
plugins=ifupdown,keyfile
[ifupdown]
managed=true
[device]
wifi.scan-rand-mac-address=yes
[connection-mac-randomization]
ethernet.cloned-mac-address=random
wifi.cloned-mac-address=random
Disable dhcpcd and enable the NetworkManager daemon and its dependency, the dbus daemon:
sh# rm -rf /var/service/dhcpcd
sh# ln -s /etc/sv/dbus /var/service/
sh# ln -s /etc/sv/NetworkManager /var/service/
For users to be able to modify connections on the system they will have to be added to the network group.
Concluding remarks
This is the bare minimum for a Void Linux desktop system. Some additional features such as bluetooth, laptop battery management, printer compatiblity, et cetera, have been documented well in the Void Handbook, and can thus be found there. The next steps are the improvement of the security of the system and the configuration of the graphical user interface.