⚠️ Now Archlinux embeeds an install script which you can run with
archinstall
, this blog post is here for curious people wanting to know how to install things from scratch and know how a Linux system works.
I recently installed Archlinux on my laptop, let me help you for a fresh new install, step by step, with all commands and tips I learnt.
After closing around 30-40 navigation pages on my phone after every new installation, I decided to take notes of my mistakes and the tips I learnt of my past experiences in this post.
Disclaimer: I based all my previous installations on the following, therefor some content will be very similar, if not the same.
- https://archlinux.org/
- https://wiki.archlinux.fr/installation
- https://github.com/FredBezies/arch-tuto-installation/blob/master/install.md (🇫🇷)
- https://driikolu.fr/2020/03/install_arch_chiffre_uefi/ (🇫🇷)
I recommend to read the tips if you have an issue with something (Ctrl-f
should work), or want to learn a bit more.
Archlinux#
I really love the minimalist mindset of Archlinux: install only what you need and what you want. You need to change something in particular? You know how to do it because you learnt how to install it before.
You are in total control of your installation and can customize it as needed. Without mentioning the AUR packages.
Bootable USB#
The first thing to get is a USB stick to make it bootable and store the ISO on it.
1sudo dd bs=4M if=/path/to/archlinux.iso of=/dev/sdX # sdX is your USB stick (see lsblk)
After some time, you get your USB bootable. Boot your computer on it to install Archlinux.
⚠️ I have an Nvidia graphics card (too recent to be supported) and needed to add the
nomodeset
flag on boot because of screen glitches.
Base system#
Partitions#
We first want to create our partitions. Make sure to get your disk label with fdisk -l
.
We will create 4 partitions:
Partition | Name | Type | Size | Mount point |
---|---|---|---|---|
/dev/sdX1 | EFI | FAT32 | 128MiB | /mnt/boot/efi |
/dev/sdX2 | Boot | ext4 | 256MiB | /mnt/boot |
/dev/sdX3 | Root | ext4 | 32GiB | /mnt |
/dev/sdX4 | Home | ext4 | Everything else | /mnt/home |
Those values are arbitrary, change them at your own risks.
1# partitions
2parted /dev/sdX
3mklabel gpt
4# EFI
5mkpart primary fat32 1MiB 129MiB # 128MiB size
6set 1 esp on
7# Boot
8mkpart primary ext4 129MiB 385MiB # 256MiB size
9set 2 boot on
10# Root
11mkpart primary ext4 385MiB 32.4GiB # 32GiB size
12# Home
13mkpart primary ext4 32.4GiB 100% # take everything else
14q
Create filesystem on the partitions:
1mkfs.fat -F32 /dev/sdX1
2
3for i in {2..4}; do mkfs.ext4 /dev/sdX$i; done # oneliner
4# or
5mkfs.ext4 /dev/sdX2
6mkfs.ext4 /dev/sdX3
7mkfs.ext4 /dev/sdX4
Basic configuration#
You want now to set your NTP:
1timedatectl set-timezone Europe/Paris # change to your location
2timedatectl set-ntp true
Linux setup#
Basic install
We will now mount our partitions on the system and install basic packages on it.
1mount /dev/sdX3 /mnt
2mkdir /mnt/home; mount /dev/sdX4 /mnt/home
3mkdir /mnt/boot; mount /dev/sdX2 /mnt/boot
4mkdir /mnt/boot/efi; mount /dev/sdX1 /mnt/boot/efi
Reffer to the partitions table
Let’s install basic packages using pacstrap
:
1pacstrap /mnt base base-devel linux linux-firmware
If your ISO is old, you will have to update your keyring because some PGP signatures could be missing/expired.
You will want to add
nvidia
if you have such card. Or even your favourite text editor.
We can now generate our fstab:
1genfstab -U /mnt >> /mnt/etc/fstab
⚠️ Do not forget to install
dhclient
if you want Internet access after reboot
Configuration
We can now edit our configuration:
1vi /etc/hostname
2# My-Super-Machine
3
4vi /etc/hosts
5# 127.0.0.1 My-Super-Machine.my-local-domain My-Super-Machine
1# NTP setup
2ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime
3hwclock --systohc
Set your locales:
1vi /etc/locale.gen
2# uncomment your locale
3locale-gen
4
5vi /etc/locale.conf
6# Use your own
7# LANG="en_US.UTF-8"
We can now set a password for the root
account:
1passwd
Boot setup#
Let’s install Grub for the boot manager:
1pacman -S grub efibootmgr
Setup the kernel modules and install Grub on the system:
1arch-chroot /mnt
2mkinitcpio -p linux
3
4grub-install --target=x86_64-efi --efi-directory=/boot/efi --recheck /dev/sdX
5grub-mkconfig -o /boot/grub/grub.cfg
Your system is now ready to work. Congratulations, you can now reboot the machine and unplug the USB stick!
Sudoer user#
We do not want to use root
user, we create a sudo user:
1useradd --create-home user_name
2passwd user_name
3usermod --append --groups wheel user_name
4visudo
5# uncomment %wheel ALL=(ALL) ALL
Users in wheel
group will be sudoer (using their password).
Graphical environment#
You may now need to use a graphical environment, I will show how to use the famous i3 and setup a basic status bar: polybar.
Install
xorg
if not installed yet
I will from now, exec commands as a regular user. sudo -u user_name
.
i3#
1sudo pacman -S i3-wm
And voilà, i3 is now installed. It will start on next login, we will see for a connection manager in a moment.
polybar#
You want a status bar? Polybar provide fast, easy to customize bars.
1# not available on pacman repos, so build from source
2cd ~/.local/share
3git clone https://aur.archlinux.org/polybar
4cd polybar; makepkg -isc
Once installed you can find cool themes at https://github.com/adi1090x/polybar-themes you will find installation and setup instructions on the repo.
You can add an entry for the bar to launch on login in your i3 config:
1vim ~/.config/i3/config
2# exec_always --no-startup-id ~/.config/polybar/launch.sh --your-selected-theme
rofi#
I use rofi for my application launcher and power menu, see https://github.com/adi1090x/rofi for more info.
Add a system bind on your config:
1vim ~/.config/i3/config
2# bindsym $mod+d exec ~/.config/rofi/launchers/launcher_you_want/launcher.sh
lightdm#
As its name says, lightdm is a lightweight package, it will allow you to setup your login page on startup.
Don’t forget to enable it with sysytemd: systemctl enable lightdm
.
Post-installation troubleshouting#
BIOS update broke my setup#
Yeah it appears that on a BIOS update, you can break your grub config. It happened to me every time as I run a dual boot alongside W*ndows. Jokes apart, it is very easy to fix things.
The main issue encountered is the disapearance of Grub and so, your Arch partition. Fear not, you can fix it in only 2 steps:
- Find your bootable stick and boot on it
- Follow the steps:
1# mount your partitions
2mount /dev/sdX3 /mnt; mount /dev/sdX4 /mnt/home; mount /dev/sdX2 /mnt/boot; mount /dev/sdX1 /mnt/boot/efi
3
4# regenerate your fstab
5genfstab -U /mnt >> /mnt/etc/fstab
6
7# reinstall grub
8arch-chroot /mnt
9mkinitcpio -p linux
10grub-install --target=x86_64-efi --efi-directory=/boot/efi --recheck
11grub-mkconfig -o /boot/grub/grub.cfg
And you can reboot.
Dual boot with windows#
My grub did not detect my Windows partition, this post helped me to solve the issue.
Tips#
- Something is broken? You forgot to install an important package but already completed all the steps? Do not reinstall from scratch! Just boot on your USB, mount your system back and
chroot
into it! - If using Nvidia card, set
nomodeset
on boot if screen tearing/glitch - Make sure to have some space for the root partition, even 32GB is tight sometimes
- Update your pacman’s keyring if the ISO is old with
pacman-key --populate archlinux
- Make sure to install
dhclient
and a network manager to access the Internet - Disable the computer speaker BEEP:
echo blacklist pcspkr > /etc/modprobe.d/nobeep.conf
If you find something broken here, feel free to send an issue on the Github repo.
As I am in some distro reinstallation process, I will update this notes on the fly.