从零安装 Arch Linux
Arch Linux 是一个以简洁、滚动更新和极致自由著称的发行版。安装 Arch 是一次深入了解 Linux 系统结构的旅程。本文结合 ArchWiki 安装指南 与实战步骤,记录一个从零到可用桌面的 Arch 安装过程,采用 UEFI 启动 + iwd 无线管理 + pipewire 音频 + zsh + i3 窗口管理器。
本文基于 2025 年官方安装镜像,适合新手及进阶用户参考。
💿 1. 制作并启动安装介质
sudo dd if=archlinux-xxx.iso of=/dev/sdX bs=4M status=progress && sync
- 启动时进入 BIOS/UEFI,关闭 Secure Boot,设置从 U 盘启动
- 选择
Arch Linux install medium
进入 Live 环境(默认以 root 登录,Shell 为 zsh)
🌐 2. 联网(使用 iwd 管理 WiFi)
# 启动 iwd
iwd
进入 iwd
控制台后:
station wlan0 scan
station wlan0 get-networks
station wlan0 connect your-ssid
确保联网后:
ping archlinux.org
💽 3. 磁盘分区(GPT + EFI 示例)
cfdisk /dev/nvme0n1
分区 | 挂载点 | 类型 | 大小 |
---|---|---|---|
/dev/nvme0n1p1 | /boot | EFI System | 512M |
/dev/nvme0n1p2 | / | ext4 | 剩余全部 |
格式化并挂载:
mkfs.fat -F32 /dev/nvme0n1p1
mkfs.ext4 /dev/nvme0n1p2
mount /dev/nvme0n1p2 /mnt
mount --mkdir /dev/nvme0n1p1 /mnt/boot
📦 4. 安装基础系统
pacstrap -K /mnt base linux linux-firmware neovim git zsh iwd
生成挂载信息:
genfstab -U /mnt >> /mnt/etc/fstab
切换到新系统环境:
arch-chroot /mnt
🔧 5. 系统配置
设置时区和本地化:
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock --systohc
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
设置主机名和 hosts:
echo arch > /etc/hostname
cat > /etc/hosts <<EOF
127.0.0.1 localhost
::1 localhost
127.0.1.1 arch.localdomain arch
EOF
设置 root 密码:
passwd
🧭 6. 安装引导程序(systemd-boot)
bootctl install
cat > /boot/loader/loader.conf <<EOF
default arch
timeout 3
editor 0
EOF
cat > /boot/loader/entries/arch.conf <<EOF
title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options root=PARTUUID=$(blkid -s PARTUUID -o value /dev/nvme0n1p2) rw
EOF
👤 7. 添加用户和 sudo 权限
useradd -mG wheel yourname
passwd yourname
EDITOR=nvim visudo # 取消 %wheel ALL=(ALL) ALL 前的注释
🌐 8. 启用网络服务(iwd)
systemctl enable iwd
🎯 9. 安装 yay 和常用软件包
pacman -S base-devel
cd /opt
git clone https://aur.archlinux.org/yay.git
chown -R yourname:yourname yay
su yourname
cd yay && makepkg -si
推荐安装的软件包(含简介):
软件 | 用途 |
---|---|
neovim | 文本编辑器 |
git | 版本控制 |
zsh + oh-my-zsh | 终端增强体验 |
alacritty | GPU 加速终端模拟器 |
firefox | 浏览器 |
ranger | 终端文件管理器 |
btop | 资源监控 |
unzip / tar | 解压工具 |
🖼️ 10. 图形界面与 i3 配置
安装 X + i3 + picom:
pacman -S xorg-server xorg-xinit i3 dmenu picom feh alacritty
# 设置启动 i3
echo 'exec i3' > /home/yourname/.xinitrc
chown yourname:yourname /home/yourname/.xinitrc
自动启动 X(添加到 ~/.bash_profile):
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx
🔊 11. 安装 Pipewire 音频系统
pacman -S pipewire wireplumber pipewire-audio pipewire-alsa pipewire-pulse
systemctl --user enable --now pipewire pipewire-pulse
🎨 12. 安装并配置 Polybar + i3 整合
pacman -S polybar
cd ~
git clone --depth=1 https://github.com/adi1090x/polybar-themes.git
cd polybar-themes
chmod +x setup.sh
./setup.sh
# 选择 hack 主题
编辑 i3 配置(~/.config/i3/config)添加 Polybar 启动:
exec --no-startup-id ~/.config/polybar/hack/launch.sh
💻 13. 安装 zsh + oh-my-zsh
pacman -S zsh
chsh -s /bin/zsh yourname
# 安装 oh-my-zsh
su - yourname
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
推荐插件:zsh-autosuggestions、zsh-syntax-highlighting(可用 yay 安装)
yay -S zsh-autosuggestions zsh-syntax-highlighting
在 ~/.zshrc
中添加:
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
✅ 总结
安装 Arch Linux 是一次系统掌控力的提升之旅。本文结合了官方指南与实际配置,帮助你快速完成一个轻量、稳定且美观的桌面系统。
你将收获:
- 干净自由的系统环境
- i3 + Polybar 极简桌面
- 全终端工作流 + 美化终端
- 深入理解 Linux 的启动与配置流程
下一篇我们将介绍 dotfiles 管理、美化 terminal、快捷键绑定等内容。
📚 推荐阅读: