Skip to content

Instantly share code, notes, and snippets.

@lnlsn
Forked from vibowit/README.md
Created May 25, 2022 19:57
Show Gist options
  • Select an option

  • Save lnlsn/4ed3afb2dc68b9079251b48e1ee2125f to your computer and use it in GitHub Desktop.

Select an option

Save lnlsn/4ed3afb2dc68b9079251b48e1ee2125f to your computer and use it in GitHub Desktop.
Void Linux Installation Guide (UEFI + chroot + brtfs + LUKS Encryption)

Void Linux installation guide!

Live image

Logging in

User is anon and password is voidlinux.

Setting keyboard layout

# loadkeys $(ls /usr/share/kbd/keymaps/i386/**/*.map.gz | grep br-abnt2)

Connecting to the internet

# cp /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant-<interface>.conf
# wpa_passphrase <ssid> <passphrase> | tee -a /etc/wpa_supplicant/wpa_supplicant-<interface>.conf
# sv restart dhcpcd
# ip link set up <interface>

Formatting disk

Run:

# fdisk /dev/sda

Then:

  1. Select g to generate a GTP table
  2. Select n to create the EFI partition with size of +200M
  3. Change the created partition's type by selecting t and then selecting the option that represents EFI Partition
  4. Select n to create the GRUB partition with size of +500M
  5. Select n to create the btrfs partition with the remaining size

Creating the filesystems

# mkfs.vfat -n boot -F 32 /dev/sda1
# mkfs.ext2 -L GRUB /dev/sda2
# cryptsetup luksFormat --type=luks -s=512 /dev/sda3
# cryptsetup open /dev/sda3 cryptroot
# mkfs.btrfs -L void /dev/mapper/cryptroot

Mounting the btrfspartition and creating subvolumes

# mount -o rw,noatime,ssd,compress=zstd,space_cache,commit=120 /dev/mapper/cryptroot /mnt
# btrfs subvolume create /mnt/@
# btrfs subvolume create /mnt/@home
# btrfs subvolume create /mnt/@snapshots

Mounting top-level partitions

# umount /mnt
# mount -o rw,noatime,ssd,compress=zstd,space_cache,commit=120,subvol=@ /dev/mapper/cryptroot /mnt
# mkdir -p /mnt/home
# mkdir -p /mnt/.snapshots
# mount -o rw,noatime,ssd,compress=zstd,space_cache,commit=120,subvol=@home /dev/mapper/cryptroot /mnt/home
# mount -o rw,noatime,ssd,compress=zstd,space_cache,commit=120,subvol=@snapshots /dev/mapper/cryptroot /mnt/.snapshots
# mkdir /mnt/boot
# mount -o rw,noatime /dev/sda2 /mnt/boot
# mkdir /mnt/boot/efi
# mount -o rw,noatime /dev/sda1 /mnt/boot/efi

Creating nested partitions

# mkdir -p /mnt/var/cache
# btrfs subvolume create /mnt/var/cache/xbps
# btrfs subvolume create /mnt/var/tmp
# btrfs subvolume create /mnt/srv

Installing the base system

# export XBPS_ARCH=x86_64-musl
# xbps-install -Sy -R https://alpha.de.repo.voidlinux.org/current/musl -r /mnt base-system btrfs-progs cryptsetup grub-x86_64-efi

Running chroot

# mount -t proc proc /mnt/proc
# mount -t sysfs sys /mnt/sys
# mount -o bind /dev /mnt/dev
# mount -t devpts pts /mnt/dev/pts
# cp -L /etc/resolv.conf /mnt/etc/
# cd /mnt
# chroot /mnt /bin/bash
# passwd root
# chown root:root /
# chmod 755 /
# echo <hostname> > /etc/hostname

Then edit the file /etc/rc.conf to contain the following:

HOSTNAME="<hostname>"

# Set RTC to UTC or localtime.
HARDWARECLOCK="UTC"

# Set timezone, availables timezones at /usr/share/zoneinfo.
TIMEZONE="America/Sao_Paulo"

# Keymap to load, see loadkeys(8).
KEYMAP="br-abnt2"

# Console font to load, see setfont(8).
#FONT="lat9w-16"

# Console map to load, see setfont(8).
#FONT_MAP=

# Font unimap to load, see setfont(8).
#FONT_UNIMAP=

# Kernel modules to load, delimited by blanks.
#MODULES=""

Then run the following commands:

# echo 'GRUB_CMDLINE_LINUX="rd.luks=1 rd.luks.uuid=<luks-device-uuid>"' >> /etc/default/grub
# echo 'add_dracutmodules+="crypt btrfs resume"' >> /etc/dracut.conf
# echo 'tmpdir=/tmp' >> /etc/dracut.conf
# dracut --force --hostonly --kver <kernel-version>
# grub-mkconfig -o /boot/grub/grub.cfg
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=void_grub --boot-directory=/boot --recheck --debug
# xbps-install -S void-repo-nonfree
# xbps-install -Su
# xbps-install intel-ucode
# echo 'early_microcode="yes"' >> /etc/dracut.conf.d/intel_ucode.conf
# xbps-reconfigure -f linux<kernel-version-major.minor>
# exit
# exit
# umount -R /mnt
# reboot

Note: one can also add splash quiet to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub.

Post-installation

Creating the main user and adding them to sudoers

Log in as root

# xbps-install -S zsh
# usermod -m -G wheel -s $(which zsh) <username>
# passwd <username>
# visudo

After running visudo, uncomment the line that contains %wheel.

Connecting to the internet

Run the proper wpa_supplicant steps to set Wi-Fi or stuff you need. Then, register and start the needed services:

sudo ln -s /etc/sv/dhcpcd /var/service/
sudo ln -s /etc/sv/wpa_supplicant /var/service/

By symlinking the services, runit will pick them up in the next five seconds and start them!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment