void linux installation

| | | topics: Technology > notes | keywords: linux luks lvm void
id: 20803e5e-e2d3-4296-a5ad-30cbc056d59a

Cheat sheet for a quick void installation with luks. /boot is not encrypted.

Boot

Boot using ubuntu iso or something like that since voidlinux's .iso available at the time of writing did not have drivers for the network interface.

load required modules

modprobe efivars
modprobe dm-crypt
# start the lvm service if not running

Create partitions, volume group, and logical volumes

parted -a optimal /dev/sda
unit mib
mklabel gpt
mkpart primary fat32 1 513
name 1 "EFI System Partition"
set 1 BOOT on
mkpart primary 513 2561
name 2 "boot partition"
mkpart primary 2561 -1
name 3 "encrypted lvm"
quit

Adjust accordingly:

export EFI_PARTITION=/dev/sda1
export BOOT_PARTITION=/dev/sda2
export SYSTEM_PARTITION=/dev/sda3

cryptsetup luksFormat $SYSTEM_PARTITION
cryptsetup luksOpen $SYSTEM_PARTITION crypt_system

if you need to mount the volumes:

vgscan --mknodes
vgchange -ay
lvm pvcreate /dev/mapper/crypt_system
vgcreate void_vg /dev/mapper/crypt_system
lvcreate -C y -L 2G -n swap void_vg
lvcreate -l 100%FREE -n root void_vg

mkfs.fat -F32 $EFI_PARTITION
mkfs.ext4 $BOOT_PARTITION
mkfs.btrfs /dev/mapper/void_vg-root
mkswap /dev/mapper/void_vg-swap
swapon /dev/mapper/void_vg-swap

mkdir /mnt/void
mount /dev/mapper/void_vg-root /mnt/void
mkdir /mnt/void/dev && mount --rbind /dev /mnt/void/dev && mount --make-rslave /mnt/void/dev
mkdir /mnt/void/proc && mount --rbind /proc /mnt/void/proc && mount --make-rslave /mnt/void/proc
mkdir /mnt/void/sys && mount --rbind /sys /mnt/void/sys && mount --make-rslave /mnt/void/sys

mkdir /mnt/void/boot
mount $BOOT_PARTITION /mnt/void/boot
mkdir /mnt/void/boot/efi
mkdir /mnt/void/boot/grub
mount $EFI_PARTITION /mnt/void/boot/efi

Fetching and installing rootfs

wget https://alpha.de.repo.voidlinux.org/live/current/void-x86_64-ROOTFS-20191109.tar.xz
tar xvf void-x86_64-ROOTFS-20191109.tar.xz -C /mnt/void

chroot into new system

cp /etc/resolv.conf /mnt/void/etc

PS1='(chroot) # ' chroot /mnt/void /bin/bash
passwd root
xbps-install -Su void-repo-nonfree
xbps-install -Su
xbps-install -u
xbps-install -Su base-system lvm2 cryptsetup grub-x86_64-efi nvidia

echo void > /etc/hostname
echo "LANG=en_US.UTF-8" >> /etc/locale.conf
echo "en_US.UTF-8 UTF-8" >> /etc/default/libc-locales
ln -sf /usr/share/zoneinfo/Europe/Copenhagen /etc/localtime
xbps-reconfigure -f glibc-locales

setting up fstab

mkdir /mnt/data
mv /etc/fstab /etc/fstab.orig

echo UUID=`blkid |grep vg-root |cut -f2 -d\"` / btrfs defaults 0 0 >> /etc/fstab
echo UUID=`blkid |grep 'boot partition' |cut -f2 -d\"` /boot ext4 defaults 0 2 >> /etc/fstab
echo UUID=`blkid |grep 'EFI' |cut -f2 -d\"` /boot/efi vfat umask=0077 0 1 >> /etc/fstab
echo UUID=`blkid | grep vg-swap | cut -f2 -d\"` none swap sw 0 0 >> /etc/fstab
echo hugetlbfs /mnt/hugepages hugetlbfs nodev,noauto,users,rw,mode=0770,gid=1003 0 0 >> /etc/fstab
#hardcoded because the partition doesn't have a label
echo UUID=764521d2-1e29-4f56-afa2-a6362c612205 /mnt/data ext4 defaults,auto 0 1 >> /etc/fstab
echo tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0 >> fstab

Double check against output of blkid.

Grub configuration

echo GRUB_ENABLE_CRYPTODISK=y >> /etc/default/grub
echo GRUB_CMDLINE_LINUX=\"rd.auto=1 dolvm crypt_root=UUID=`blkid |grep crypto_LUKS|cut -f2 -d\\"` root=/dev/mapper/void_vg-root root_trim=yes\" >> /etc/default/grub
grub-mkconfig -o /boot/grub/grub.cfg
grub-install /dev/sda --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id="Void Linux [GRUB]" --recheck

and enable issue_discards in /etc/lvm/lvm.conf.

sed -i 's/issue_discards = 0/issue_discards = 1/g' /etc/lvm/lvm.conf

Create user

useradd -m -s /bin/bash -U -G wheel,users,audio,video,cdrom,input tse,kvm
chown -R tse:tse /mnt/data

Reconfigure

xbps-reconfigure -fa

Potential troubleshooting

NOTE ON BOOT ORDER NOT UPDATING:
Notes/Issues
Notes on Grub2 EFI Loader installation.

Grub2 possesses the ability to install an EFI loader to the EFI System Partition, as well as to modify the BootOrder variable in the system firmware. This works on most well-behaved UEFI imlementations. However, there are reports of a couple of issues on some systems/motherboards:

    The BootOrder variable is not updated.
    The BootOrder is not saved/followed by the system.

If the BootOrder variable fails to be updated, then the system will not boot the newly-installed Void system without some extra configuration.

To confirm that BootOrder has been updated before your final reboot, you can run the command efibootmgr with no arguments. The output should include something like this:

BootOrder: 0000,0003,0004
Boot0000* void_grub
Boot0003* CD/DVD Drive
Boot0004  EFI Internal Shell

See the man page for efibootmgr for more information on the capabilities and use of this program. If you see the option "void_grub" and it is listed first in BootOrder, then the variables have been successfully updated, and you can try to reboot. If not, keep reading.

Workaround:

In cases where BootOrder is either not updated, or not saved/followed after you reboot, then you should try copying grubx64.efi to the common default EFI loader location. You'll need to mount your EFI partition, and we'll assume it's on /mnt/. (In your installed Void system, the mount point would normally be /boot/efi/)

# install -D /mnt/EFI/void_grub/grubx64.efi /mnt/EFI/boot/bootx64.efi

On 32-bit firmware it should be

# install -D /mnt/EFI/void_grub/grubia32.efi /mnt/EFI/boot/bootia32.efi

# grub-install /dev/sda --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id="Void Linux [GRUB]" --recheck

https://www.linuxbabe.com/command-line/how-to-use-linux-efibootmgr-examples