This article is for record-keeping purposes and can serve as a reference. There are many detailed tutorials available online, as well as the official ArchWiki.
Preparation Before Installation#
About Dual Boot
There are two types of dual boot installations:
- One is to install Windows and Linux on the same hard drive. In this case, you need to allocate a free space in Windows for Linux in advance.
- The other is to install Windows and Linux on two separate hard drives. In this case, the boot settings after installation are different from a single system installation.
Download ISO
Go to the official Arch Linux website or some open-source mirror sites (Tsinghua) to download the latest ISO file.
Download and Install Disk Burning Software
I use Ventoy, which is open-source. It is different from regular burning software; regular software burns the installation boot system into the entire USB drive, making it unusable after installation without formatting. However, after using Ventoy to install the system, the USB drive can still be used normally, and there is no need to back up the files on the USB drive. Additionally, it is very simple to operate; you just need to copy the ISO file directly to the USB drive without any other operations.
Motherboard BIOS Settings
Before starting the installation, you need to make some simple settings in the BIOS:
- Disable Secure Boot. ArchWiki states that
Arch Linux installation images do not support Secure Boot
. - Set the installation disk (the USB drive) to boot first.
The method to enter BIOS varies by computer; you can refer to the official manual based on your computer model.
Installation#
Basic Settings#
After setting up the BIOS and plugging in the USB drive, you are ready to start the installation.
When the computer screen shows the boot loader menu, which is a selectable black box, select the first option "Arch Linux install medium" and press Enter to enter the Arch Linux installation environment.
Set Appropriate Font and Keyboard Layout (optional)
In the installation environment, the font in this console is particularly small and hard to read, so you can modify the font to choose a larger one. All available fonts are in the /usr/share/kbd/consolefonts/
directory, and you can set it using the setfont
command:
# Use the filename under /usr/share/kbd/consolefonts/ (omit the extension) as the command argument
setfont LatGrkCyr-12x22 # This is a relatively large font
You can also change the keyboard layout, which generally does not need to be changed; the default is US layout. All supported keyboard layouts are in each directory under /usr/share/kbd/keymaps/
, and you can modify it using the loadkeys
command:
# Similarly, the parameter below is the name of the keyboard layout without the extension
loadkeys keyboardlayout
Determine Computer's Boot Mode (optional)
The computer's boot mode for loading hardware drivers mainly includes the early BIOS and the current UEFI. The boot methods for the two modes are different. According to ArchWiki, you can confirm if the computer is in UEFI mode with the following command:
cat /sys/firmware/efi/fw_platform_size
# Returns 64 or 32, representing 64-bit and 32-bit UEFI, respectively. If the file does not exist, it may be BIOS.
Connect to Network
First, check if the network device is turned on:
# This command lists the names of wireless network devices (wlan0) and their status. If the status contains <...,...,UP,...>, it indicates the network device is turned on; otherwise, it is off.
ip link
# If it is not turned on, use the following command to turn it on
ip link set wlan0 up # Here the network card name is wlan0
# If the above command shows Operation not possible due to RF-kill, you need to unlock the network card using rfkill first.
# rfkill - tool for enabling and disabling wireless devices
rfkill # List wireless devices and their status
rfkill unblock wlan # unblock the network card
Then use iwctl
to set up the wireless network, which is an interactive command-line network setup program:
# View help information
help
# Check the current connection status of the network card
station wlan0 show
# Scan for networks
station wlan0 scan
# View available networks
station wlan0 get-networks
# Connect to the network named "P40 pro"
station wlan0 connect "P40 pro"
At this point, you can check if the network is connected:
ping baidu.com
If you cannot ping, it is likely that DHCP is not configured. Use:
dhcpcd &
Update System Clock
timedatectl set-ntp true # Synchronize system time with network time
Disk Partitioning#
Use fdisk
for disk partitioning.
Commands:
-
m: View help
-
p: Print the current partition table
-
g: Create a new empty partition table, clearing the original partitions. The newly created partitions will not be written until the
w
command is used, and the original partitions will not be overwritten. -
n: Create a new partition.
There are mainly three partitions:
boot partition + main partition + swap partition.
I will create four partitions here:
The first is the system boot partition, mounted at the /boot
directory.
The second is the main partition, mounted at the root directory /
.
The third is for storing user file data, mounted at the home directory /home
.
The fourth is the swap partition.
Format and Create File System
# The /boot partition should be FAT format
mkfs.fat -F32 /dev/nvme0n1p1
# The root partition and home directory partition choose ext4 file system
mkfs.ext4 /dev/nvme0n1p2
mkfs.ext4 /dev/nvme0n1p3
# Swap partition
mkswap /dev/nvme0n1p4
Mount Partitions
# Swap mount
swapon /dev/nvme0n1p4
# Main partition
mount /dev/nvme0n1p2 /mnt
# Boot partition
mkdir /mnt/boot
mount /dev/nvme0n1p1 /mnt/boot
# Home partition
mkdir /mnt/home
mount /dev/nvme0n1p3 /mnt/home
# or
# omit mkdir
# mount --mkdir /dev/nvme0n1p2 /mnt/home
After the mounting is complete, you can say that the system installation is more than halfway done.
Official Installation#
Choose Domestic Software Sources
Before installation, disable the reflector service, which automatically updates pacman's mirrorlist. If you close it too late, it's okay; you can manually add domestic sources.
# /etc/pacman.d/mirrorlist
# Move the mirror sources under China to the top.
Install System (Install Essential Packages)
Install base, linux, and linux-firmware.
pacstrap -K /mnt base linux linux-firmware
Create fstab File
fstab is used to define disk partitions. It is one of the important files in the Linux system. Use genfstab
to automatically generate and write the fstab file based on the current mount situation.
genfstab -U /mnt >> /mnt/etc/fstab
Post-Installation Configuration in the New System#
Switch the current installation environment to the new system environment:
arch-chroot /mnt
Set Time Zone and Synchronize Time
# Create a symbolic link in /etc/localtime with the appropriate time zone from /usr
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# Synchronize time
hwclock --systohc
Localization Settings
Edit /etc/locale.gen
and uncomment en_US.UTF-8 UTF-8
, then use locale-gen
.
locale-gen
Set the LANG variable in /etc/locale.conf
:
# /etc/locale.conf
LANG=en_US.UTF-8
Hostname and Host Configuration
Create a new /etc/hostname
file and add the hostname to it.
Also, add the configuration in the /etc/hosts
file:
# /etc/hostname
glede
# /etc/hosts
127.0.0.1 localhost
::1 localhost
127.0.0.1 glede.localdomain glede
Set Root Password
passwd
# SheN_2327
Install Some Software
# Intel microcode
# intel-ucode
# Bootloader
# grub efibootmgr os-prober
pacman -S grub efibootmgr intel-ucode os-prober
Configure Boot Loader (GRUB)
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=ARCH
# --efi-directory=/boot —— Install grubx64.efi to the previously specified location (EFI partition)
# --bootloader-id=ARCH —— Name it Arch
# Next, use vim to edit the /etc/default/grub file
# GRUB boot loader configuration
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Arch"
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=5 nowatchdog"
GRUB_CMDLINE_LINUX=""
GRUB_DISABLE_OS_PROBER=false
...
# Generate the configuration file needed for grub
grub-mkconfig -o /boot/grub/grub.cfg
Install Necessary Software
# Here you can install some essential software
pacman -S iwd dhcpcd zsh vim
# Network configuration: iwd dhcpcd
# Shell: zsh
# Editor: vim
Reboot
exit # Return to the installation boot system
reboot # Reboot, and remove the USB drive during the reboot process
Configuration After Reboot#
After rebooting, the system can be said to be installed, but to reach a usable level, there is still a long way to go, and a lot of work needs to be done to download many software.
The most important thing is to install a desktop environment. You can choose any desktop environment or window manager you like:
I chose to use Hyprland, but since my computer uses an Nvidia graphics card, the process of installing the Hyprland environment is extremely complicated, and I won't record it here. You can refer to the official Hyprland wiki.
Below are some basic configurations needed after installation.
Set vconsole Again
The previous section has discussed setting the vconsole font and keymap, but that was done in the installation environment for our convenience. Now that we are in the new system, we need to set it again.
The vconsole configuration is in the /etc/vconsole.conf
file:
# Add the font and keyboard settings to be modified in this file
KEYMAP=us
FONT=LatGrkCyr-12x22
Set Up Dual Boot
If it is a dual boot and installed on two separate drives, then when you boot, you will not be able to enter the Windows system. You need to configure the boot loader (GRUB).
# First, mount the Windows system boot partition
mount /dev/nvme1n1p1 /mnt
ls /mnt
# Use os-prober to detect other systems' boot
os-prober
# Reconfigure the grub file
cp /boot/grub/grub.cfg /boot/grub/grub.cfg.bak
grub-mkconfig -o /boot/grub/grub.cfg
Configure Network
Enable iwd:
systemctl enable iwd.service
systemctl start iwd.service
# The network configuration here is the same as above. You may also encounter rfkill issues; use the same method.
ip link
ip link set wlan0 up
rfkill
rfkill unblock wlan
# Then you can use iwctl to connect to the network.
Create Non-Root User
useradd -m -G wheel -s /bin/bash username
passwd username # Set password
# If you haven't downloaded vi, you can directly link vim to vi.
ln -s /usr/bin/vim /usr/bin/vi
# Use visudo to edit the sudo file and elevate the permissions of the wheel user group.
# Comment out the following line:
%wheel ALL=(ALL:ALL) ALL
Install man and sudo
pacman -S man-db sudo
Add Multilib && Archlinuxcn Sources
# Modify and add in the pacman configuration file
# /etc/pacman.conf
# Enable multilib
[multilib]
Include = /etc/pacman.d/mirrorlist
# Enable archlinuxcn
[archlinuxcn]
Server = https://mirrors.nju.edu.cn/archlinuxcn/$arch
# Here you can refer to the official website to add the mirror source closest to you.
pacman -S archlinuxcn-keyring archlinuxcn-mirrorlist-git
# Change the Server line under archlinuxcn to:
Include = /etc/pacman.d/archlinuxcn-mirrorlist
Disable the Annoying PC Speaker Beep
Adding the pcspkr module to the blacklist can prevent udev from loading it at startup.
# /etc/modprobe.d/nobeep.conf
blacklist pcspkr