Arch Linux 安装配置指南

1. Pre-installation
Section titled “1. Pre-installation”Set Timezone
Section titled “Set Timezone”Ensure your system time is correct before installation.
timedatectl set-timezone Asia/ShanghaiDisk Partitioning
Section titled “Disk Partitioning”We will use fdisk to create a GPT partition table with an EFI System Partition (ESP) and a Root partition.
Create Boot Partition (ESP)
Section titled “Create Boot Partition (ESP)”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 changesFormat the ESP partition:
mkfs.fat -F32 /dev/sda1Create Root Partition
Section titled “Create Root Partition”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 changesFormat the Root partition:
mkfs.ext4 /dev/sda2Mount Partitions
Section titled “Mount Partitions”Mount the root partition to /mnt and the boot partition to /mnt/boot.
mount /dev/sda2 /mntmkdir -p /mnt/bootmount /dev/sda1 /mnt/bootConfigure Mirror List
Section titled “Configure Mirror List”Edit /etc/pacman.d/mirrorlist to use a fast mirror (e.g., Aliyun). Add the following line to the top of the file:
Server = http://mirrors.aliyun.com/archlinux/$repo/os/$arch2. Installation
Section titled “2. Installation”Install Base System
Section titled “Install Base System”Install the base system, development tools, kernel, and network manager.
pacstrap /mnt base base-devel linux dhcpcdGenerate Fstab
Section titled “Generate Fstab”Generate the fstab file to define how disk partitions should be mounted.
genfstab -L /mnt >> /mnt/etc/fstabVerify the content:
cat /mnt/etc/fstab3. System Configuration
Section titled “3. System Configuration”Chroot into New System
Section titled “Chroot into New System”Change root into the new system.
arch-chroot /mntSet Timezone
Section titled “Set Timezone”ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtimehwclock --systohcInstall Essential Packages
Section titled “Install Essential Packages”Install common tools like vim, networkmanager, etc.
pacman -S vim dialog wpa_supplicant ntfs-3g networkmanagerLocalization
Section titled “Localization”Edit /etc/locale.gen and uncomment the following lines:
en_US.UTF-8 UTF-8zh_CN.UTF-8 UTF-8zh_HK.UTF-8 UTF-8zh_TW.UTF-8 UTF-8Generate locales:
locale-genCreate /etc/locale.conf and set the LANG variable:
echo "LANG=en_US.UTF-8" > /etc/locale.confNetwork Configuration
Section titled “Network Configuration”Set the hostname (replace ArchLx with your desired hostname):
echo "ArchLx" > /etc/hostnameEdit /etc/hosts:
127.0.0.1 localhost::1 localhost127.0.1.1 ArchLx.localdomain ArchLxSet Root Password
Section titled “Set Root Password”passwdMicrocode (Intel CPU only)
Section titled “Microcode (Intel CPU only)”If you are using an Intel CPU, install the microcode updates.
pacman -S intel-ucode4. Bootloader Installation
Section titled “4. Bootloader Installation”We will use GRUB as the bootloader.
pacman -S os-prober ntfs-3g grub efibootmgrgrub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grubgrub-mkconfig -o /boot/grub/grub.cfg5. Finish
Section titled “5. Finish”Exit the chroot environment and reboot.
exitreboot