I will describe how I install ArchLinux on my personal desktop. Hopefully, this guide will prove useful not only to others but also to you!
However, when it comes to servers, I prefer using Debian instead of ArchLinux. But that's a different topic altogether.
Note: This tutorial draws significant inspiration from the official installation guide: https://wiki.archlinux.org.
https://archlinux.org/download/
[root@host ~]# fdisk -l
[root@host ~]# dd if=archlinux-XXXX.XX.XX-x86_64.iso of=/dev/sdX bs=16M status=progress; sync
root@archiso ~ # loadkeys fr
root@archiso ~ # if [ -d /sys/firmware/efi/efivars ]; then echo "UEFI OK"; else echo "UEFI KO"; fi
root@archiso ~ # ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 00:50:56:80:0b:32 brd ff:ff:ff:ff:ff:ff
altname enp11s0
root@archiso ~ # dhclient ens192
root@archiso ~ # ip addr add 192.168.1.10/24 dev ens192
root@archiso ~ # ip route add default via 192.168.1.254
root@archiso ~ # echo 'nameserver 192.168.1.254' >> /etc/resolv.conf
root@archiso ~ # ping 46.105.57.169
root@archiso ~ # host std.rocks
std.rocks has address 46.105.57.169
std.rocks has IPv6 address 2001:41d0:301::20
std.rocks mail is handled by 1 mx4.mail.ovh.net.
std.rocks mail is handled by 10 mx3.mail.ovh.net.
Note: From this step, if necessary, you can log in to the installation program as root via SSH from another machine. Just use the "passwd" command beforehand to set a password.
root@archiso ~ # timedatectl set-ntp true
I will partition my 40GB disk as follows:
Partition | Note | Filesystem | Size |
---|---|---|---|
EFI | EFI partition | FAT32 | 512M |
/boot | Boot partition | ext2 | 500M |
swap | Swap partition | Swap on LUKS | 2G |
/ | Root partition | Btrfs on LUKS | 37G |
⚠️ Please note that the sda disk will be completely erased, resulting in data loss. ⚠️
root@archiso ~ # fdisk -l
Disk /dev/sda: 40 GiB, 42949672960 bytes, 83886080 sectors
Disk model: Virtual disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop0: 683.24 MiB, 716427264 bytes, 1399272 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
root@archiso ~ # gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.9
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): d
Command (? for help): n
Partition number (1-128, default 1):
First sector (34-83886046, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-83886046, default = 83884031) or {+-}size{KMGTP}: +512M
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): EF00
Changed type of partition to 'EFI system partition'
Command (? for help): n
Partition number (2-128, default 2):
First sector (34-83886046, default = 1050624) or {+-}size{KMGTP}:
Last sector (1050624-83886046, default = 83884031) or {+-}size{KMGTP}: +500M
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'
Command (? for help): n
Partition number (3-128, default 3):
First sector (34-83886046, default = 2074624) or {+-}size{KMGTP}:
Last sector (2074624-83886046, default = 83884031) or {+-}size{KMGTP}: +2G
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): 8309
Changed type of partition to 'Linux LUKS'
Command (? for help): n
Partition number (4-128, default 4):
First sector (34-83886046, default = 6268928) or {+-}size{KMGTP}:
Last sector (6268928-83886046, default = 83884031) or {+-}size{KMGTP}:
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): 8309
Changed type of partition to 'Linux LUKS'
Command (? for help): p
Disk /dev/sda: 83886080 sectors, 40.0 GiB
Model: Virtual disk
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 45AB06C7-DDAF-45D4-A781-B5C33DAF56D2
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 83886046
Partitions will be aligned on 2048-sector boundaries
Total free space is 4029 sectors (2.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 1050623 512.0 MiB EF00 EFI system partition
2 1050624 2074623 500.0 MiB 8300 Linux filesystem
3 2074624 6268927 2.0 GiB 8309 Linux LUKS
4 6268928 83884031 37.0 GiB 8309 Linux LUKS
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.
root@archiso ~ # mkfs.fat -F32 /dev/sda1
root@archiso ~ # mkfs.ext2 /dev/sda2
root@archiso ~ # cryptsetup luksFormat /dev/sda3
WARNING!
========
This will overwrite data on /dev/sda3 irrevocably.
Are you sure? (Type 'yes' in capital letters): YES
Enter passphrase for /dev/sda3: STDp@$$
Verify passphrase: STDp@$$
cryptsetup luksFormat /dev/sda3 16.55s user 1.08s system 86% cpu 20.303 total
root@archiso ~ # cryptsetup luksOpen /dev/sda3 swap
Enter passphrase for /dev/sda3: STDp@$$
root@archiso ~ # ls /dev/mapper
control swap
root@archiso ~ # mkswap /dev/mapper/swap
root@archiso ~ # cryptsetup luksFormat /dev/sda4
WARNING: Device /dev/sda4 already contains a 'dos' partition signature.
WARNING!
========
This will overwrite data on /dev/sda4 irrevocably.
Are you sure? (Type 'yes' in capital letters): YES
Enter passphrase for /dev/sda4: ComplexSTDp@$$
Verify passphrase: ComplexSTDp@$$
cryptsetup luksFormat /dev/sda4 9.72s user 0.68s system 75% cpu 13.721 total
root@archiso ~ # cryptsetup luksOpen /dev/sda4 root
Enter passphrase for /dev/sda3: ComplexSTDp@$$
root@archiso ~ # ls /dev/mapper
control root swap
root@archiso ~ # mkfs.btrfs /dev/mapper/root
root@archiso ~ # mount /dev/mapper/root /mnt/
root@archiso ~ # swapon /dev/mapper/swap
root@archiso ~ # mount --mkdir /dev/sda2 /mnt/boot
root@archiso ~ # mount --mkdir /dev/sda1 /mnt/efi
If necessary, we can add Btrfs subvolumes at this point. For example, let's create a /home subvolume:
root@archiso ~ # btrfs subvolume create /mnt/home
root@archiso ~ # mount /dev/mapper/root -o subvol=home /mnt/home
root@archiso ~ # pacstrap /mnt base linux linux-firmware btrfs-progs vim grub efibootmgr
root@archiso ~ # genfstab -U /mnt >> /mnt/etc/fstab
/dev/mapper/swap none swap defaults 0 0
root@archiso ~ # arch-chroot /mnt
[root@archiso /]# ls /usr/share/zoneinfo/
[root@archiso /]# ln -sf /usr/share/zoneinfo/Region/City /etc/localtime
[root@archiso /]# ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
[root@archiso /]# hwclock --systohc
[…]
#en_SG ISO-8859-1
en_US.UTF-8 UTF-8
#en_US ISO-8859-1
[…]
#fr_CH ISO-8859-1
fr_FR.UTF-8 UTF-8
#fr_FR ISO-8859-1
[root@archiso /]# locale-gen
[root@archiso /]# echo 'LANG=en_US.UTF-8' > /etc/locale.conf
[root@archiso /]# echo 'LANG=fr_FR.UTF-8' > /etc/locale.conf
[root@archiso /]# echo 'KEYMAP=fr' > /etc/vconsole.conf
[root@archiso /]# echo 'KEYMAP=us' > /etc/vconsole.conf
[root@archiso /]# echo 'stdesktop' > /etc/hostname
MODULES=(dm_mod ext2 btrfs ext4 xfs)
[…]
#add lvm2, mdadm if needed
HOOKS=(base udev autodetect modconf block keyboard keymap encrypt filesystems usr fsck shutdown)
[root@archiso /]# mkinitcpio -P
[root@archiso /]# echo 'swap /dev/sda3 /dev/urandom swap,cipher=aes-cbc-essiv:sha256,size=256' >> /etc/crypttab
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 amdgpu.audio=0"
#we can use /dev/sda4 UUID like that: cryptdevice=UUID=XXXX-XXXX-XXXX:root if we prefer
GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda4:root"
[root@archiso /]# grub-install --target=x86_64-efi --efi-directory=/efi/ --bootloader-id=GRUB
Installing for x86_64-efi platform.
Installation finished. No error reported.
[root@archiso /]# grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
Found fallback initrd image(s) in /boot: initramfs-linux-fallback.img
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done
[root@archiso /]# passwd
[root@archiso /]# exit
root@archiso ~ # reboot
[root@stdesktop ~]# useradd -m newuser
[root@stdesktop ~]# passwd newuser
We can configure the network manually, statically, or via DHCP.
[root@stdesktop ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 24:1f:fe:d3:bc:2a brd ff:ff:ff:ff:ff:ff
Note: This configuration will be reset after each reboot.
[root@stdesktop ~]# ip link set ens192 up
[root@stdesktop ~]# ip addr add 192.168.1.10/24 dev ens192
[root@stdesktop ~]# ip route add default via 192.168.1.254
[root@stdesktop ~]# echo 'nameserver 80.67.169.12' > /etc/resolv.conf
[Match]
Name=ens192
[Network]
Address=192.168.1.10/24
Gateway=192.168.1.254
DNS=192.168.1.254
[root@stdesktop ~]# systemctl enable systemd-networkd.service && systemctl start systemd-networkd.service
[Match]
Name=ens192
[Network]
DHCP=yes
[root@stdesktop ~]# systemctl enable systemd-networkd.service && systemctl start systemd-networkd.service
[root@stdesktop ~]# pacman -S gnome
[root@stdesktop ~]# localectl set-x11-keymap fr
[root@stdesktop ~]# systemctl enable gdm
[root@stdesktop ~]# systemctl start gdm
If you have an AMD FirePro W5000, you may want to enable hardware video acceleration.
[root@stdesktop ~]# pacman -S libva-mesa-driver mesa-vdpau
[root@stdesktop ~]# pacman -S libva-utils vdpauinfo radeontop
options amdgpu si_support=1
options radeon si_support=0
options radeon cik_support=0
MODULES=(dm_mod ext2 btrfs ext4 xfs amdgpu)
[...]
HOOKS=(base udev autodetect modconf block keyboard keymap encrypt lvm2 filesystems usr fsck shutdown)
[root@archiso /]# mkinitcpio -P
[newuser@stdesktop ~]$ lspci -k | grep -A 3 -E "(VGA|3D)"
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Pitcairn LE GL [FirePro W5000]
Subsystem: Advanced Micro Devices, Inc. [AMD/ATI] Device 0b06
Kernel driver in use: amdgpu
Kernel modules: radeon, amdgpu
[newuser@stdesktop ~]$ echo 'export VDPAU_DRIVER=radeonsi' >> ~/.bashrc
[newuser@stdesktop ~]$ vainfo
vainfo: VA-API version: 1.15 (libva 2.15.0)
vainfo: Driver version: Mesa Gallium driver 22.1.7 for ATI FirePro V(FireGL V) Graphics Adapter (pitcairn, LLVM 14.0.6, DRM 3.47, 5.19.9-arch1-1)
vainfo: Supported profile and entrypoints
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Main : VAEntrypointVLD
VAProfileVC1Simple : VAEntrypointVLD
VAProfileVC1Main : VAEntrypointVLD
VAProfileVC1Advanced : VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileH264Main : VAEntrypointVLD
VAProfileH264High : VAEntrypointVLD
VAProfileNone : VAEntrypointVideoProc
[newuser@stdesktop ~]$ vdpauinfo
display: :0 screen: 0
API version: 1
Information string: G3DVL VDPAU Driver Shared Library version 1.0
Video surface:
name width height types
-------------------------------------------
420 16384 16384 NV12 YV12
422 16384 16384 UYVY YUYV
444 16384 16384 Y8U8V8A8 V8U8Y8A8
420_16 16384 16384
422_16 16384 16384
444_16 16384 16384
Decoder capabilities:
[…]
When logging in, you can have your most frequently used applications open automatically.
[newuser@stdesktop ~]$ mkdir ~/.config/autostart
[Desktop Entry]
Name=AutostartScript
GenericName=Gnome Auto Start Script
Comment=Script wich launch applications at startup
Exec=/home/newuser/.config/autostart.sh
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true
#Open terminal
gnome-terminal&
#Open Firefox
firefox &
#Open Explorer
nautilus&
[newuser@stdesktop ~]$ chmod +x ~/.config/autostart.sh
I usually use cron as a task scheduler. While there are implementations of cron in ArchLinux, none of them are pre-installed. By default, the base system uses systemd/Timers. Here, we will see how to create a systemd/Timers task.
[Unit]
Description=Copy a file
Wants=mytask.timer
[Service]
Type=oneshot
User=newuser
#Normaly $(/usr/bin/date +%Y%m%d) but $ and % need to be escaped
ExecStart=/bin/bash -c '/usr/bin/cp /home/newuser/a_file /backup/a_file.$$(/usr/bin/date +%%Y%%m%%d)'
[Install]
WantedBy=multi-user.target
[Unit]
Description=Copy a file trigger
Requires=mytask.service
[Timer]
Unit=mytask.service
#It will run each day at 19h00
OnCalendar=*-*-* 19:00:00
[Install]
WantedBy=timers.target
[root@stdesktop ~]# systemctl enable mytask.timer && systemctl daemon-reload
[root@stdesktop ~]# systemctl status mytask.timer
● mytask.timer - Copy a file
Loaded: loaded (/etc/systemd/system/mytask.timer; enabled; preset: disabled)
Active: active (waiting) since Sun 2022-09-25 16:28:31 CEST; 26min ago
Until: Sun 2022-09-25 16:28:31 CEST; 26min ago
Trigger: Sun 2022-09-25 19:00:00 CEST; 2h 4min left
Triggers: ● mytask.service
sept. 25 16:28:31 stddesktop.local systemd[1]: Started Copy a file.
Contact :