void linux install walkthrough

instructions to install void linux on a system with:

working as of 2021.01.01

compiled from pages:

post-boot UEFI check

ensure you've UEFI-booted by verifying the /sys/firmware/efi directory exists:

$ file /sys/firmware/efi

net connect

fetch the network interface ($INTERFACE) you'd like to use (either wireless or wired):

$ ip a

if wireless, fetch the networks SSID and connect:

$ iw $INTERFACE scan | grep SSID
$ wpa_supplicant -B -i $INTERFACE -c <(wpa_passphrase $SSID $PASSWORD)

enable the dhcp client:

$ dhcpcd $INTERFACE

disk setup

select the disk ($OSDISK) you want to use for the operating system:

$ lsblk

discard existing disk sectors (all data on this disk will be lost!):

$ discard /dev/$OSDISK

create the GPT schema:

$ fdisk /dev/$OSDISK

Command: g
Created a new GPT disklabel.

Command: n
Partition number (default 1):
First sector (default 2048):
Last sector: +500M
Created a new partition 1 of type 'Linux filesystem' and of size 500 MiB.

Command: t
Selected partition 1
Partition type or alias: 1
Changed type of partition 'Linux filesystem' to 'EFI System'.

Command: n
Partition number (default 2):
First sector (default 1026048):
Last sector (default 500118158):
Created a new partition 2 of type 'Linux filesystem' and of size 238 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

LUKS encrypt 2nd partition, consider your options, then open:

$ cryptsetup \
    --cipher aes-xts-plain64 \
    --key-size 512 \
    --hash sha512 \
    --iter-time 5000 \
    --use-random \
    luksFormat /dev/${OSDISK}2
$ cryptsetup luksOpen /dev/${OSDISK}2 cryptroot

create the LVM volume group, logical volumes:

$ vgcreate pool /dev/mapper/cryptroot
$ lvcreate --name root -L 30G pool
$ lvcreate --name swap -L 12G pool
$ lvcreate --name home -l 100%FREE pool

create the filesystems, swap:

$ mkfs.fat -F 32 /dev/${OSDISK}1
$ mkfs.ext4 -L root /dev/mapper/pool-root
$ mkfs.ext4 -L home /dev/mapper/pool-home
$ mkswap /dev/mapper/pool-swap

mount the filesystems, enable swap:

$ mount /dev/mapper/pool-root /mnt
$ mkdir /mnt/{boot,home}
$ mount /dev/${OSDISK}2 /mnt/boot
$ mount /dev/mapper/pool-home /mnt/home
$ swapon /dev/mapper/pool-swap

install system

$ export XBPS_ARCH=x86_64-musl
$ xbps-install -Sy \
    --repository=https://alpha.de.repo.voidlinux.org/current/musl \
    --rootdir /mnt \
    base-system cryptsetup lvm2 grub-x86_64-efi \
vim

verify RSA key

$ mount -t proc /proc /mnt/proc
$ mount --rbind /dev /mnt/dev
$ mount --rbind /sys /mnt/sys

$ cat /proc/mounts >> /etc/fstab
$ vim /etc/fstab

GRUB_CMDLINE_LINUX_DEFAULT="loglevel=4 rd.auto=1 rd.luks.allow-discards"

$ echo 'hostonly=yes' >> /etc/dracut.conf.d/override.conf
$ grub-install --target=x86_64-efi --efi-directory=/boot/efi
$ grub-mkconfig -o /boot/grub/grub.cfg

$ echo $HOSTNAME > /etc/hostname
$ passwd

$ xbps-reconfigure -fa

$ exit
$ umount -R /mnt
$ reboot