Arch Linux-Hyprland 安装流程记录
- 1336
- 18 min
这是一份 Arch Linux + Hyprland 的安装流程记录。它不是一键脚本,而是把我认为最容易漏掉的步骤按顺序写下来。Arch 和 Hyprland 都更新很快,真正安装前应该同时打开官方 ArchWiki 和 Hyprland Wiki 对照。
下面命令默认是 UEFI 启动、单系统安装、EFI 分区挂载到 /boot。如果你是双系统、加密磁盘、Btrfs 子卷或 NVIDIA 显卡,需要按实际情况调整。
安装前检查
进入 Arch 安装介质后,先确认是否以 UEFI 模式启动:
ls /sys/firmware/efi/efivars如果这个目录不存在,说明当前不是 UEFI 模式。不要继续照抄 UEFI 的 GRUB 安装命令。
联网:
iwctl在 iwctl 里:
device list
station wlan0 scan
station wlan0 get-networks
station wlan0 connect SSID
exit有线网络通常会自动连上。检查:
ping archlinux.org同步时间:
timedatectl set-ntp true分区与格式化
先看磁盘名称:
lsblk假设目标磁盘是 /dev/nvme0n1,一个简单方案是:
/dev/nvme0n1p1 EFI 1G FAT32 /boot
/dev/nvme0n1p2 root 剩余 ext4 /可以用 cfdisk:
cfdisk /dev/nvme0n1注意:下面格式化命令会清空对应分区。
mkfs.fat -F 32 /dev/nvme0n1p1
mkfs.ext4 /dev/nvme0n1p2挂载:
mount /dev/nvme0n1p2 /mnt
mkdir -p /mnt/boot
mount /dev/nvme0n1p1 /mnt/boot如果想用 swapfile,可以等进入新系统后再建;如果想用 swap 分区,此时单独创建并 mkswap。
安装基础系统
用 pacstrap 安装基础系统和常用工具:
pacstrap -K /mnt base linux linux-firmware \
base-devel vim git sudo networkmanager \
grub efibootmgrIntel CPU 加:
pacstrap -K /mnt intel-ucodeAMD CPU 加:
pacstrap -K /mnt amd-ucode生成 fstab:
genfstab -U /mnt >> /mnt/etc/fstab检查:
cat /mnt/etc/fstab进入新系统:
arch-chroot /mnt基础配置
时区:
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock --systohc编辑 locale:
vim /etc/locale.gen取消注释:
en_US.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8生成:
locale-gen写入默认语言:
echo "LANG=en_US.UTF-8" > /etc/locale.conf主机名:
echo "arch-hyprland" > /etc/hostname/etc/hosts:
127.0.0.1 localhost
::1 localhost
127.0.1.1 arch-hyprland.localdomain arch-hyprland设置 root 密码:
passwd创建普通用户:
useradd -m -G wheel -s /bin/bash tsiayi
passwd tsiayi允许 wheel 组使用 sudo:
EDITOR=vim visudo取消注释:
%wheel ALL=(ALL:ALL) ALL启用网络:
systemctl enable NetworkManager安装 GRUB
UEFI + EFI 分区挂载到 /boot 的情况下:
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=Arch
grub-mkconfig -o /boot/grub/grub.cfg如果 EFI 分区挂载到 /boot/efi,则 --efi-directory 要改成 /boot/efi。
完成后退出并重启:
exit
umount -R /mnt
reboot安装 Hyprland
重启进入新系统后登录普通用户,先更新:
sudo pacman -Syu安装 Hyprland 和一组最小可用组件:
sudo pacman -S hyprland xdg-desktop-portal-hyprland xdg-desktop-portal-gtk \
waybar kitty rofi-wayland dunst \
pipewire wireplumber pipewire-pulse pipewire-alsa \
polkit-kde-agent qt5-wayland qt6-wayland \
grim slurp wl-clipboard brightnessctl playerctl \
noto-fonts noto-fonts-cjk noto-fonts-emoji这里几个包的作用:
xdg-desktop-portal-hyprland:Wayland 下屏幕共享、全局快捷键等 portal 功能。xdg-desktop-portal-gtk:补文件选择器等 GTK portal 功能。pipewire、wireplumber:音频和屏幕共享基础。dunst:通知守护进程。polkit-kde-agent:图形化权限认证。qt5-wayland、qt6-wayland:Qt 程序原生 Wayland 支持。
从 TTY 手动启动:
Hyprland如果能进入桌面,再考虑登录管理器。
最小 Hyprland 配置
创建配置目录:
mkdir -p ~/.config/hypr
cp /usr/share/hypr/hyprland.conf ~/.config/hypr/hyprland.conf可以先保留默认配置,再加入一些必要项:
monitor = ,preferred,auto,1
env = GDK_BACKEND,wayland,x11
env = QT_QPA_PLATFORM,wayland;xcb
env = XDG_CURRENT_DESKTOP,Hyprland
env = XDG_SESSION_TYPE,wayland
env = XDG_SESSION_DESKTOP,Hyprland
exec-once = waybar
exec-once = dunst
exec-once = /usr/lib/polkit-kde-authentication-agent-1
$terminal = kitty
$menu = rofi -show drun
$mainMod = SUPER
bind = $mainMod, RETURN, exec, $terminal
bind = $mainMod, D, exec, $menu
bind = $mainMod, Q, killactive
bind = $mainMod SHIFT, E, exit
input {
kb_layout = us
follow_mouse = 1
touchpad {
natural_scroll = true
}
}多显示器先用:
hyprctl monitors all再根据输出写具体配置,例如:
monitor = DP-1, 2560x1440@165, 0x0, 1
monitor = HDMI-A-1, 1920x1080@60, 2560x0, 1使用 greetd 登录
如果想开机进入登录界面,可以用 greetd + tuigreet:
sudo pacman -S greetd tuigreet编辑 /etc/greetd/config.toml:
[terminal]
vt = 1
[default_session]
command = "tuigreet --time --cmd Hyprland"
user = "greeter"启用:
sudo systemctl enable greetd重启前最好确认手动 Hyprland 已经能进入桌面,否则登录管理器只会把问题藏起来。
NVIDIA 相关
Hyprland 官方文档明确提醒:NVIDIA 并不总是开箱即用。如果使用 NVIDIA,至少要阅读 Hyprland 的 NVIDIA 页面和 ArchWiki。常见包是:
sudo pacman -S nvidia nvidia-utils较新的开源内核模块可以考虑:
sudo pacman -S nvidia-open nvidia-utilsHyprland 配置里常见环境变量包括:
env = LIBVA_DRIVER_NAME,nvidia
env = __GLX_VENDOR_LIBRARY_NAME,nvidia
env = GBM_BACKEND,nvidia-drm
env = ELECTRON_OZONE_PLATFORM_HINT,auto但这部分不要盲目复制。不同显卡、驱动版本、内核版本差异很大,最可靠的排错依据是官方 Wiki 和日志。
常见问题
没有网络
确认服务:
systemctl status NetworkManager如果没启用:
sudo systemctl enable --now NetworkManager没有声音
检查 PipeWire:
systemctl --user status pipewire wireplumber pipewire-pulse如果缺包,补装:
sudo pacman -S pipewire wireplumber pipewire-pulse pipewire-alsa截图或屏幕共享不能用
确认 portal:
systemctl --user status xdg-desktop-portal-hyprland
systemctl --user status xdg-desktop-portal同时确认安装了:
sudo pacman -S xdg-desktop-portal-hyprland xdg-desktop-portal-gtkQt 程序界面异常
安装:
sudo pacman -S qt5-wayland qt6-wayland并确认 Hyprland 配置里有:
env = QT_QPA_PLATFORM,wayland;xcb参考资料
- ArchWiki, Installation guide.
- ArchWiki, GRUB.
- ArchWiki, NetworkManager.
- Hyprland Wiki, Installation.
- Hyprland Wiki, Environment variables.
- Hyprland Wiki, xdg-desktop-portal-hyprland.
- Hyprland Wiki, Monitors.