How to install Void Linux (DOS/MBR, Legacy Boot, No Encryption)

2020-05-25

(last time edited: 2021-03-14)

tags: linux, void

Void Linux is a general purpose operating system, based on the monolithic Linux® kernel. Its package system allows you to quickly install, update and remove software; software is provided in binary packages or can be built directly from sources with the help of the XBPS source packages collection.

It is available for the Intel x86®, ARM® and MIPS® processor architectures. Software packages can be built natively or cross compiled through the XBPS source packages collection.

At the end of this guide you will have a setup like this:

Download

Download a live image from here.

Choose between the multiple architectures and flavours offered according to your CPU. (x86_64, x86_64-musl, i686, pcc64, pcc64-musl, aarch64-musl, etc.)

Burn

Check your connected storage devices.

# lsblk

Burn the live image.

# dd if=voiddistro.iso of=/dev/sdX

Reboot.

# reboot

Boot

Boot the USB and log in using the following credentials:

user: root
password: voidlinux

Update

Update your live image.

# xbps-install -Su xbps

Partition

Check your connected devices.

# lsblk

Partition your device using fdisk.

# fdisk /dev/sdX

Create a new DOS partition table.

Command (m for help): o

Created a new DOS disklabel with disk identifier XxXXXXXXXXXXXX

Create the first partition. This will be the root partition. Choose a considerable size. (+20G, +30G, +40G, +50G)

Command (m for help): n

Partition type
    p primary (0 primary, 0 extended, 4 free)
    e extended (container for logical partitions)

Select (default p): p

Partition number (1-4, default 1): 1

First sector (xxxxxxxxxxxxxxx-xxxxxxxxxxxxx, default 2048): ENTER

Last sector, +-sectors or +/-size{K,M,G,T,P} (2048-xxxxxxxxx, default xxxxxxxxx): +30G

Created a new partition 1 of type 'xxxxxxxxxxx' and of size 30 GiB.

Optional: Crete a swap partition. It's only recommended when you don't have a lot of RAM.

The Void community recommends 2 times the amount of RAM for systems with less than 2 GB. Equal to the amount of RAM for 2-8GB systems. And 4GB for systems with more than 8GB.

Command (m for help): n

Partition type
    p primary (1 primary, 0 extended, 3 free)
    e extended (container for logical partitions)

Select (default p): p

Partition number (2-4, default 2): 2

First sector (2048-xxxxxxxxx, default 2048): ENTER

Last sector, +-sectors or +/-size{K,M,G,T,P} (2048-xxxxxxxxx, default xxxxxxxxx): +4G

Created a new partition 2 of type 'xxxxxxxxxxx' and of size 4 GiB.

Create a third partition. This will be the home partition.

Command (m for help): n

Partition type
    p primary (2 primary, 0 extended, 2 free)
    e extended (container for logical partitions)

Select (default p): p

Partition number (3-4, default 3): 3

First sector (xxxxxxxxxx-xxxxxxxxxx, default xxxxxxxxxx): ENTER

Last sector, +/-sectors or +/-size{K,M,G,T,P} (xxxxxxxxx-xxxxxxxx, default xxxxxxxxx): ENTER

Created a new partition 3 of type 'xxxxxxxx' and of size X GiB.

Write changes and exit.

Command (m for help): w

The partition table has been altered.
Calling iotcl() to re-read partition table.
Syncing disks.

Re-read the partition table so the Linux kernel see the changes.

# kpartx /dev/sdX

Format

Format swap, root and home partitions.

# mkfs.ext4 /dev/sdX1

Optional: Activate swap if you opted to create a swap partition.

# mkswap /dev/sdX2

# mkfs.ext4 /dev/sdX3

Mount

Create a directory to start working on your new system.

# mkdir /mnt/nusys

Mount the root partition.

# mount /dev/sdX1 /mnt/nusys

Create a home directory in the mounted root volume, in order to mount the home partition.

# mkdir /mnt/nusys/home

Mount the home partition.

# mount /dev/sdX3 /mnt/nusys/home

Bind mount important directories on your new system.

# for DIR in proc sys dev; do mkdir /mnt/nusys/$DIR; done

# mount -t proc /proc /mnt/nusys/proc

# mount -t sysfs /sys /mnt/nusys/sys

# mount -B /dev /mnt/nusys/dev

# mount -t devpts pts /mnt/nusys/dev/pts

Install

Install base-system, linux and GRUB.

# xbps-install -S -R https://alpha.de.repo.voidlinux.org/current -r /mnt/nusys base-system linux grub

Fstab

With the following commands we will tell our new system where to look for devices when we boot.

# echo tmpfs /tmp tmpfs defaults 0 0 > /mnt/nusys/etc/fstab

# echo /dev/sdX1 / ext4 defaults 0 0 >> /mnt/nusys/etc/fstab

Optional: Swap is optional. If you created a swap partition add it to fstab.

# echo /dev/sdX2 none swap defaults 0 0 >> /mnt/nusys/etc/fstab

# echo /dev/sdX3 /home ext4 defaults 0 0 >> /mnt/nusys/etc/fstab

GRUB

Install GRUB.

# chroot /mnt/nusys grub-install /dev/sdX

Create a configuration file for GRUB.

# chroot /mnt/nusys grub-mkconfig -o /boot/grub/grub.cfg

User Creation

Create your user.

# chroot /mnt/nusys useradd -m yourusername

Assign a password to your user.

# chroot /mnt/nusys passwd yourusername

Root Password

Assign a password to the root account.

# chroot /mnt/nusys passwd root

System Configuration

Edit hostname and rc configuration.

# echo void > /mnt/nusys/etc/hostname

# echo HOSTNAME=void > /mnt/nusys/etc/rc.conf

# echo HARDWARECLOCK=localtime >> /mnt/nusys/etc/rc.conf

# echo TIMEZONE=US/Michigan >> /mnt/nusys/etc/rc.conf

# echo KEYMAP=us >> /mnt/nusys/etc/rc.conf

Add your user to important user groups.

# chroot /mnt/nusys usermod -G audio,video,input -a yourusername

Configure locales only if you are installing a glibc Void Linux version.

# echo LANG=en_US.UTF-8 > /mnt/nusys/etc/locale.conf

# echo en_US.UTF-8 UTF-8 > /mnt/nusys/etc/default/libc-locales

# xbps-reconfigure -r /mnt/nusys -f glibc-locales

Services

Activate the dhcpcd service for ethernet networking.

# chroot /mnt/nusys ln -s /etc/sv/dhcpcd /etc/runit/runsvdir/current

Reboot

The system will unmount everything when you send a reboot command.

Just run:

# reboot

And make sure to disconnect the USB drive before it boots.