This post covers the configuration of the Arch operating system.
1. Arch Installation
1.1. What is Arch?
Arch Linux is an independently developed, general-purpose x86-64 GNU/Linux distribution that strives to provide the latest stable versions of most software by following a rolling-release model. The default installation is a minimal base system, configured by the user to only add what is purposely required 1.
1.2. Basic Concepts
LVM is an implementation of a logical volume manager for the Linux kernel. LVM includes many of the features expected from a volume manager, including:
- Resizing of logical groups
- Resizing of logical volumes
- Read-only snapshots (LVM2 offers read and write)
- RAID0 of logical volumes. LVM does not implement RAID1 or RAID5, so it is recommended to use dedicated RAID software for these operations, placing the LVs on top of the RAID 2.
RAID will not be used in this configuration.
LUKS is a disk encryption specification created by Clemens Fruhwirth, originally intended for Linux. While most disk encryption software implements different and incompatible undocumented formats, LUKS specifies a standard on-disk format, platform-independent, for use with various tools. This not only facilitates compatibility and interoperability between different programs, but also ensures that they all implement password management in a secure and documented manner. The reference implementation runs on Linux and is based on an enhanced version of cryptsetup, using dm-crypt as the disk encryption interface 3.
A boot loader loads an operating system kernel into memory and executes it. A boot manager hands over control to another boot program. GRUB is both a boot loader and a boot manager. rEFInd is only a boot manager.
Another fundamental concept is understanding the difference between EFI/UEFI and BIOS.
LVM is an implementation of a logical volume manager for the Linux kernel. LVM includes many of the features expected from a volume manager, including:
- Resizing of logical groups
- Resizing of logical volumes
- Read-only snapshots (LVM2 offers read and write)
- RAID0 of logical volumes. LVM does not implement RAID1 or RAID5, so it is recommended to use dedicated RAID software for these operations, placing the LVs on top of the RAID 2.
RAID will not be used in this configuration.
LUKS is a disk encryption specification created by Clemens Fruhwirth, originally intended for Linux. While most disk encryption software implements different and incompatible undocumented formats, LUKS specifies a standard on-disk format, platform-independent, for use with various tools. This not only facilitates compatibility and interoperability between different programs, but also ensures that they all implement password management in a secure and documented manner. The reference implementation runs on Linux and is based on an enhanced version of cryptsetup, using dm-crypt as the disk encryption interface 3.
In the Partition Table, the ext4 format is used for partitions because it improves I/O speed and uses less CPU than the ext3 and ext2 formats. The following minimum values are recommended:
| Partition | Recommended Size | Debian Allocation | Custom Allocation | Contains |
|---|---|---|---|---|
| / | >= 750MB | 22GB | 64GB | /etc, /bin, /sbin, /lib, /dev, /usr |
| /usr | >= 4-6GB | 0 | 0 | User programs, libs and docs |
| /var | >= 2-3GB | 32GB | 112GB | Variable data such as emails |
| /tmp | >= 100MB | 16GB | 32GB | Web pages, package cache, temporary data |
| /home | >= 100MB | 200GB | 288GB | Directory with Documents, Downloads, … |
| /boot | >= 256MB | 500MB | 512GB | Primary Partition, ext4 or ext2, encryption not recommended |
| /boot/efi | >= 100MB | 250MB | 0 | Encryption not recommended and bootable flag: on |
| /swap | >= 8GB | 16GB | 16GB | Swap area |
1.3. Flashing the Arch Image
The steps from the Arch installation guide were followed 4.
One way to flash an image is with the dd command as shown below:
| |
| |
| |
1.4. Booting Arch
Connect the USB and ethernet cable, then boot Arch Linux from the USB via the BIOS.
2. Initial Configuration
2.1. Set the Keyboard Layout in the Live Environment
Switch the keyboard to Spanish:
| |
2.2. Configure Wi-Fi
If the iwd package is not installed, install it using an ethernet connection:
| |
Configure the Wi-Fi interface with:
: wlan0 : Wi-Fi network name : password
To find these values, you can use the iwctl command followed by device device show.
| |
To see available Wi-Fi networks, run the following commands:
| |
Verify that you have an IP address with:
| |
Now, if you change the root user password with the passwd command, you can connect to the machine with:
| |
2.3. Time Update
We follow this guide with the first steps after installing Arch 5. Set the timezone to the appropriate one with:
| |
Synchronize the clock with the internet:
| |
2.4. Unlock LUKS-encrypted Partition Configured with LVM Logical Volumes
Decrypt the partition with:
| |
Then detect the LVM volume group with:
| |
Note: the following steps may not work on the first attempt and may need to be completed with the next section. You could skip the end of this section and install GRUB directly.
Once the commands above have been executed, continue with the installation until the GRUB installation. Open a terminal again and identify the UUID of the encrypted partition with:
| |
Next, edit the /etc/crypttab file:
| |
Add the following content, where the UUID is the one obtained from the blkid command:
| |
This configuration may need to be repeated later.
2.5. Mount the Partitions
According to the Arch documentation for creating filesystems and mounting volumes, format the previously created volumes and mount the following partitions:
| |
2.6. Installation of Essential and Recommended Packages
Sources:
- [https://denovatoanovato.net/instalar-arch-linux/#uefi]
- [https://linuxhint.com/setup-luks-encryption-on-arch-linux/] Try following with encrypt instead of lvm2 or using both
Essential packages:
| |
Recommended packages (some may produce errors):
| |
To enable the touchpad, install the xf86-input-synaptics package.
Other additional packages could include os-probes (may produce errors).
Then generate the fstab file, which contains the system’s partition table.
| |
2.7. Enter the Base System
It is time to enter the installed base system to continue configuring it from within. To access the system in chroot, run:
| |
2.8 Update Hostname
| |
2.9. Update Timezone
| |
2.10. Set the Clock
| |
2.11. Configure Keyboard Layout
| |
2.12. Configure mkinitcpio
Sources:
- [https://www.linuxserver.io/blog/2014-01-18-installing-arch-linux-with-root-on-an-lvm]
- [https://wiki.archlinux.org/title/LVM_(Espa%C3%B1ol)#Crear_sistemas_de_archivos_y_montar_los_vol%C3%BAmenes_l%C3%B3gicos]
| |
Edit the HOOKS line and add the following:
| |
Then run:
| |
At this point, you could unmount the partition and reboot the operating system with the following commands if you did not install Arch on an encrypted partition. If you installed it on an encrypted partition, you must configure GRUB to indicate that it is encrypted (step 2.13).
| |
2.13. Configure GRUB
Install GRUB with the following commands:
| |
In /etc/default/grub, edit the GRUB_CMDLINE_LINUX line to:
| |
[Tip] To automatically detect other operating systems on your computer, install os-prober (pacman -S os-prober) before running the following command.
Finally, configure GRUB with:
| |
2.14. Configuration for LUKS-encrypted Partition
Note: the following steps are the same as those in section 2.4, so check carefully whether they already worked in that step or need to be repeated.
Detect the UUID of the encrypted partition. The X in sdaX corresponds to the number of the encrypted partition; if you do not know it, simply use the blkid command.
| |
Edit the /etc/crypttab file with nano:
| |
Add the following:
| |
Install initramfs:
| |
Once finished, use the following command to update initramfs:
| |
2.14 (Optional) Initialize the Pacman Keyring
Install the keyring:
| |
Initialize the pacman keyring and populate the Arch Linux ARM package signing keys (if using a Raspberry Pi):
| |
2.15 Unmount the Partitions
Unmount the mnt partition:
| |
Reboot the operating system with:
| |
3. Advanced Configuration
Connect via SSH to the machine again and follow the steps below.
3.1. System Update
Once you have a console with a non-root user, open a new console as the root user:
| |
The default password is usually root or the one previously configured.
- Update Arch:
| |
3.2. Language Update
If not previously configured, uncomment the desired language in the locale.gen file (e.g., en_US.UTF-8):
| |
Run:
| |
Then run:
| |
3.3. Hostname Change
Change the hostname with:
| |
Add a hostname alias in the /etc/hosts file of the computer you are using for the configuration. Use nano /etc/hosts:
| |
3.4. (Optional) Enable Color Output in Pacman
If using Arch, run:
| |
3.5. (Optional) Add 8GB of SWAP Memory
If using Arch, run:
| |
3.6. (Optional) New User with Sudo Privileges
If using Arch, we will now use the visudo utility to edit group permissions for running administrative commands with sudo.
| |
Uncomment the following line:
| |
Create a new sudo group with:
| |
Create a new user with:
| |
Set a password for the new user:
| |
Once you have the new user, delete the alarm user or the default installation user (if one exists).
| |
Modify the permissions of the user created during installation and add them to the sudo group with the following command:
| |
Reboot the system:
| |
3.6. SSH Keys
In the next step, you need to copy the public key to the ~/.ssh/authorized_keys file on the machine. To do this, use the following command:
| |
Now it will ask for your SSH key password, and you can connect to the machine with:
| |
3.7. (Optional) Wi-Fi Configuration
Reproduced from the guide: first steps after installing Arch 5. karog, on ArchLinux ARM forums provides a very simple way to connect to Wi-Fi. As root, follow these steps:
nano /etc/systemd/network/wlan0.networkto configure the wlan0 interface:- Add the following content to the file:
| |
wpa_passphrase "<SSID>" "<PASSWORD>" > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf. Replaceand with your Wi-Fi network name and password. systemctl enable wpa_supplicant@wlan0to enable Wi-Fi on boot.systemctl start wpa_supplicant@wlan0to connect to Wi-Fi.
Everything is now set up. However, if you ever want to remove the Wi-Fi connection (for example, when you want the machine to connect only via ethernet):
systemctl stop wpa_supplicant@wlan0systemctl disable wpa_supplicant@wlan0rm /etc/wpa_supplicant/wpa_supplicant-wlan0.confrm /etc/systemd/network/wlan0.network
4. Package and Software Installation
4.1. Basic Packages
gitandwget:
| |
yay: The most commonly used AUR helpers in Arch Linux are Yaourt and Packer. You can easily use them for Arch Linux package management tasks such as installing and updating packages.
However, both have been discontinued in favor of yay, short for Yet Another Yaourt. Yay is a modern AUR helper written in the Go language. It has very few dependencies and supports AUR tab completion so you don’t have to type out full commands.
We install it with the following commands in the opt directory, which is the designated folder for storing third-party programs.
| |
Update the repos with:
| |
4.2 Install zsh, Oh My Zsh and Powerlevel10k
Install zsh and oh-my-zsh with the following commands:
| |
To install Powerlevel10k, we need to install the required fonts with the command:
| |
Alternatively, you can do it manually by downloading and placing the 4 .ttf fonts from Meslo Nerd in /usr/local/share/fonts. They must have permissions 644 (-rw-r–r–)6.
Create the /usr/local/share/fonts directory:
| |
Download the fonts:
| |
Install and configure Powerlevel10k with:
| |
4.2. Docker and Docker Compose
It is recommended to install Docker rootless (4.2.2.) but it may cause issues with some Docker containers. If you do not want to deal with those issues or you are configuring a production server that requires security, follow the next section (4.2.1.).
4.2.1. Installation on Arch
Install Docker from the official repositories:
| |
Add the user to the docker group:
| |
Enable the Docker daemon:
| |
If you get an error, reboot the machine.
4.2.2 Docker Rootless
- Arch:
| |
Add kernel.unprivileged_userns_clone=1 in /etc/sysctl.conf:
| |
| |
Test with docker run -d -p 8080:80 nginx.
If you want it to start at boot, run the following commands:
| |
4.3 i3wm Window Manager
Following the steps from Low Orbit Flux - Arch Linux How to Install i3 Gaps, install the xorg-xinit package which installs xinit. The xinit program allows the user to manually start an Xorg display server. Install the X window server xorg and xterm.
| |
Install some optional extras:
| |
Install the entire i3 group, prioritizing i3-gaps over i3-wm since the former is a fork of the latter.
| |
Install the necessary drivers for your machine.
| |
Follow the steps from Low Orbit Flux - Arch Linux How to Install i3 Gaps to completion.