InSnh-Gd

InSnh-Gd 的小空间

Void Linux Installation Record

Preface#

Void Linux is an extremely minimal rolling release distribution, but unlike other rolling releases, Void has relatively good stability, although the software may not be as up-to-date.

Void Linux is a very niche Linux distribution, and it also offers the relatively less common Musl libc and runit, which is a significant advantage of Void Linux.

Musl is lightweight and fast, often considered more standard and simpler than glibc. For developers, Musl's source code is much more elegant and clean, and for users, packages compiled with Musl are smaller, making it very suitable for distributions that pursue extreme minimalism and efficiency.

Compared to Musl, runit is even more appealing to me. I used to be an Arch Linux user || (although I still use it on servers) || everything on Arch Linux is great... except for systemd, which is too "heavy" and does too many things that an init system shouldn't do, deviating from the UNIX philosophy. Runit, on the other hand, is much lighter, has a very small codebase, is stable enough, and is much easier to maintain.

Void Linux's package manager xbps is designed from the ground up, is very fast, and provides the xbps-src builder, which can build software in containers using Linux namespaces.

Preparation Before Installation#

Before downloading the image, we can choose a mirror that better suits our habits. The "base" image does not provide a graphical interface, similar to archiso. Unlike Arch Linux, Void Linux has a TUI installer, but I prefer manual command-line installation, just like Arch Linux. As for musl and glibc, it depends on personal preference; I hope my system can be more compact, so I choose Musl.

::: banner {warn}

Musl is not perfect. The standardization of Musl requires programs to adhere to the standards; otherwise, they may not work properly under Musl. If you are a VIM user, VIM may not display Chinese characters correctly under Musl.

Details: https://wiki.musl-libc.org/functional-differences-from-glibc.html
:::

There are only a few mirror sources for Void Linux in China, and you can download the Void Linux installation image from the following links.

Tsinghua Source: https://mirrors.tuna.tsinghua.edu.cn/voidlinux/live/current

Beiwai Source: https://mirrors.bfsu.edu.cn/voidlinux/live/current

Fastly Global CDN: https://repo-fastly.voidlinux.org/live/current

Reference download link (musl base): https://repo-fastly.voidlinux.org/live/current/void-live-x86_64-musl-20221001-base.iso

Of course, you can also choose not to use Void Linux's livecd; you can use archiso or other distributions' livecd for installation, needing to download Void's rootfs and extract it to the already formatted root partition.

Reference rootfs download link (musl): https://repo-fastly.voidlinux.org/live/current/void-x86_64-musl-ROOTFS-20221001.tar.xz

Notes#

If you are an NVIDIA card user, press Tab at the Void livecd boot interface and add the nomodeset kernel parameter to prevent being unable to enter tty.

If you are not a runit user, do not be confused by the unfamiliar boot process when starting Livecd; the boot process of runit is different from that of systemd and other init systems.

The root user password for the Livecd is voidlinux, and the password for the anon user is voidlinux.


Installation#

After entering the LiveCD, log in as the root user.

The default Void Linux image has a surprisingly good speed in China, so we will first change to a domestic mirror source; I use the Beiwai mirror source.

# mkdir -p /etc/xbps.d
# cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/
# sed -i 's|https://repo-default.voidlinux.org|https://mirrors.bfsu.edu.cn/voidlinux|g' /etc/xbps.d/*-repository-*.conf

Next, let xbps synchronize the changes.

# xbps-install -S

Disk Partitioning#

I use an entire hard drive to install Void Linux, but you can also create a separate partition on an existing system's hard drive for installing Void Linux.

I am accustomed to using the gptfdisk (hereinafter referred to as gdisk) tool for partitioning the hard drive, so I first need to install gdisk on the LiveCD.

# xbps-install -Sy gptfdisk 

Using gdisk for partitioning:

GPT fdisk

Step analysis:

  1. Create a new GPT partition table and confirm execution (y).

  2. Create a 2MB partition /dev/sda1 with an ef02 label, so that Legacy Boot can recognize and boot GRUB2 on the GPT disk.

  3. Create a 500MB partition /dev/sda2 with an ef00 label, which serves only as the /boot partition to store the GRUB2 bootloader and Linux kernel in Legacy Boot; when using UEFI boot, it can serve as the /boot/efi partition.

  4. Create a partition using all the free space as the / partition (root partition) /dev/sda3.

  5. Write to the hard drive and confirm the changes (y).

::: banner {info}

Here my hard drive is /dev/sda, and you need to replace my hard drive and partition with your actual situation. You can use the fdisk -l command to check; by the way, I did not use swap here.

:::

Preparing the File System#

Our partition situation is roughly one extra partition, one root partition, and one boot partition, and we need to format the latter two.

Use mkfs.ext4 to format /dev/sda3 (root partition) as an EXT4 partition.

# mkfs.ext4 /dev/sda3

Use mkfs.vfat to format /dev/sda2 (boot partition) as a FAT32 partition.

# mkfs.vfat /dev/sda2

Mount the above two partitions to / and /boot respectively.

