Void Linux Installation Guide with Disk Encryption (except boot), Btrfs, rEFInd
Warning: this guide was written late 2023, and was updated on October, 29th 2024. Follow this guide at your own risk!
Installation Image
We suppose that the reader uses Linux to install the Void image on an external drive.
Get it here. In most cases, you may want to
pick x86_64
, base
, “Live Image” (glibc
. Installing rEFInd with musl
does not work). Also get sha256sum.txt
and sha256sum.sig
(just above the
x86_64
button).
Install minisign
with your package manager. Check integrity and signatures of
the files with 1:
wget 'https://github.com/void-linux/void-packages/tree/master/srcpkgs/void-release-keys/files/void-release-20240314.pub'
minisign -V -p void-release-20240314.pub -x sha256sum.sig -m sha256sum.txt
sha256sum -c --ignore-missing sha256sum.txt
Example of correct minisign
output:
Signature and comment signature verified
Trusted comment: This key is only valid for images with date 20240314.
For sha256sum
:
void-live-x86_64-20240314-base.iso: OK
Flash the image on an external drive 2. Everything on it will be deleted!
lsblk # Find your USB key
umount /dev/sdX # check it is not mounted (should return `umount: /dev/sdX: not mounted`)
cat void-live-x86_64-20230628-base.iso > /dev/sdX
sync
Void Linux Installation
Boot the external driver. Choose the RAM option for better performance 3.
Log in with root
and password voidlinux
.
Run bash
for a better shell (completion…).
If your keyboard is not QWERTY:
ls /usr/share/kbd/keymaps/i386 # Find your keyboard
loadkeys fr-latin9 # Replace fr-latin9 with your keyboard
Internet Connectivity
For Wi-Fi connection (here with WPA-PSK, that is personal Wi-Fi), find the
right interface with ip a
. We suppose here that it’s wlan0
. Then run:
wpa_cli -i wlan0
Using wpa_cli
, execute:
scan
scan_results
add_network
set_network 0 ssid "MySSID"
set_network 0 psk "passphrase"
enable_network 0
save_config
quit
If your Wi-Fi network does not have any password, run instead set_network 0 key_mgnt NONE
.
Test connectivity with ping
. If it’s still not working, try ip link set up wlan0
or sv restart dhcpd
.
Partitioning
Create two partitions, one for the \boot
partition with 1 GiB 4 and one
for the rest. To do so, use for instance cfdisk -z /dev/nvme0n1
where
/dev/nvme0n1
is the disk where you want to install Void (check with lsblk
)
5. Be careful with this command as you will lose any files on the disk.
Choose gpt
for the label
, and choose EFI System
for the type of the first
partition. Leave the default for the second (Linux filesystem
). Finish with
Write
.
Filesystem and Disk Encryption
mkfs.vfat -F32 /dev/nvme0n1p1
cryptsetup luksFormat /dev/nvme0n1p2 # choose a password
cryptsetup open /dev/nvme0n1p2 cryptroot
mkfs.btrfs /dev/mapper/cryptroot
mount /dev/mapper/cryptroot /mnt
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@snapshots
btrfs subvolume create /mnt/@var_log
btrfs subvolume create /mnt/@swap
umount /mnt
mount -o defaults,subvol=@ /dev/mapper/cryptroot /mnt
mkdir -p /mnt/boot && mount /dev/nvme0n1p1 /mnt/boot
mkdir -p /mnt/home && mount -o defaults,subvol=@home /dev/mapper/cryptroot /mnt/home
mkdir -p /mnt/.snapshots && mount -o defaults,subvol=@snapshots /dev/mapper/cryptroot /mnt/.snapshots
mkdir -p /mnt/var/log && mount -o defaults,subvol=@var_log /dev/mapper/cryptroot /mnt/var/log
mkdir -p /mnt/swap && mount -o defaults,subvol=@swap /dev/mapper/cryptroot /mnt/swap
System Installation
Choose a official mirror close to you, and run this accordingly 6:
REPO=https://repo-default.voidlinux.org/current
ARCH=x86_64
Copy the Void keys to install packages:
mkdir -p /mnt/var/db/xbps/keys
cp /var/db/xbps/keys/* /mnt/var/db/xbps/keys/
Install the system:
XBPS_ARCH=$ARCH xbps-install -S -r /mnt -R "$REPO" base-system btrfs-progs cryptsetup refind vim # Or nano
Chroot Environment
System Configuration
xchroot /mnt /bin/bash
Then in the Chroot environment:
vim /etc/hostname # Choose a hostname
vim /etc/rc.conf # Or nano. Change the keyboard if needed
ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime # Pick your own timezone
vim /etc/default/libc-locales # Uncomment the relevant locales for you
xbps-reconfigure -f glibc-locales
Then:
passwd # Root password
useradd -m myuser # Create a given user
passwd myuser # Set its password
gpasswd -a myser wheel # Make them able to run sudo commands
visudo # Remove comments on one of the wheel lines
fstab
File
cp /proc/mounts /etc/fstab
Edit the fstab
file and remove all lines except the ones with
/dev/mapper/cryptroot
and /dev/nvme0n1p1
(/boot
). Then change the last
0
at the end of all the lines with a 2
, except the line for /
where you
need to change the 0
with a 1
instead. Then run:
BOOT_UUID=$(blkid -s UUID -o value /dev/nvme0n1p1)
ROOT_UUID=$(blkid -s UUID -o value /dev/mapper/cryptroot)
sed -i "s/\/dev\/nvme0n1p1/UUID=$BOOT_UUID/" /etc/fstab
sed -i "s/\/dev\/mapper\/cryptroot/UUID=$ROOT_UUID/" /etc/fstab
echo "/swap/swapfile none swap defaults 0 0" >> /etc/fstab
echo "tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0" >> /etc/fstab
Check the file. It should look like this:
UUID=c52c0f6d-b6b5-4871-8330-8f46c335d5ee / btrfs rw,relatime,space_cache=v2,subvolid=256,subvol=/@ 0 1
UUID=D5FA-4678 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixes,utf8,errors=remount-ro 0 2
UUID=c52c0f6d-b6b5-4871-8330-8f46c335d5ee /home btrfs rw,relatime,space_cache=v2,subvolid=257,subvol=/@home 0 2
UUID=c52c0f6d-b6b5-4871-8330-8f46c335d5ee /var/log btrfs rw,relatime,space_cache=v2,subvolid=258,subvol=/@var_log 0 2
UUID=c52c0f6d-b6b5-4871-8330-8f46c335d5ee /swap btrfs rw,relatime,space_cache=v2,subvolid=260,subvol=/@swap 0 2
UUID=c52c0f6d-b6b5-4871-8330-8f46c335d5ee /.snapshots btrfs rw,relatime,space_cache=v2,subvolid=259,subvol=/@snapshots 0 2
/swap/swapfile none swap defaults 0 0
tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0
Create a swap file. For 8 to 64 GB RAMs, the advised size is 3/2 the size of the RAM, if you plan to use hibernation 5. Example for a RAM of 8 GB:
btrfs filesystem mkswapfile --size 12G --uuid clear /swap/swapfile
swapon /swap/swapfile
SWAP_OFFSET=$(btrfs inspect-internal map-swapfile -r /swap/swapfile)
rEFInd
refind-install
vim /boot/refind_linux.conf
Remove the lines, and run:
echo "\"Boot (quietly)\" \"rw root=UUID=$ROOT_UUID resume=UUID=$ROOT_UUID resume_offset=$SWAP_OFFSET quiet\"" >> /boot/refind_linux.conf
echo "\"Boot\" \"rw root=UUID=$ROOT_UUID resume=UUID=$ROOT_UUID resume_offset=$SWAP_OFFSET\"" >> /boot/refind_linux.conf
Optimize the generation of initramfs
images with 7:
echo "hostonly=yes" > /etc/dracut.conf.d/hostonly.conf
And finally:
xbps-reconfigure -fa
swapoff /swap/swapfile
exit # Exit chroot
umount -R /mnt
reboot
You are done!