Check#
- Your computer supports UEFI boot.
- Your computer has disabled secure boot.
- You have a basic understanding of Linux.
- A good mindset 😉
If you encounter problems during the installation process, try using a search engine to look up the issue or consult the Arch Wiki, and it's best not to ask others.
All information on your hard drive will be erased, so please back up in advance. You will be responsible for any data loss.
Preparation#
- An Arch Linux image.
- Use a disk writing tool to write the image file to your USB.
Once ready, please boot your Arch Linux ISO from the USB. After entering the Grub boot interface, please select the first option.
Networking#
This step is only necessary for devices that need to connect to the network via WLAN. If you are already connected via an Ethernet cable, please skip this step.
We can use the iwctl
command to connect to the network.
iwctl
device list # View your wireless network card name
station wlan0 scan # Scan for networks, usually the wireless card is wlan0
station wlan0 get-networks # List Wi-Fi networks
station wlan0 connect your_network_name # Connect to the network
exit # Exit
Then, you need to test if you are connected to the network.
ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=185 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=54 time=184 ms
64 bytes from 1.1.1.1: icmp_seq=3 ttl=54 time=185 ms
If you see continuous output similar to the above, you can press Ctrl+C to end.
Change Mirror#
Before this, please disable Reflector, as Reflector may update your mirrorlist file.
systemctl stop reflector.service
Delete the mirrorlist file.
sudo rm -rf /etc/pacman.d/mirrorlist
Then you can change it. You need to enter the following content to open it with the vim editor.
vim /etc/pacman.d/mirrorlist
Please add the following content:
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
After finishing, press ESC and enter :wq
to save and exit.
Partitioning#
Before partitioning, you need to check the number of your disk.
fdisk -l
Disk /dev/nvme0n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: KBG50ZNV512G KIOXIA
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 0B70F9F0-7C38-4F81-9EAB-754397E6079D
Device Start End Sectors Size Type
/dev/nvme0n1p1 2048 2099199 2097152 1G EFI System
/dev/nvme0n1p2 2099200 1000214527 998115328 475.9G Linux filesystem
You will see one or more disks like Disk /dev/*. Please check the partition or disk size to identify the disk you want to install on. For example, my computer has only one disk: /dev/nvme0n1. Once you have identified it, remember your disk number, and then enter:
cfdisk /dev/your_disk
You will see an interface
Disk: /dev/nvme0n1
Size: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
Label: gpt, identifier: 0B70F9F0-7C38-4F81-9EAB-754397E6079D
Device Start End Sectors Size Type
>> /dev/nvme0n1p1 2048 2099199 2097152 1G EFI System
/dev/nvme0n1p2 2099200 1000214527 998115328 475.9G Linux filesystem
┌────────────────────────────────────────────────────┐
│ Partition UUID: D3F1CADC-8559-44B4-A98F-3DCBD07C7B0B │
│ Partition type: EFI System (C12A7328-F81F-11D2-BA4B-00A0C93EC93B) │
│ Filesystem UUID: 59A1-A47E │
│ Filesystem LABEL: EFI │
│ Filesystem: vfat │
│ Mountpoint: /boot (mounted) │
└────────────────────────────────────────────────────┘
[ Delete ] [ Resize ] [ Quit ] [ Type ] [ Help ] [ Write ] [ Dump ]
- You need to delete all partitions. Select the partition and choose the first DELETE option until only Free Space remains in your device list.
- You need to select Free Space, then choose Create, change the partition size to
1G
, then select Type, find the first option, EFI, and select it. This partition will later be referred to as the EFI partition. Remember it is/dev/***
. - Continue to place the cursor on Free Space, press Enter directly, then select Write, and after entering
y
, your disk will be partitioned. This partition will later be referred to as the system partition. Remember it is/dev/***
.
Create Filesystem#
What you need to do is (create the filesystem for the EFI partition,) create the filesystem for the system partition, then create some subvolumes, and finally mount them. You can follow the commands below.
# Create filesystem for EFI partition
mkfs.fat -F32 /dev/(EFI_partition)
# Create filesystem for system partition
mkfs.btrfs -L ArchLinux /dev/(system_partition)
# Mount the partition
mount /dev/(system_partition) /mnt
# Create subvolumes
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
# Unmount
umount /mnt
# Mount
mount -t btrfs -o subvol=/@,compress=zstd /dev/sdxn /mnt
mount -t btrfs -o subvol=/@home,compress=zstd /dev/sdxn /mnt/home --mkdir
mount /dev/(EFI_partition) /mnt/boot --mkdir
Install Basic System#
Use the following commands to update the Keyring and install basic packages to your partition. The speed of this step depends on your internet speed and may take about 5 minutes.
pacman -Sy archlinux-keyring
pacstrap /mnt base base-devel linux linux-firmware btrfs-progs networkmanager vim nano sudo iwd net-tools
After completion, enter the following command to write your current mount location into the fstab of your system.
genfstab -U /mnt > /mnt/etc/fstab
You also need to enter the following command to check if there are subvolume IDs in your fstab.
grep "subvolid" /mnt/etc/fstab
If there is output after executing this step, please immediately use an editor to delete characters like subvolid=xxx
. Remember to also delete the comma that follows.
vim /mnt/etc/fstab
After finishing, press ESC and enter :wq
to save and exit.
Configuration#
Change Mirror for New System#
mkdir -p /mnt/etc/pacman.d
cp -r /etc/pacman.d/mirrorlist /mnt/etc/pacman.d
Switch to System#
arch-chroot /mnt
Hostname#
Enter the following command to set your computer's name (do not use symbols other than "-"). For example, my computer is called Silver:
echo "Silver" > /etc/hostname
Hosts#
Open /etc/hosts:
vim /etc/hosts
Please use the editor to add the following content:
127.0.0.1 localhost
::1 localhost
127.0.1.1 archlinux.localdomain archlinux
After finishing, press ESC and enter :wq
to save and exit.
Language Support#
Execute the following commands to add support for Chinese and English, and set the default language to English:
If you want to ask why not set Chinese, the answer is that your terminal does not support Chinese characters, even if you directly install a desktop environment, it won't work because you haven't installed Chinese fonts.
echo 'zh_CN.GBK GBK' > /etc/locale.gen
echo 'zh_CN.UTF-8 UTF-8' > /etc/locale.gen
echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen
locale-gen
echo 'LANG=en_US.UTF-8' > /etc/locale.conf
Root Password#
When you execute the command below, it will prompt you to set the root password. The characters you enter will not be displayed.
passwd root
Install Plasma Desktop (Optional)#
This will also install Chinese fonts.
pacman -S adobe-source-han-sans-cn-fonts plasma konsole dolphin xorg ark neofetch sddm
Enable Network Manager on Boot#
systemctl enable sddm
systemctl enable NetworkManager
Add User#
useradd -m -G wheel -s /bin/bash your_username
passwd your_username
You also need to have sudo privileges:
vim /etc/sudoers
# ↓ Find this line and remove the `#`, if there are spaces after it, remove the spaces after `#`.
# %wheel ALL=(ALL:ALL) ALL
After finishing, press ESC and enter :wq
to save and exit.
Install Microcode#
pacman -S intel-ucode
# or
pacman -S amd-ucode
Configure Bootloader#
- Use the following command to install the software:
pacman -S grub efibootmgr os-prober
- Use the following command to install the bootloader:
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=ARCH
- Allow discovery of other systems:
vim /etc/default/grub
After opening, remove the #
in front of the last line, then press ESC and enter :wq
to save and exit.
- Generate the configuration file:
grub-mkconfig -o /boot/grub/grub.cfg
Set to Chinese#
If you installed the Plasma desktop and SDDM earlier, you can now switch the system to Chinese.
rm -rf /etc/locale.conf
echo "zh_CN.UTF-8" >> /etc/locale.conf
Final Step#
You need to exit Chroot and reboot.
exit
reboot
All Done#
Congratulations, you have successfully installed Arch Linux.