Notes on my Void Linux setup.
Recently I switched the Linux distribution I use on my desktop and laptop to Void from Arch. I had used Void before but switched away from it because there were some packages I use missing from their repositories. That point hasn’t really changed much, but I thought I’d give it another go anyway.
I use an ISO keyboard with a UK layout, I’m also a heavy vim user so a lot of of the decisions I make are personal preference, YMMV. Here’s how I set it up:
Firstly boot the live ISO image into the box you’re doing the installation on (won’t cover that since it’s fairly obvious) and login as root.
Preparation#
Sets TERM variable (especially useful if doing this through ssh) and vim mode for the shell
root@void-live:~ # export TERM=xterm-256colorroot@void-live:~ # alias v=nvimroot@void-live:~ # set -o viroot@void-live:~ # bind -m vi-command 'Control-l: clear-screen'root@void-live:~ # bind -m vi-insert 'Control-l: clear-screen'Change keycode 58 = Escape to make Caps Lock key act as Escape because it’s $currentYear
root@void-live:~ # v /usr/share/kbd/keymaps/i386/qwerty/uk.map.gzroot@void-live:~ # loadkeys ukPing any website to check internet connection
root@void-live:~ # ping gnu.orgCheck whether you’re booted into UEFI or BIOS
root@void-live:~ # ls /sys/firmware/efi/efivarsPartitions#
Create 2 partitions on your drive (first one is just for /boot so I always make it 1GB, which is plenty). Encrypt the second one with LUKS
root@void-live:~ # fdisk /dev/sdaroot@void-live:~ # cryptsetup luksFormat /dev/sda2root@void-live:~ # cryptsetup luksOpen /dev/sda2 [NAMEOFcrypt]LVM setup
root@void-live:~ # pvcreate /dev/mapper/[NAMEOFcrypt]root@void-live:~ # vgcreate [NAMEOF-vg] /dev/mapper/[NAMEOFcrypt]root@void-live:~ # lvcreate --name root -L 100G [NAMEOF-vg]root@void-live:~ # lvcreate --name home -l 100%FREE [NAMEOF-vg]Format the newly created partitions
root@void-live:~ # mkfs.vfat -F32 /dev/sda1root@void-live:~ # mkfs.ext4 -L root /dev/[NAMEOF-vg]/rootroot@void-live:~ # mkfs.ext4 -L home /dev/[NAMEOF-vg]/homeMount the partitions
root@void-live:~ # mount /dev/[NAMEOF-vg]/root /mntroot@void-live:~ # mkdir -p /mnt/{home,boot}root@void-live:~ # mount /dev/[NAMEOF-vg]/home /mnt/homeroot@void-live:~ # mount /dev/sda1 /mnt/bootMount dev proc sys and run in bind mode in order to chroot to /mnt
root@void-live:~ # for dir in dev proc sys run; do mkdir -p /mnt/$dir; mount --rbind /$dir /mnt/$dir; mount --make-rslave /mnt/$dir; doneSystem bootstrap and installation#
root@void-live:~ # xbps-install -Sy -R https://alpha.de.repo.voidlinux.org/current -r /mnt base-system base-devel cryptsetup lvm2 neovim openssh connman connman-ncurses dbus-elogind python3 openntpd grub-x86_64-efiChroot into /mnt and continue installation from there
root@void-live:~ # chroot /mnt bashchroot # chown root:root /chroot # chmod 755 /chroot # echo [NAMEOFbox] > /etc/hostnameModify hosts file to reflect new hostname
chroot # v /etc/hostsSet your timezone, keyboard (I replace Caps_Lock to act as Escape again by setting keycode 58 = Escape), keymap, and locale
chroot # ln -fs /usr/share/zoneinfo/Europe/London /etc/localtimechroot # v /usr/share/kbd/keymaps/i386/qwerty/uk.map.gzchroot # echo "KEYMAP=uk" >> /etc/rc.confchroot # echo "LANG=en_GB.UTF-8" > /etc/locale.confchroot # echo "en_GB.UTF-8 UTF-8" >> /etc/default/libc-localeschroot # xbps-reconfigure -f glibc-localesUsers and groups#
chroot # useradd -m -g wheel [NAMEOFuser]chroot # groupadd libvirtchroot # usermod -a -G audio,video,libvirt,lp [NAMEOFuser]chroot # chown [NAMEOFuser]:wheel -R /home/[NAMEOFuser]chroot # chmod 700 /home/[NAMEOFuser]chroot # passwd [NAMEOFuser]chroot # passwd rootCreate a swapfile#
chroot # dd if=/dev/zero of=/var/swapfile count=8192 bs=1MiBchroot # chmod 600 /var/swapfilechroot # mkswap /var/swapfilechroot # swapon /var/swapfileEdit your fstab#
Use this command to add the UUID of sda1 into the fstab file
chroot # blkid -o value -s UUID /dev/sda1 >> /etc/fstabYour fstab should look like this
/dev/[NAMEOF-vg]/root / ext4 defaults 0 0
/dev/[NAMEOF-vg]/home /home ext4 defaults 0 0
UUID=[UUIDOFsda1] /boot vfat defaults 0 0
/var/swapfile swap swap none 0 0Bootloader#
I use grub as my bootloader, feel free to use any alternatives you like here.
Use this command if running UEFI
chroot # grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id="Void" /dev/sdaUse this one if running BIOS
chroot # grub-install --bootloader-id="Void" /dev/sdaUse this command to add the UUID of the encrypted partition /dev/sda2 into /etc/default/grub
chroot # blkid -o value -s UUID /dev/sda2 >> /etc/default/grubModify /etc/default/grub to look like the following (only need to change LINUX_DEFAULT line)
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 rd.auto=1 cryptdevice=UUID=[UUIDOFsda2]"Update grub.cfg
chroot # grub-mkconfig -o /boot/grub/grub.cfgFinalising#
chroot # rm /var/service/agetty-{tty3,tty4,tty5,tty6}chroot # ln -fs /etc/sv/{sshd,dbus,connmand,openntpd} /var/service/chroot # echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/sudo-wheelchroot # echo "[NAMEOFuser] hard nofile 524288" >> /etc/security/limits.confExit chroot, unmount drives and reboot
chroot # exitroot@void-live:~ # umount -R /mnroot@void-live:~ # rebootRight now you should have a fully functioning Void install, I use an Ansible playbook which sets up my entire graphical environment, dotfiles and other things; maybe I’ll publish that soon.
