Last active
April 9, 2022 09:49
-
-
Save LukeHuckman/7feadbeed54e6b446f942d8eaefa56ab to your computer and use it in GitHub Desktop.
Step by step basic installation of Arch Linux with systemd-boot on a UEFI system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Step 1: Partition and format disks | |
List disks, | |
iso# fdisk -l | |
Select disk, | |
iso# fdisk /dev/X // Replace X with a storage device | |
// SATA drives: sda, sdb, sdc... | |
// NVMe drives: nvme0n1, nvme1n1, nvme2n1... | |
Create a GPT partiton table, | |
iso[fdisk]# g | |
Create partitions for ESP, root, and (optionally) swap, // For swapfile, see step 4.5 | |
iso[fdisk]# n // Minimum 128MiB for ESP, at least 256MiB for multi boot | |
Change partition types to match, | |
iso[fdisk]# t // Partition types: ESP=1, Root=20, Swap=19 | |
Write changes, | |
iso[fdisk]# w | |
Format partitons, | |
iso# mkfs.A /dev/Xi // Replace A with a filesystem type, i with a partition number | |
iso# mkfs.B /dev/Xj // (e.g. "mkfs.vfat -F32 /dev/sda1", "mkfs.ext4 /dev/sda2") | |
iso# mkswap /dev/Xk // mkswap for the optional swap partition | |
... | |
Ref: | |
https://wiki.archlinux.org/title/Fdisk | |
https://wiki.archlinux.org/title/File_systems | |
https://wiki.archlinux.org/title/File_systems#Create_a_file_system | |
https://wiki.archlinux.org/title/Swap#Swap_partition | |
Step 2: Check internet connectivity | |
iso# ping ... // Provide a valid address to ping yadayadayada, you know the drill | |
Use iwctl for wifi, | |
iso# iwctl | |
iso[iwctl]# station <wifi interface> connect <network name> | |
Ref: | |
https://wiki.archlinux.org/title/Iwd#iwctl | |
Step 3: Update pacman databases | |
(Optional) Get mirrorlist using reflector, | |
iso# pacman -S reflector | |
iso# reflector -c SG,TH,ID -f 12 -l 10 -n 12 --sort age --save /etc/pacman.d/mirrorlist | |
// ^ ^ ^ These are country codes for Singapore, Thailand, and Indonesia. | |
// You can replace these with the country you're in or closest to you. | |
Update the databases, | |
iso# pacman -Syy // Note: for installation purposes only. | |
// Don't do this on a working system. Use -Syu (see ref #2) | |
Ref: | |
https://wiki.archlinux.org/title/Pacman | |
https://wiki.archlinux.org/title/System_maintenance#Partial_upgrades_are_unsupported | |
https://wiki.archlinux.org/title/Reflector | |
Step 4: Mount filesystems and install base system, kernel, device firmware, text editor | |
Mount root and ESP, | |
iso# mount /dev/Xj /mnt // Root partition | |
iso# mkdir /mnt/boot | |
iso# mount /dev/Xi /mnt/boot // ESP | |
iso# swapon /dev/Xk // (Optional) Swap partition | |
iso# pacstrap /mnt base linux linux-firmware nano | |
--or-- | |
iso# pacstrap /mnt base linux-lts linux-firmware nano // LTS kernel is recommended for use with Nvidia graphics | |
Generate fstab, | |
iso# genfstab -U /mnt >> /mnt/etc/fstab // genfstab works by detecting currently mounted partitions, | |
// so make sure the partitions you want mounted at startup are mounted | |
Ref: | |
https://wiki.archlinux.org/title/File_systems#Mount_a_file_system | |
Step 4.5 (Optional): Set up swapfile // Alternative to swap parition, not needed if you already have that | |
Create swapfile, | |
iso# dd if=/dev/zero of=/mnt/swapfile bs=1M count=<size in MiB> | |
iso# chmod 600 /mnt/swapfile | |
iso# mkswap /mnt/swapfile | |
Append swapfile mount config to fstab, | |
iso# echo "/swapfile none swap defaults 0 0" >> /mnt/etc/fstab | |
Ref: | |
https://wiki.archlinux.org/title/Swap#Swap_file | |
Step 5: Complete base system setup | |
Chroot into installed system, | |
iso# arch-chroot /mnt | |
Set timezone, | |
# timedatectl set-timezone <timezone> // To show available timezones: # timedatectl list-timezones | |
Edit locale.gen and set system locale, | |
# nano /etc/locale.gen // Uncomment the locales to use | |
# locale-gen | |
# echo LANG=<locale> > /etc/locale.conf // Replace <locale> with your preffered locale | |
# export <locale> | |
Configure hostname, | |
# echo <hostname> > /etc/hostname | |
Configure hosts file, | |
# touch /etc/hosts | |
# nano /etc/hosts | |
127.0.0.1 localhost | |
::1 localhost | |
127.0.1.1 <hostname> // Replace <hostname> with your desired hostname | |
Change root password, | |
# passwd | |
(Optional, HIGHLY RECOMMENDED) Install and configure sudo, | |
# pacman -S sudo | |
# visudo // Uncomment %wheel or %sudo to enable the sudoers group | |
Add user accounts, | |
# useradd -m <username> // Replace <username> with your preferred username | |
# passwd <password> | |
(Optional, HIGHLY RECOMMENDED) Add user account to sudoers and disable root login, | |
# usermod -a -G sudo/wheel <username> | |
# passwd -l root // Prevents access to root without using sudo | |
Ref: | |
https://wiki.archlinux.org/title/System_time#Time_zone | |
https://wiki.archlinux.org/title/Locale | |
https://wiki.archlinux.org/title/Network_configuration#Set_the_hostname | |
https://wiki.archlinux.org/title/Users_and_groups#User_management | |
https://wiki.archlinux.org/title/Sudo | |
Step 6: Set up bootloader | |
Install systemd-boot, | |
# bootctl install | |
Add boot entries, // If you're using more than one kernel/different default kernel, | |
# nano /boot/loader/entries/00-arch.conf // add/modify accordingly | |
title Arch Linux | |
linux /vmlinuz-linux | |
initrd /initramfs-linux.img | |
options root="UUID=..." rw loglevel=3 ... // UUID can be found by using the "blkid" command | |
// Each partition has its own UUID, so double check | |
# nano /boot/loader/entries/01-arch-fallback.conf // (Not to be confused with PARTUUID) | |
title Arch Linux (Fallback) | |
linux /vmlinuz-linux // Trailing ellipses signify any extra options you might | |
initrd /initramfs-linux-fallback.img // want to add, e.g. adding "quiet" reduces the amount of | |
options root="UUID=..." rw loglevel=3 ... // messages shown during booting | |
Configure bootloader, | |
# nano /boot/loader/loader.conf | |
default 00-arch.conf | |
console-mode max | |
editor no | |
Ref: | |
https://wiki.archlinux.org/title/Systemd-boot | |
(optional, recommended) | |
Step 7: Install network manager | |
# pacman -S networkmanager | |
# systemctl enable NetworkManager.service | |
Ref: | |
https://wiki.archlinux.org/title/NetworkManager | |
(optional for WiFi, recommended) | |
Step 7.5: Configure the wireless regulatory domain | |
# pacman -S crda | |
# nano /etc/conf.d/wireless-regdom // Uncomment the relevant country code | |
Ref: | |
https://wiki.archlinux.org/title/Network_configuration/Wireless#Respecting_the_regulatory_domain | |
(optional) | |
Step 8: Install GUI | |
(Required for Nvidia, not required otherwise) | |
Install X server, | |
# pacman -S xorg | |
Install appropriate Xorg video drivers, | |
# pacman -S xf86-video-amdgpu // For AMD graphics | |
--or-- | |
# pacman -S xf86-video-intel // For Intel graphics | |
--or-- | |
# pacman -S nvidia // For Nvidia graphics on standard kernel | |
--or-- | |
# pacman -S nvidia-lts // For Nvidia graphics on LTS kernel | |
GNOME: // Example DEs only. You can install any other WM/DEs if you want | |
# pacman -S gnome // that isn't covered here (See ref #2-4) | |
# systemctl enable gdm.service | |
KDE: | |
# pacman -S plasma kde-applications | |
# pacman -S plasma-wayland-session // Optional for Wayland support, not recommended for Nvidia | |
# systemctl enable sddm.service | |
Ref: | |
https://wiki.archlinux.org/title/Xorg | |
https://wiki.archlinux.org/title/Window_manager#List_of_window_managers | |
https://wiki.archlinux.org/title/Display_manager#List_of_display_managers | |
https://wiki.archlinux.org/title/Desktop_environment#List_of_desktop_environments | |
Step 9: Exit chroot, reboot, enjoy! | |
# exit | |
Unmount ESP and Root, | |
iso# umount -R /mnt | |
Disable swap, | |
iso# swapoff -a | |
iso# reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment