What Does Installing Linux Involve? An Overview of the Entire Linux Installation Process

 2024-10-02

 Linux

This article is the English version of the Japanese article titled ‘Linuxのインストールとは何をする作業なのか?Linuxインストールの全体像を解説’.

What exactly does the installation process of Linux do?

In recent years, many Linux distributions have prepared easy-to-use GUI installers, and users can simply enter and select information according to the installer’s wizard screen, and the installer will automatically determine and proceed with the process. This makes the installation itself very easy, and I am very happy that more users can easily start using Linux. On the other hand, I think that there is an aspect to this that it has become difficult to see what the installation process is doing because there are fewer opportunities to install by hand and type commands.

For people who only use the system, it is not a problem if they do not know what the installer is doing during the installation process. However, if you perform the installation process manually once, you will clearly understand what the installer is doing, and you will have the advantage of becoming familiar with the system configuration and the location of the setting files. In addition, there are cases where you can respond flexibly to problems during installation. For example, even if the GUI installer issues an error in the disk partitioning section, there are cases where you can manually resolve the issue. This time, I would like to look at what is done during the installation process of a general Linux system, rather than talking about a specific distribution.

Creating an environment for the installation process

First, you need to create an environment for the installation process. Nowadays, it is not uncommon to update packages during installation, so it is no exaggeration to say that a network connection is almost essential. Also, if the appropriate keyboard layout is not set, you will not be able to type properly while working. In this way, we will first prepare for the work at this stage.

Connecting to the network

When Linux systems were distributed on CDs and DVDs in the past, an Internet environment was not necessarily required, but nowadays, there are installers that download the latest packages from the Internet during installation, so I think it can be said that it is almost an essential environment in modern society. If it is a wired connection, the OS installed on the installation media will recognize the hardware’s network interface and automatically connect to the Internet using services such as dhcpcd. In some cases, you may need to connect manually.

Regarding wireless LAN, if the installation media contains firmware and drivers that correspond to the hardware and recognizes the device, you may be able to connect to Wifi. This assumes that wireless services such as iwd can be used on the installation media.

Setting the keyboard layout

This is a simple setting, but it is an important setting. If the keyboard layout (keymap) is not appropriate, you will feel very uncomfortable and your work will not progress. Many GUI installers allow you to select a keymap when selecting a language. Some distributions that use commands to install the installer also provide the loadkeys command.

Disk preparation

This may be one of the most troubling parts of the installation process. Depending on whether the BIOS firmware is Legacy BIOS or UEFI, you can choose whether to use MBR or GPT for the hard disk partitioning table. In addition, in the case of UEFI, you need to prepare an ESP (EFI System Partition) formatted in FAT32 format, so prior knowledge is required.

Furthermore, there are many decisions to be made by the person installing, such as should the system and home directory be on one partition, or should the home directory be on a separate partition? How much swap space should be? To reduce these hassles, many installers have an “automatic” mode that erases the entire disk and partitions it automatically.

Partitioning

This is the task of dividing the hard disk into appropriate capacities for each role and deciding which roles to assign to each role. The minimum required is a partition for the root. In some cases, you may need to separate partitions for home, boot, etc. For machines with UEFI firmware, you need to prepare a separate partition (ESP) of about 512MiB to 1GiB. This ESP may be mounted to /boot or /boot/efi.

To partition using commands, use a TUI or interactive partitioning tool. Many installers come with tools such as fdisk, cfdisk, gdisk, cgdisk, and parted. Installers that come with a desktop environment may also come with the GUI GParted.

Format

After partitioning, you will need to format the partitions according to their role. In most cases, the root and home partitions will be formatted with ext4. In some cases, you may choose Btrfs. For UEFI machines, format the ESP with FAT32.

To format ext4 using commands, use

mkfs.ext4 /dev/sdX

For FAT32, use

mkfs.vfat -F 32 /dev/sdX

Mounting

After partitioning and formatting, the next step is mounting. The mounting location depends on the installation media. For example, in Arch Linux, mount the root partition to /mnt. If you want to create a separate home partition, mount it inside the root partition as /mnt/home. In the GUI installer, you can automatically mount it by simply specifying the mount location.

Creating swap

In most GUI installers, you can automatically create swap by simply selecting “swap” when partitioning. To create swap manually, use the command:

mkswap /dev/sdX
swapon /dev/sdX

