# Installation

To install the Void Linux distribution on the system, the encrypted partition and the efi partition have to be mounted to the main system.

```
# mount /dev/mapper/root /mnt
# mkdir /mnt/boot
# mount /dev/disk/by-label/efi /mnt/boot
# for dir in dev proc sys run; do
> mkdir /mnt/$dir
> mount --rbind --make-rslave /$dir /mnt/$dir
> done
```

The "base-system" needs to be installed to the mounted drive. For this installation there is also other packages which are needed like NetworkManager, gummiboot and cryptsetup.

* For glibc:

```
# xbps-install -Sy -R https://repo-default.voidlinux.org/current -r /mnt base-system cryptsetup gummiboot vim apparmor NetworkManager git booster
```

* For musl:

```
# xbps-install -Sy -R https://repo-default.voidlinux.org/current/musl -r /mnt base-system cryptsetup gummiboot vim apparmor NetworkManager git booster
```

To get internet inside the chroot whilst installing the system, copy over the `resolv.conf`.

```
# cp /etc/resolv.conf /mnt/etc/
```

Entering the chroot and configuring the system.

```
# chroot /mnt
# chown root:root /
# chmod 755 /
# passwd root
# echo <hostname> > /etc/hostname
```

Adding the `uuid` of the root partition to `crypttab` by:

```
# blkid -o value -s UUID /dev/<disk2> >> /etc/crypttab
```

Now edit `/etc/crypttab` and insert:

```
root /dev/disk/by-uuid/<uuid> none
```

We can configure the `fstab` by editing `/etc/fstab` and inserting:

```
tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0
efivarfs /sys/firmware/efi/efivars efivarfs defaults 0 0
/dev/disk/by-label/root / ext4 defaults,noatime 0 1
/dev/disk/by-label/efi /boot vfat defaults 0 2
```

Booster is a faster and more secure initramfs than Dracut.

To configure booster create a file `/etc/booster.yaml` which contains:

```
busybox: true
modules: vfat,nls_cp437,nls_iso8859_1
```

Then to remove dracut from the system first create a config file at `/etc/xbps.d/no-dracut.conf`

```
ignorepkg=dracut
```

And after that delete it from the system with:

```
# xbps-remove -Ry dracut
```

Now mount `efivarfs` to `/sys/firmware/efi/efivars`.

```
# mount -t efivarfs efivarfs /sys/firmware/efi/efivars
```

And install gummiboot.

```
# gummiboot install
```

Create `/boot/loader/void-options.conf` to configure gummiboot.

```
# touch /boot/loader/void-options.conf
```

The `uuid` is needed again and can be obtained by:

```
# blkid -o value -s UUID /dev/<disk2> >> /boot/loader/void-options.conf
```

Now edit `/boot/loader/void-options.conf` and insert:

```
rw rd.luks.name=<uuid>=root root=/dev/mapper/root quiet splash apparmor=1 security=apparmor loglevel=1 rd.shell=0 rd.emergency=reboot
```

To obtain a boot menu. A timeout may be added to `/boot/loader/loader.conf`.

```
timeout 4
```

If running `glibc` the locales have to be configured, to configure the locales edit `/etc/default/libc-locales` and uncomment.

```
en_US.UTF-8 UTF-8
```

And reconfigure the locales.

```
 # xbps-reconfigure -f glibc-locales
```


To obtain better security, `apparmor` will be set to enforce. By editing `/etc/default/apparmor` and inserting:

```
APPARMOR=enforce
```

To set the internal network edit `/etc/hosts` and insert.

```
127.0.1.1 <hostname>
```

Finally reconfigure Linux.

```
# xbps-reconfigure -f linux<version>
```

Exit the chroot.

```
# exit
```

Do not forget to umount. (I always do).

```
# umount -Rf /mnt
```

And reboot.

```
# shutdown -r now
```