# mount /dev/sda3 /mnt
# mount /dev/sda2 /mnt/boot --mkdir

Basic System Installation#

I choose to download the rootfs installation method, which is also applicable to other distributions' LiveCDs.

Install wget on the LiveCD.

# xbps-install wget -y

Download the rootfs package.

# wget https://repo-fastly.voidlinux.org/live/current/void-x86_64-musl-ROOTFS-20221001.tar.xz

Use tar to extract the rootfs package to our root partition.

# tar -xvf void-x86_64-musl-ROOTFS-20221001.tar.xz -C /mnt

For Void LiveCD, you can directly use the xchroot tool to automatically enter Chroot.

# xchroot /mnt /bin/sh

For non-Void LiveCD, you need to complete it manually.

# mount -t proc none /mnt/proc
# mount -t sysfs none /mnt/sys
# mount --rbind /dev /mnt/dev
# mount --rbind /run /mnt/run

The rootfs package of Void Linux is not updated in a timely manner, and the packages within it are usually outdated, and there is no complete base-system package group. We need to update the existing software packages in the rootfs package and install the base-system package group.

# xbps-install -Su xbps
# xbps-install -u
# xbps-install base-system
# xbps-remove base-voidstrap

Set the hostname; I set it to "InSnh-Gd".

# echo 'InSnh-Gd' > /etc/hostname

Set the timezone; for Void Linux, you can directly modify rc.conf and change the default value of "TIMEZONE=" to Asia/Shanghai.

# Modify in /etc/rc.conf
TIMEZONE=Asia/Shanghai

If using the glibc branch, you need to edit /etc/default/libc-locales and uncomment the line for "zh_CN.UTF-8".

Modify the root password and create a user in the wheel group, then use 'visudo' to edit /etc/sudoers and uncomment the line "#%wheel ALL=(ALL) ALL".

# passwd
# useradd -m -G wheel <user>
# visudo 

Configure fstab; you can directly copy /proc/mounts to write the currently mounted file system parameters into /etc/fstab.

# cp /proc/mounts /etc/fstab

Delete the lines except for the root partition / and boot partition /boot. If you created a swap partition, keep the swap line.

The final result looks something like this:

/dev/sda3	/		ext4	rw,realtime	0 0 
/dev/sda2	/boot	vfat	rw,realtime	0 0

Configuring the Network#

We also need to configure the network; you can install dhcpcd for automatic network configuration and enable its service.

# xbps-install dhcpcd -y
# ln -s /etc/sv/dhcpcd /etc/runit/runsvdir/default/

I choose to use a static IP. I think if a network manager is not a strict requirement for you (like configuring bridges, etc.), you can directly use the iproute2 tool to configure a fixed IP instead of installing a management program like NetworkManager, making your system a bit more streamlined. To achieve automatic network configuration at boot, you can write the command into /etc/rc.local; create it if it doesn't exist.

I am accustomed to using the ethX format for network card names and use the net.ifnames=0 kernel parameter to change the network card name to eth0. You need to modify the command according to your network card name; it is recommended to run the ip addr command first to check your network card name and internal IP segment. The IP should be set to x.x.x.200~254 to prevent IP conflicts.

# echo "
ip addr add 192.168.2.200/16 dev eth0
ip route add default via 192.168.2.1" >> /etc/rc.local

Installing the Bootloader GRUB2#

Use xbps-install to install GRUB2. For Legacy Boot (BIOS systems), install the grub package.

# xbps-install grub -y

For UEFI boot, install the grub-x86_64-efi package.

# xbps-install grub-x86_64-efi

I use Legacy Boot, so I only need to run grub-install /dev/sda.

If you use UEFI boot, you need to run the following command. Pay special attention to the mount point of your boot partition or EFI partition; if you followed my steps, the mount point for the boot partition is /boot, then change the /boot/efi in --efi-directory to /boot.

# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id="Void"

Completing the Installation#

Use xbps-reconfigure to ensure that all installed packages are correctly configured.

# xbps-reconfigure -fa

At this point, we have obtained a basic and complete Void Linux installation. Exit chroot and reboot the computer.

[xchroot /mnt]# exit
# umount -R /mnt 
# shutdown -r now

Let me share my feelings during the installation. Although I have basically moved away from Arch Linux, my method of installing Linux distributions has still become similar to that of Arch Linux (sigh, I still can't forget Arch). From the installation process, one can see the minimalism of Void Linux, the power of the xbps package management, and the efficiency of runit!!! It really just serves as an init system and supervision; why don't more people use such a good thing? Do people prefer to use the sh*t mountain that is systemd instead of using runit, which others don't use? Or am I too extreme and too conservative?

After installing Void Linux, its size is about 100MB less than that of Arch Linux with roughly the same number of packages, which is a result of Void Linux's precise package splitting and the dual effect of Musl, very powerful.

References#

ArchWiki - GRUB

Void Linux Handbook

musl libc

runit-- a UNIX init scheme with service supervision

Void Linux manpages

VoidLinux Chinese Website

This article was synchronized and updated to xLog by Mix Space. The original link is https://blog.insnhgd.com/posts/build/1

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.