系统配置
加速AUR构建
从这里开始需要使用到普通用户,命令前#代表root用户,$代表普通用户。
你通常不应该直接使用root用户,在普通用户下可以在命令前加上sudo来以root权限运行命令,如sudo pacman -S base。
GitHub下载加速
加速脚本
# pacman -S axel
# su [用户名]
$ nano ~/makepkg_proxy添加以下内容
#!/bin/sh
domain=$(echo "$2" | cut -f3 -d'/')
case "$domain" in
"github.com"|"raw.githubusercontent.com")
url="https://github.dpik.top/$2"
;;
*)
url=$2
;;
esac
/usr/bin/axel -n 10 -a -o "$1" "$url"https://github.dpik.top是一个加速GitHub下载的网站,更多加速下载网站见此网站。 10是多线程下载的线程数。
$ chmod +x ~/makepkg_proxy使脚本可运行。
配置makepkg
$ sudo nano /etc/makepkg.conf修改下面的内容
DLAGENTS=('file::/usr/bin/curl -gqC - -o %o %u'
'ftp::/usr/bin/axel -n 15 -a -o %o %u'
'http::/usr/bin/axel -n 15 -a -o %o %u'
'https::/home/[用户名]/makepkg_proxy %o %u'
'rsync::/usr/bin/rsync --no-motd -z %u %o'
'scp::/usr/bin/scp -C %u %o')加速构建
# pacman -S rust pigz pbzip2 lbzip2配置cargo
$ mkdir ~/.cargo
$ nano ~/.cargo/config.toml添加以下内容
[source.crates-io]
replace-with = 'mirror'
[source.mirror]
registry = "sparse+https://mirrors.aliyun.com/crates.io-index/"安装paru
$ git clone https://aur.archlinux.org/paru.git ~/paru
$ cd ~/paru
$ makepkg -si修改MakePKG
$ paru -S plzip
$ sudo nano /etc/makepkg.conf修改下面的内容
MAKEFLAGS="-j4"
OPTIONS=(... !debug ...)
COMPRESSGZ=(pigz -c -f -n)
COMPRESSBZ2=(lbzip2 -c -f)
COMPRESSZST=(zstd -c -T0 --auto-threads=logical -)
COMPRESSLZ=(plzip -c -f)终端
Fish Shell和Zsh Shell是两个不同的终端。Fish更轻量,功能多,但不兼容POSIX;Zsh兼容POSIX。可以同时安装。
Fish
安装fish和插件管理器fisher
sudo pacman -S fish
mkdir -p ~/.config/fish/{plugins,conf.d}
nano ~/.config/fish/conf.d/fisher.fish添加以下内容
set -g fisher_path ~/.config/fish/plugins
set fish_complete_path $fish_complete_path[1] $fisher_path/completions $fish_complete_path[2..]
set fish_function_path $fish_function_path[1] $fisher_path/functions $fish_function_path[2..]
for file in $fisher_path/conf.d/*.fish
source $file 2>/dev/null
end安装tide
fish
curl -sL https://github.dpik.top/https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher
fisher install IlanCosman/tide@v6将 fish 用作交互式 shell
~/.bashrc追加以下内容
if [[ $(ps --no-header --pid=$PPID --format=comm) != "fish" && -z ${BASH_EXECUTION_STRING} && ${SHLVL} == 1 ]]
then
shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION=''
exec fish $LOGIN_OPTION
fiZsh + p10k
安装Zsh
sudo pacman -S zsh zsh-autosuggestions zsh-syntax-highlighting zsh-completions autojump
chsh -s /usr/bin/zsh
vim ~/.zshrc添加以下内容
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/autojump/autojump.zsh
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh警告
你可能需要将在 ~/.bash_profile 所做的配置复制到 ~/.zsh_profile,将在 ~/.bashrc 所做的配置复制到 ~/.zshrc。
安装p10k
curl -fsSL https://github.dpik.top/https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh
echo "zmodule romkatv/powerlevel10k" >> ~/.zimrc
zimfw install因为Zim框架是从GitHub下载插件的,所以速度极慢,多等多试几次就好,或者挂梯子。
桌面环境
GNOME
安装 GNOME
有三个软件组可用:
- gnome包组:包含基本的桌面环境和一些集成良好的应用
- gnome-circle包组:包含多种格外应用,极大的拓展了GNOME生态。
- gnome-extra包组:包含部分开发工具,以及其他适合GNOME的应用与游戏。
或者只安装gnome-shell包使用GNOME基础桌面环境。
显示管理器
sudo systemctl enable gdmKDE
安装 KDE
有两个包租可用:
- plasma包组:包含基本的桌面环境和一些集成良好的应用
- kde-applications包租:KDE全套应用
或者只安装kde-desktop包使用KDE基础桌面环境。
显示管理器
sudo systemctl enable plasmaloginWayland合成器
常见的Wayland的合成器有Niri、Hyprland、Mango等,他们提供强大的客制化功能,但是需要大量配置,大量软件需要手写。
你可以使用Noctalia Shell、Dank Material Shell等Wayland桌面shell来减少工作量。
这里以Niri + Noctalia来演示部分功能(Noctalia用到了Google的包,需要梯子)。
安装Niri
安装Niri、XWayland、XDG门户、显示管理器和剪贴板
sudo pacman -S niri xwayland-satellite xdg-desktop-portal-gtk xdg-desktop-portal-gnome uwsm cliphist补全GNOME XDG门户自带的Nautilus的功能,当然你也可以换别的
sudo pacman -S ffmpegthumbnailer gvfs-smb nautilus-open-any-terminal file-roller gnome-keyring gst-plugins-base gst-plugins-good gst-libav安装Noctalia
paru -S noctalia-shell-git matugen cava qt6-multimedia-ffmpeg配置终端
假设使用Kitty作为终端模拟器。
设置Nautilus默认终端模拟器。
sudo ln -s /usr/bin/kitty /usr/bin/gnome-terminal修改默认终端
nano ~/.config/kitty/kitty.conf修改shell为/usr/bin/fish,并去掉注释
美化Kitty
kitty + kitten themes
kitty list-fonts --psnames自动登录tty
sudo mkdir -p /etc/systemd/system/[email protected]/
sudo nano /etc/systemd/system/[email protected]/autologin.conf添加以下内容
[Service]
ExecStart=
ExecStart=-/sbin/agetty --noreset --noclear --autologin [用户名] - ${TERM}显示管理器
自动启动Niri
sudo nano ~/.bash_profile添加以下内容
if [[ -z $DISPLAY && $(tty) == /dev/tty1 ]]; then
exec uwsm start niri.desktop
fi输入法
Linux下主流输入法有iBus和Fcitx。
这里使用Fcitx5 + Rime + 雾凇拼音。
sudo pacman -S fcitx5-im fcitx5-rime fcitx5-nord rime-ice-pinyin-git配置fcitx5-rime
mkdir -p ~/.local/share/fcitx5/rime
nano ~/.local/share/fcitx5/rime/default.custom.yaml添加以下内容
patch:
__include: rime_ice_suggestion:/
menu/page_size: 10请ArchWiki查询当前桌面环境和显示协议需要使用的环境变量。
显卡驱动和硬件编解码
NVIDIA
在CodeNames搜索自己的显卡,看看对应的family是什么。然后在ArchWiki查找对应的显卡驱动。
linux官方内核使用nvidia-open,其他内核都使用nvidia-open-dkms。
sudo pacman -S nvidia-open-dkms nvidia-utils lib32-nvidia-utils nvidia-vaapi-driver可选:安装OpenCL加速计算
sudo pacman -S opencl-nvidia lib32-opencl-nvidiaAMD
AMD显卡不需要自己安装驱动,已经由linux-firmware和mesa提供。可以安装一下Vulkan驱动。
sudo pacman -S mesa lib32-mesa xf86-video-amdgpu vulkan-radeon lib32-vulkan-radeon可选:安装OpenCL加速计算
sudo pacman -S opencl-mesa lib32-opencl-mesaIntel
Intel显卡不需要自己安装驱动,已经由linux-firmware和mesa提供。可以安装一下Vulkan驱动。
Broadwell以后的Intel显卡装intel-media-driver,旧的装libva-intel-driver。
sudo pacman -S mesa lib32-mesa vulkan-intel lib32-vulkan-intel intel-media-driver可选:安装OpenCL加速计算
sudo pacman -S opencl-mesa lib32-opencl-mesa验证硬件编解码
先重启,再安装libva-utils
sudo pacman -S libva-utils运行vainfo验证,多显卡用户可以使用LIBVA_DRIVER_NAME环境变量指定要使用的显卡。
LIBVA_DRIVER_NAME=nvidia vainfo笔记本显卡切换
混合模式下用独显运行
PRIME
bashsudo pacman -S nvidia-prime使用 prime-run命令使用独显运行软件
bashprime-run steamswitcheroo-control
GNOME装这个可以右键桌面快捷方式选择使用独显运行
bashsudo pacman -S switcheroo-control sudo systemctl enable --now switcheroo-controlKDE:开始菜单右键编辑应用程序在高级页面设置用独显运行
显卡切换
目前Wayland没有完善的显卡切换,只能做到从混合模式切换到核显模式。独显直连需要手动进BIOS调整,建议安装时处在混合模式。从混合切到独显直连大概率会失败,谨慎操作。
supergfxctl
ASUS华硕用户可以用supergfxctl
bashparu -S supergfxctl sudo systemctl enable --now supergfxdGNOME从扩展里下载GPU supergfxctl switch
KDE从AUR安装plasma6-applets-supergfxctl
envycontrol
bashparu -S envycontrolGNOME装扩展GPU Profile Selector
KDE在桌面右键进入编辑模式,挂件商店里下载Optimus GPU Switcher
Zram内存压缩与 Swappiness 策略优化
Zram 在内存中创建一个压缩块设备作为 Swap 使用。由于 RAM 的速度远快于磁盘,且 Zstd 压缩效率高,这能显著提升系统响应速度,避免系统在内存压力大时卡死。
zram: Compressed RAM-based block devices — The Linux Kernel documentation
通用配置原则:
- Zram 大小:建议设为物理内存的 50% (
zram-fraction = 0.5)。- 小内存设备 (<16GB):可激进设为 100% (1.0) 以防止内存耗尽。
- 大内存设备 (≥32GB):50% (0.5) 已绰绰有余,既能提供巨大的交换空间,又保留了足够的物理内存安全红线。
- Swappiness:配合 Zram 时,建议保持默认 60 或更高(如 100)。这能让系统积极利用 Zram 压缩冷数据,腾出物理内存给文件缓存。切勿在使用 Zram 时将其设为 10。
1. 安装与配置 Zram 安装 zram-generator
sudo pacman -S zram-generator
sudo nano /etc/systemd/zram-generator.conf添加以下内容(注意:可以解除 4GB 默认限制):
[zram0]
# 压缩算法,zstd 是性能和压缩率的最佳平衡
compression-algorithm = zstd
# Zram 大小:设置为物理内存的百分之多少除以 100
zram-fraction = 0.5
# 解除默认的 4096MB (4GB) 限制,否则大内存机器只会分到 4G
max-zram-size = none
# 优先级,确保比磁盘 Swap 高(如果有的话)
swap-priority = 100启动zram
sudo systemctl daemon-reload
sudo systemctl start dev-zram0.swap验证安装
zramctl预期输出示例(DISKSIZE 应接近你的物理内存大小,如 64G)
# NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
# /dev/zram0 zstd 32G 4K 64B 20K 16 [SWAP]如果修改了配置文件(如调整大小)想立即生效且不重启电脑,建议按照以下“彻底重置”步骤操作:
sudo systemctl stop dev-zram0.swap
sudo systemctl stop [email protected]
# 如果下面的命令提示模块在使用,请先执行 sudo swapoff /dev/zram0,再执行此命令
sudo modprobe -r zram
sudo systemctl daemon-reload
sudo systemctl start dev-zram0.swap2. 调整 Swappiness(确保 Zram 被有效利用)
查看当前值(默认通常为 60)
cat /proc/sys/vm/swappiness确保其不为 10。如果需要强制指定为 60 或更高(如 100)
sudo nano /etc/sysctl.d/99-swappiness.conf添加以下内容
# Zram 专用优化:保持积极的换页策略
vm.swappiness = 60
# 可选:如果希望系统更激进地利用 Zram,可设为 100
# vm.swappiness = 100应用配置
sudo sysctl --system电源管理
sudo pacman -S tlp acpi
sudo systemctl enable --now tlp
sudo systemctl enable --now fstrim.timer笔记本电池充电阈值
sudo nano /etc/tlp.conf修改以下内容
START_CHARGE_THRESH_BAT0=60
STOP_CHARGE_THRESH_BAT0=80笔记本合盖不睡眠
sudo nano /etc/systemd/logind.conf修改以下内容
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
LidSwitchIgnoreInhibited=yes