Skip to content

Arch Linux 安装配置指南

Ensure your system time is correct before installation.

Terminal window
timedatectl set-timezone Asia/Shanghai

We will use fdisk to create a GPT partition table with an EFI System Partition (ESP) and a Root partition.

Terminal window
fdisk /dev/sda
# In fdisk prompt:
# g - Create a new empty GPT partition table
# n - Add a new partition
# 1 - Partition number (default 1)
# 2048 - First sector (default)
# +512M - Last sector (size 512M)
# t - Change partition type
# 1 - Select partition 1 (if asked)
# 1 - Set type to 'EFI System' (code 1 in fdisk for GPT)
# w - Write changes

Format the ESP partition:

Terminal window
mkfs.fat -F32 /dev/sda1
Terminal window
fdisk /dev/sda
# In fdisk prompt:
# n - Add a new partition
# - Partition number (default 2)
# - First sector (default)
# - Last sector (default, use remaining space)
# w - Write changes

Format the Root partition:

Terminal window
mkfs.ext4 /dev/sda2

Mount the root partition to /mnt and the boot partition to /mnt/boot.

Terminal window
mount /dev/sda2 /mnt
mkdir -p /mnt/boot
mount /dev/sda1 /mnt/boot

Edit /etc/pacman.d/mirrorlist to use a fast mirror (e.g., Aliyun). Add the following line to the top of the file:

Terminal window
Server = http://mirrors.aliyun.com/archlinux/$repo/os/$arch

Install the base system, development tools, kernel, and network manager.

Terminal window
pacstrap /mnt base base-devel linux dhcpcd

Generate the fstab file to define how disk partitions should be mounted.

Terminal window
genfstab -L /mnt >> /mnt/etc/fstab

Verify the content:

Terminal window
cat /mnt/etc/fstab

Change root into the new system.

Terminal window
arch-chroot /mnt
Terminal window
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock --systohc

Install common tools like vim, networkmanager, etc.

Terminal window
pacman -S vim dialog wpa_supplicant ntfs-3g networkmanager

Edit /etc/locale.gen and uncomment the following lines:

en_US.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8
zh_HK.UTF-8 UTF-8
zh_TW.UTF-8 UTF-8

Generate locales:

Terminal window
locale-gen

Create /etc/locale.conf and set the LANG variable:

Terminal window
echo "LANG=en_US.UTF-8" > /etc/locale.conf

Set the hostname (replace ArchLx with your desired hostname):

Terminal window
echo "ArchLx" > /etc/hostname

Edit /etc/hosts:

127.0.0.1 localhost
::1 localhost
127.0.1.1 ArchLx.localdomain ArchLx
Terminal window
passwd

If you are using an Intel CPU, install the microcode updates.

Terminal window
pacman -S intel-ucode

We will use GRUB as the bootloader.

Terminal window
pacman -S os-prober ntfs-3g grub efibootmgr
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub
grub-mkconfig -o /boot/grub/grub.cfg

Exit the chroot environment and reboot.

Terminal window
exit
reboot