Je vais parler ici de l'installation de ArchLinux sur mon ordinateur. Avec un peu de chance cela pourra ĂŞtre utile Ă d'autres et peut ĂŞtre mĂŞme Ă toi!
Par contre je ne l'installerai jamais sur un serveur pour lequel je préfère debian. Mais c'est un autre sujet.
Note : Ce guide s'inspire largement de l'article d'installation officiel : 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 : à partir de cette étape, si besoin, il est possible de se connecter depuis une autre machine à l'installeur avec ssh. Il faudra juste utiliser la commande passwd avant pour paramétrer un mot de passe.
root@archiso ~ # timedatectl set-ntp true
Je vais partitionner mon disque de 40G de la façon suivante.
Partition | Note | Système de fichier | Taille |
---|---|---|---|
EFI | partition efi | FAT32 | 512M |
/boot | partition de démarrage | ext2 | 500M |
swap | partition fichiers d'Ă©change | swap sur LUKS | 2G |
/ | partition racine | btrfs sur LUKS | 37G |
⚠️ A noter que le disque sera complètement supprimé et par conséquent les données présentes seront effacées.⚠️
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
Si besoin on pourra ajouter ici un ou plusieurs sous-volumes btrfs, par exemple ici avec /home.
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 you 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
On peut configurer le réseau de façon manuelle, statique ou 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 : Cette configuration sera réinitialisée après chaque redémarrage.
[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
Si comme moi vous êtes propriétaire d'une carte AMD FirePro W5000 il peut être interessant d'activer l'accélération matérielle.
[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:
[…]
Quand j'ouvre ma session, j'aime bien que les programmes que j'ai l'habitude d'utiliser s'ouvrent automatiquement.
[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
J'utilise hbaituellement cron comme planificateur de taches. Il existe des implémentations de cron dans ArchLinux mais aucune d'entre elle n'est préinstallée. Par défaut le système utilise les systemd/Timers. Nous allons voir ici comment créer une tache de type systemd/Timers.
[Unit]
Description=Copy a file
Wants=mytask.timer
[Service]
Type=oneshot
User=newuser
#Normalement $(/usr/bin/date +%Y%m%d) mais les caractères $ et % doivent être échapés
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 :