Table of Contents
This is a brief record of Arch Linux installation and configuration for quick reference.
Preparation
Download ISO
Download the latest ISO from the USTC Mirror.
Installation
Disable reflector
systemctl stop reflector.serviceEnsure UEFI
ls /sys/firmware/efi/efivarsConnecting to WI-FI
iwctldevice liststation wlan0 scanstation wlan0 get-networksstation wlan0 connect wifi-namestation wlan0 showexitUpdate time
timedatectl set-ntp truetimedatectl statusUse mirror source
vim /etc/pacman.d/mirrorlistRecommend mirrors:
Server = https://mirrors.ustc.edu.cn/archlinux/$repo/os/$archServer = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$archSetup Btrfs
Check partition layout
lsblkUse cfdisk to setup the new partition
cfdisk /dev/sdxMake a swap first. The recommended size is about 60% of your RAM (e.g. 10GB if your RAM is 16GB). The type should be Linux swap.
Then make the main partition for your files. The type should be the default Linux filesystem.
If you donβt already have a boot partition, make a partition of type EFI System. Around 200-300 MB is proper, however I would recommend 512 MB.
After completing the partition, check it again and [Write].
Now you can use fdisk -l or lsblk to check your partition layout.
Format Btrfs and others
If necessary, format EFI partition:
mkfs.fat -F32 /dev/sdxnFormat Swap
mkswap /dev/sdxnFormat Btrfs
mkfs.btrfs -L ArchZone /dev/sdxnYou can also use your own label instead of ArchZone
mount -t btrfs -o compress=zstd /dev/sdxn /mntbtrfs subvolume create /mnt/@btrfs subvolume create /mnt/@homebtrfs subvolume list -p /mnt # if you want to checkumount /mntMount
mount -t btrfs -o subvol=/@,compress=zstd /dev/sdxn /mntmkdir /mnt/homemount -t btrfs -o subvol=/@home,compress=zstd /dev/sdxn /mnt/homemkdir -p /mnt/bootmount /dev/sdxn /mnt/bootswapon /dev/sdxnTo check:
df -hfree -hInstall system
pacstrap /mnt base base-devel linux-zen linux-firmware btrfs-progspacstrap /mnt iwd networkmanager vim sudo zsh zsh-completionsGenerate fstab
genfstab -U /mnt > /mnt/etc/fstabChange root
arch-chroot /mntFollow-up setup
vim /etc/hostnamevim /etc/hosts127.0.0.1 localhost::1 localhost127.0.1.1 [hostname].localdomain [hostname](You may use TAB to align them)
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtimehwclock --systohcvim /etc/locale.gen # en_US.UTF-8 UTF-8 & zh_CN.UTF-8 UTF-8locale-genecho 'LANG=en_US.UTF-8' > /etc/locale.confpasswd root# Choose onepacman -S intel-ucodepacman -S amd-ucodeBoot software
Install GRUB:
pacman -S grub efibootmgr os-probergrub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUBGet your swap partition id:
lsblk -o name,mountpoint,size,uuid | grep SWAPConfiguration:
vim /etc/default/grubGRUB_CMDLINE_LINUX_DEFAULT="loglevel=5 nowatchdog resume=UUID=[your swap partition uuid]"GRUB_DISABLE_OS_PROBER=falseGRUB_DEFAULT=savedGRUB_SAVEDEFAULT=trueGRUB_DISABLE_SUBMENU=y # OptionalApply:
grub-mkconfig -o /boot/grub/grub.cfgEdit resume hook:
vim /etc/mkinitcpio.confAdd resume in the HOOKS line. It must be added after udev, after block, before filesystems and before lvm2 if there is it.
Regenerate initramfs:
sudo mkinitcpio -PEnter your Arch Linux
After the above steps, you can reboot and boot into your Arch Linux!
Connecting to WIFI
vim /etc/NetworkManager/conf.d/wifi_backend.conf[device]wifi.backend=iwdsystemctl enable --now NetworkManagerThen use nmtui or iwctl.
fastfetch
pacman -S fastfetchfastfetchBasic configuration
pacman -SyuDo this regularly :)
Edit your .bash_profile
vim ~/.bash_profileto add:
export EDITOR='vim'to use vim as default editor.
Add a main admin user:
useradd -m -G wheel -s /bin/bash [username]passwd [username]EDITOR=vim visudo#%wheel ALL=(ALL) NOPASSWD: ALLConfig pacman:
vim /etc/pacman.confUncomment [multilib] and Color, add archlinuxcn at the bottom:
[archlinuxcn]Server = https://mirrors.ustc.edu.cn/archlinuxcn/$archServer = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$archThen
pacman -Sy archlinuxcn-keyringpacman -SyyuHyprland and more with my dotfiles (Optional)
Login with your main user instead of root for the following steps.
My dotfiles repository includes modern configuration files for CLI tools like zsh and a fancy rice for Hyprland. For example, get a modern zsh instantly through that:
sudo pacman -S yadmyadm clone -b dotfiles git@github.com:pstron/dotfiles.gitNow you can change your shell to zsh:
pacman -S fzf # fzf is requiredchsh -s /bin/zshTo install Hyprland and other related components, refer to the next post.
References
Arch Linux Brief Guide - A really nice guide for Arch Linux installation. Especially for CN users.
Arch Linux Wiki - Almost everything you want to know about Arch Linux or even more can be found here.