Fast way to manually install Arch Linux

Arch Linux Grub Entry

Firstly, I want to say that this is more of a documentation for myself not a full guide. I'm writing this because I want to have a reference for myself and I want to share it with you. I'm not going to explain every single command here, but I'll try to explain the most important ones. Hope you'll find it useful.

Ok, so let's dive in.

There are 3 common ways to install Arch Linux:

  1. Manual Installation
  2. Archinstall
  3. Arch Linux GUI (not-recommended)

In this post, I'll show only how to install Arch Linux manually. From my experience, this is the best way to install this distribution. You'll have much more control over the installation process, and you'll learn a lot about the Linux itself. You'll learn how to partition the disk, how to install the bootloader, how to install the packages, how to configure the network, etc.

I found this knowledge very useful in my work as a software engineer, for example when I was using Docker, I had to know how to configure the network, or when I've spun up my own Proxmox server with Kubernetes cluster. For example, using the Archinstall script gave me a lot of trouble with the Btrfs file system, and eventually, I installed Arch Linux manually.

Ok, so let's get started.

Manual Installation

Step 1 - Create Arch Linux USB Drive

First, let's create a bootable Arch Linux USB drive. You can download the ISO file from here: Download Arch Linux. Insert your USB drive and run the following command to find the device name:

lsblk

Let's say that the device name is /dev/sdb.

To create the bootable USB drive, you can use the dd command:

dd bs=4M if={arch-linux.iso} of=/dev/sdb conv=fsync oflag=direct status=progress

Alternatively, you can use the cat command:

cat {arch-linux.iso} > /dev/sdb

Make sure to replace {arch-linux.iso} with the actual name of the ISO file.

If you're changing/installing many OSes you can use ventoy, you can download it from here: Get started with Ventoy. It's a nice tool that will allow you to just copy-paste the iso file and have as many OS's as you want on single stick.

For Windows users, you can use Rufus to create the bootable USB drive. You can download it from here: Rufus.

To boot from the USB drive, you may need to use a specific key depending on the manufacturer. Common keys include ESC or F8. Refer to your manufacturer's documentation or website for the exact key.

  1. Manual installation
  2. python script archinstall
  3. Arch Linux Gui Arch-Linux-Gui (honestly I don't recommend it because it's not official, and I had some problems with it)

Step 2 - Boot and connect to the internet

If you already have an internet connection, you can skip this step as it will work automatically. However, if you have a Wi-Fi connection, follow these commands to connect to the internet:

  1. Open a terminal and run the following command:
iwctl
  1. Inside the iwctl prompt, run the following commands to list the available devices and connect to your Wi-Fi network:
device list
station {device_name} connect {wifi_name}
  1. Replace {device_name} with the appropriate device name and {wifi_name} with the name of your Wi-Fi network.

Next, ensure that your system clock is synchronized:

timedatectl set-ntp true

Step 3 - Partition the disk

In this section, we'll create partitions for the Arch Linux installation, and for simplicity this will be only two partitions, one for the root directory and one for boot. Popular approach is to create separate partitions also for home, and swap. However, nowadays, it's not necessary to create swap partition, as most of new computers have enough RAM. If it comes to home directory, it's handy only if you have multiple Linux distros or have ability to port your home directory to another computer.

First, let's identify the drive where you want to install Arch Linux:

lsblk ## Example output: NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 259:0 0 953.9G 0 disk ├─sda1 259:1 0 512M 0 part ├─sda2 259:2 0 952.4G 0 part sdb 259:6 0 7.5G 0 disk └─sdb1 259:7 0 7.5G 0 part

In this example, the drive is /dev/sda, USB drive is /dev/sdb. I've already created a partition for the Arch Linux installation, so I have /dev/sda1 and /dev/sda2 partitions. If you don't have any partitions, you can create a new partition with cfdisk command:

cfdisk /dev/sda

To create the partition just simply choose the free space and press New button. Then choose the size of the partition and press Enter. If you don't have any free space, you can delete one of the existing partitions and create a new one. To delete the partition, choose the partition and press Delete button. Remember, cfdisk is a tool for creating partitions, not for formatting them, also after creating/deleting the partition you have to write the changes to the disk. To do that, choose the Write button and press Enter.

Next step is to format the partitions with mkfs command:

mkfs.fat -F32 /dev/sda1 mkfs.ext4 /dev/sda2

We're formatting the /dev/sda2 partition with ext4 file system and the /dev/sda1 partition with fat32 file system.

Now mount the partitions:

mount /dev/sda2 /mnt

Step 4 - Install necessary packages and configure the system

Follow these commands to proceed with the installation:

pacstrap /mnt base base-devel linux linux-firmware neovim fish

Generate a fstab file to configure the mounting of partitions at boot:

genfstab -U /mnt >> /mnt/etc/fstab

This command is used generate a file system table (fstab). We're appending it to the /mnt/etc/fstab file. The -U option is used to generate UUIDs instead of device names. This is useful because device names can change and UUIDs are more reliable.

arch-chroot /mnt /bin/fish

This command changes the root directory to /mnt. I'm using fish shell here, because of auto-completion and syntax highlighting out of the box, but you can use bash or zsh.

Ensure your system is booted in UEFI mode by checking for the existence of the /sys/firmware/efi directory:

ls /sys/firmware/efi/efivars

If the directory exists, run the following command to install the grub:

pacman -S networkmanager grub efibootmgr os-prober mtools

Here, efibootmgr is a tool for managing UEFI boot entries. mtools is a collection of tools for manipulating FAT32 file systems. Install os-prober if you have other operating systems installed on your computer.

If the directory doesn't exist, run the following command to install just the grub:

pacman -S networkmanager grub

networkmanager is just a network manager, so you can connect to the internet after rebooting the system.

Let's not forget to mount the boot partition:

  1. with efi:
mkdir /boot/efi mount /dev/sda1 /boot/efi
  1. without efi:
mkdir /boot mount /dev/sda1 /boot

Next step is to configure grub. First we need to install the grub on the disk:

  1. with efi:
grub-install --target=x86_64-efi --efi-directory=esp --bootloader-id=GRUB
  1. without efi:
grub-install --target=i386-pc /dev/sda

Grub will be installed on the disk, not on the partition. This is because the bootloader needs to be loaded before the partitions are mounted.

Before generating the grub configuration file, note that if you have multiple systems installed on your computer, you have to edit the /etc/default/grub file and uncomment the following line:

GRUB_DISABLE_OS_PROBER=false

Now let's generate the grub configuration file:

grub-mkconfig -o /boot/grub/grub.cfg

Important thing to note here is that the output of this command should include lines with Found linux image and Found initrd image. If you don't see these lines, then you need to check your grub configuration, also if the os-prober is installed, and other OS's are present, they should be detected and added to the GRUB menu automatically.

Now we're enabling the network manager service, to be available on boot.

systemctl enable NetworkManager.service

Now we need to set the root password:

passwd

At this point we can exit the chroot environment and reboot the system, but I like to do some extra configuration before that.

First, let's configure language and keyboard layout:

vim /etc/locale.gen

Uncomment the line with the language of your choice. For example, if you want to use English, uncomment the line with en_US.UTF-8 UTF-8. Now generate the locale:

locale-gen

Now let's set the language:

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

To set the keyboard layout, we need to create a file:

echo KEYMAP=us > /etc/vconsole.conf

Don't forget to set the hostname:

echo {hostname} > /etc/hostname

Now the time zone:

ln -sf /usr/share/zoneinfo/{Region}/{City} /etc/localtime

And the last step is to create a user:

useradd -m -G wheel -s /bin/fish {username}

Let's set the password for the user:

passwd {username}

Now we need to edit the sudoers file:

EDITOR=nvim visudo

Uncomment the line with %wheel ALL=(ALL:ALL) ALL to allow members of the wheel group to execute any command.

Now we can exit the chroot environment:

exit

And reboot the system:

reboot

And that's it. You should now have a working Arch Linux installation.