Mounting

After partitioning and formatting, the next step is mounting. The mounting location varies depending on the installation media. For example, in Arch Linux, mount the root partition to /mnt. If you want to create a separate home partition, mount it inside the root partition as /mnt/home. In the GUI installer, you only need to specify the mount location and it will be mounted automatically.

Creating swap

In most GUI installers, simply select “swap” when partitioning and it will be created automatically. To create swap manually, use the command:

mkswap /dev/sdX
swapon /dev/sdX

Copying files that make up the system

Copy the core files of the system to the root partition that you just mounted. In many distributions, the Linux kernel copies the binary built for each distribution to the /boot directory, but in some cases, like Gentoo Linux, you can build and install the kernel manually.

Some installers will install packages other than the core of the system, such as the desktop environment and applications selected by the user, at this stage. This is the most time-consuming part, so make yourself a cup of coffee and take a break.

Configuration in the installed system

Now that all the packages required for the system are on the new partition, we will configure the new system.

Creating fstab

The fstab is an important setting that tells the system which partitions to mount and where to mount them when the system boots. Most advanced installers will generate it automatically. Some distributions, like Arch Linux, have an automatic generation script called genfstab, but some distributions require you to generate it manually. The fstab file is often located in /etc/fstab.

Setting the root password

Decide on a root password so that you can log in to the system after installation. For distributions that do not allow root login, such as Ubuntu and Solus, you do not need to decide on a root password, but create an administrator user.

Setting the time zone

The essence of setting the time zone is how to set the binary file /etc/localtime. There are direct methods such as copying the file /usr/share/zoneinfo/Region/City or setting a symbolic link, and there are also methods such as setting a text file /etc/timezone and setting /etc/localtime using a tool, as in Debian-based systems and Gentoo with OpenRC selected. Systems that use Systemd have the timedatectl command.

Setting the locale

Set the locale. In the case of a GUI installer, the localedef command is executed and the /etc/locale.conf file is created automatically, but in the case of a manual installer, you need to do it yourself. Arch Linux and Gentoo provide the locale-gen command to create a locale database for each locale, while Void Linux uses xbps-reconfigure to set it up.

Install the necessary network utilities such as dhcpcd and NetworkManager and set them up so that the services are enabled at boot time. You can also set up the network manually. If you want to complete the wireless network connection during installation, install firmware and drivers to recognize the necessary devices, and install and configure tools that support wireless connections such as NetworkManager and iwd.

Creating a user

Create a user who can log in. If the distribution does not allow root login, create a user with administrator privileges who can execute sudo commands and belong to the sudo and wheel groups. Don’t forget to set the user’s password.

Setting the keymap and font on the console

Set the keymap for the new system and the font on the console screen. The location of the configuration file varies depending on the init you are installing. For systems that use Systemd, set it to /etc/vconsole.conf. For systems that use runit, write the settings in /etc/rc.conf. In a system that has OpenRC installed, create or edit a configuration file under the /etc/conf.d/ directory. In the case of a GUI installer, the configuration will be performed automatically without any special configuration.

Installation and configuration of required packages

If you need packages such as an editor or desktop environment, install them using package management commands such as apt, pacman, zypper, dnf, and eopkg. It is a good idea to update your system in advance. If you are installing a GUI environment, set the keymap under the X11 or Wayland environment. Please note that this is different from the keymap set for the console. If the installer automatically installs the desktop environment, you do not need to worry about setting the keymap.

Installation of the boot loader

This is the last and most important part. You will not be able to start the new system unless you install the boot loader correctly or set it so that the Linux kernel can be booted directly (starting with EFISTUB). Many major distributions use GRUB2 as the standard boot loader, but there are also distributions that allow you to manually install your preferred boot loader. The boot loader and installation method you should choose will change depending on whether your BIOS firmware is Legacy BIOS or UEFI.

Summary

I have tried to explain what it means to “install Linux” as a general task, rather than from the perspective of a distribution-specific task. As mentioned at the beginning, the installer now automatically performs tasks such as hardware recognition, partitioning, and boot loader installation, making it very easy, but on the other hand, it has become difficult to see what is happening behind the beautiful GUI screen. Understanding the overall picture of the installation process and learning the specific procedures for your distribution may be the gateway to learning more about your Linux system. I hope this article will help you enjoy your Linux life.