How to Set Up a Void Linux Box with Drive on UEFI

1. Prepare Installation Media

2. Boot and Initial Setup

3. Partition the Disk

Optional: swap and home partitions depending on your preference.

Using a swap file instead of a swap partition is generally preferable, since it can be resized easily at any time. It’s also a good practice to keep /home on a separate partition, so if the root partition ever breaks, you can reinstall the system and simply remount the existing home partition without losing your data.

4. Format the Partitions

If you created a home partition, you should allocate the remaining disk space accordingly.

  • Format the root filesystem:
    # mkfs.ext4 /dev/sda2
    # mount /dev/sda2 /mnt
  • Format the EFI partition and mount it:
    # mkfs.vfat /dev/sda1
    # mkdir -p /mnt/boot/efi
    # mount /dev/sda1 /mnt/boot/efi
  • 5. Copy RSA Keys

    # mkdir -p /mnt/var/db/xbps/keys

    Copying the RSA keys from the installer to the new system

    # cp /var/db/xbps/keys/* /mnt/var/db/xbps/keys/

    6. Install Base System

    # xbps-install -Sy -R https://repo-default.voidlinux.org/current -r /mnt \
    base-system grub-x86_64-efi nano NetworkManager efibootmgr

    After that, let’s generate the fstab.

    # xgenfstab /mnt > /mnt/etc/fstab

    7. Chroot into the New System

    Using xchroot to enter the new system.

    # xchroot /mnt
    [xchroot /mnt] # chown root:root /
    [xchroot /mnt] # chmod 755 /

    Give the root user a password.

    [xchroot /mnt] # passwd root

    Set your hostname by replacing VOID with your desired name.

    [xchroot /mnt] # echo VOID > /etc/hostname
    For locale configuration (glibc only):
    [xchroot /mnt] # echo "LANG=en_US.UTF-8" > /etc/locale.conf
    [xchroot /mnt] # echo "en_US.UTF-8 UTF-8" >> /etc/default/libc-locales

    Set the locale by replacing en_US.UTF-8 with your preferred language.

    [xchroot /mnt] # xbps-reconfigure -f glibc-locales

    Reconfigure the locales.

    8. Install GRUB

    Make sure that the device name is correct.

    [xchroot /mnt] # grub-install /dev/sda

    Reconfigures everything and regenerates the GRUB configuration file.

    [xchroot /mnt] # xbps-reconfigure -fa

    To exit the chroot

    [xchroot /mnt] # exit

    Recursively unmount everything mounted under /mnt

    # umount -R /mnt
    # reboot

    You should remove the installation media.

    11. Post-Installation

    After rebooting, entering the passphrase, seeing the GRUB menu, and logging in as root, you should enable the network service.

    # ln -s /etc/sv/NetworkManager /var/service/
    # ln -s /etc/sv/dbus /var/service/

    To start the network manager and dbus services.

    # sv up NetworkManager
    # sv up dbus

    If you are using an Ethernet cable, it connects automatically. For Wi-Fi, run nmtui and activate a connection.

    Edit the resolv.conffile

    # nano /etc/resolv.conf
    nameserver 1.1.1.1
    nameserver 8.8.8.8

    To test the connection, run the following command.

    # ping -c4 voidlinux.org

    Add a new user to your system. The -m option creates a home directory, and -G wheel adds the user to the wheel group (which allows administrative privileges):

    # useradd -mG wheel <yourUserName>
    # passwd <yourUserName>
    

    Replace <yourUserName> with the username you want to create and use.

    Now, edit the sudoers file to give the new user permission to use sudo. Here we set the default editor to nano:

    # EDITOR=nano visudo

    Inside the file, find the following line and uncomment it by removing the # at the beginning:

    %wheel ALL=(ALL:ALL) ALL

    This allows any user in the wheel group to execute commands as root using sudo.

    Reboot and log in as the new user to install some utilities:

    $ sudo xbps-install -S htop ufetch
    $ ufetch

    Et voilà! You now have a base Void Linux system.