Arch Linux 安装配置指南

1. 安装前准备
Section titled “1. 安装前准备”确保系统时间正确。
timedatectl set-timezone Asia/Shanghai使用 fdisk 创建 GPT 分区表,包含 EFI 系统分区 (ESP) 和根分区。
创建引导分区 (ESP)
Section titled “创建引导分区 (ESP)”fdisk /dev/sda# 在 fdisk 提示符中:# g - 创建新的 GPT 分区表# n - 添加新分区# 1 - 分区号 (默认 1)# 2048 - 起始扇区 (默认)# +512M - 结束扇区 (大小 512M)# t - 更改分区类型# 1 - 选择分区 1 (如有提示)# 1 - 设置类型为 'EFI System' (GPT 中代码为 1)# w - 写入更改格式化 ESP 分区:
mkfs.fat -F32 /dev/sda1fdisk /dev/sda# 在 fdisk 提示符中:# n - 添加新分区# - 分区号 (默认 2)# - 起始扇区 (默认)# - 结束扇区 (默认,使用剩余空间)# w - 写入更改格式化根分区:
mkfs.ext4 /dev/sda2将根分区挂载到 /mnt,引导分区挂载到 /mnt/boot。
mount /dev/sda2 /mntmkdir -p /mnt/bootmount /dev/sda1 /mnt/boot编辑 /etc/pacman.d/mirrorlist,使用快速镜像源(如阿里云)。在文件顶部添加:
Server = http://mirrors.aliyun.com/archlinux/$repo/os/$arch2. 系统安装
Section titled “2. 系统安装”安装基础系统
Section titled “安装基础系统”安装基础系统、开发工具、内核和网络管理器。
pacstrap /mnt base base-devel linux dhcpcd生成 Fstab
Section titled “生成 Fstab”生成 fstab 文件以定义如何挂载磁盘分区。
genfstab -L /mnt >> /mnt/etc/fstab验证内容:
cat /mnt/etc/fstab3. 系统配置
Section titled “3. 系统配置”切换到新系统
Section titled “切换到新系统”arch-chroot /mntln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtimehwclock --systohc安装必要软件包
Section titled “安装必要软件包”pacman -S vim dialog wpa_supplicant ntfs-3g networkmanager编辑 /etc/locale.gen,取消注释以下行:
en_US.UTF-8 UTF-8zh_CN.UTF-8 UTF-8zh_HK.UTF-8 UTF-8zh_TW.UTF-8 UTF-8生成 locale:
locale-gen创建 /etc/locale.conf:
echo "LANG=en_US.UTF-8" > /etc/locale.conf设置主机名(将 ArchLx 替换为你的主机名):
echo "ArchLx" > /etc/hostname编辑 /etc/hosts:
127.0.0.1 localhost::1 localhost127.0.1.1 ArchLx.localdomain ArchLx设置 Root 密码
Section titled “设置 Root 密码”passwd微码更新 (仅 Intel CPU)
Section titled “微码更新 (仅 Intel CPU)”pacman -S intel-ucode4. 引导加载器安装
Section titled “4. 引导加载器安装”使用 GRUB 作为引导加载器。
pacman -S os-prober ntfs-3g grub efibootmgrgrub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grubgrub-mkconfig -o /boot/grub/grub.cfg退出 chroot 环境并重启。
exitreboot