← 返回首页

Ubuntu 26.04 装机后的完整配置实录:驱动、HiDPI、输入法、国产应用、终端环境

2026-05-26 · LinuxUbuntu 26.04WaylandHiDPIGNOME

环境: Ubuntu 26.04 amd64,GNOME 50、默认 Wayland、NVIDIA RTX PRO 6000 Blackwell(595 open 驱动)、5120×2160 物理 / 3072×1296 逻辑、166.7% 分数缩放、LANG=en_US.UTF-8(系统语言保持英文)。

这台机器是 Ubuntu 26.04 全新装的,硬件是新一代 Blackwell 显卡 + 4K,软件上保留英文 locale、跑桌面办公 + 开发 + 国产社交。Ubuntu 26.04 默认装完离「开机就走」还差不少,这篇把每件事的最终方案 + 命令按主题整理出来(章节顺序大致按依赖关系,不严格等于装机时间线)。涉及到细节多的几节会链回单独的排查文章。

0. NVIDIA Blackwell 驱动:必须用 -open 模块

Ubuntu 26.04 默认内核是 7.0.0-15-generic(uname -r 看),Blackwell 跑得起来,但默认装的 NVIDIA 驱动元包是错的:

# 如果误装过闭源 / dkms 版本,先清掉
sudo apt purge -y nvidia-dkms-595 nvidia-driver-595

# 装 open 驱动 + 预编译内核模块(跟随 HWE 内核更新)
sudo apt install -y -o DPkg::options::=--force-confnew \
    nvidia-driver-595-open \
    linux-modules-nvidia-595-open-generic-hwe-26.04

# 重启
sudo reboot

重启后验证:

nvidia-smi                                       # 期望正常输出 GPU 信息
cat /sys/module/nvidia_drm/parameters/modeset    # 期望 Y(KMS 已开)

NVIDIA + Wayland 下 modeset=Y 是 GDM 走 Wayland、能读懂分数缩放的前提。

坑提示: 清理 NVIDIA 残留时不要直接 apt-get autoremove --purge——它会把 dkms 当孤儿包一起删,你后面装别的东西可能还需要。卸载时显式写包名

1. GDM 登录界面 HiDPI 缩放

桌面会话调到 166.7% 后,登录界面(GDM greeter)还是糊的。按以前的老经验复制 ~/.config/monitors.xml/var/lib/gdm3/.config/ 完全没用——Ubuntu 26.04 的 gdm 50.0 同时改了两件事:

  1. greeter 改用 uid 60578(gdm-greeter) 跑,且不在 NSS 里(getent passwd gdm-greeter 查不到),要按数字 uid 引用。
  2. 配置目录搬到 /var/lib/gdm3/seat0/config/(按 seat 隔离),老路径静默忽略。

最终方案: 先在「设置 → 显示」里调好分辨率/缩放/刷新率,系统会写入 ~/.config/monitors.xml,然后:

sudo install -o 60578 -g nogroup -m 600 \
    ~/.config/monitors.xml \
    /var/lib/gdm3/seat0/config/monitors.xml
sudo rm -f /var/lib/gdm3/.config/monitors.xml    # 清掉老路径,避免误导
sudo systemctl restart gdm                        # 注意会立即结束当前会话

→ 详细排查(PAM 日志取证、binary strings 找路径):Ubuntu 26.04 GDM 登录界面 HiDPI 缩放配置

2. 英文 locale 下汉字显示成日文字形

系统语言保持英文,但希望中文按简体(SC)字形显示。问题表现:网页正文里的中文正常,而浏览器地址栏、应用 UI、终端里的中文偏窄、左右留白多(典型「复」字)。

根因:Ubuntu 默认的 64-language-selector-cjk-prefer.conf 把 CJK 字体排成 JP → KR → SC → TC → HK,无 lang 提示的汉字落到排第一的 JP。fc-match 'sans-serif:charset=590d' 一查就清楚。

最终方案: 新建 ~/.config/fontconfig/conf.d/80-prefer-sc-default.conf,强绑定前插 [拉丁主字体, 然后 SC]:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="pattern">
    <test name="family"><string>sans-serif</string></test>
    <edit name="family" mode="prepend" binding="strong">
      <string>Noto Sans</string>
      <string>Noto Sans CJK SC</string>
    </edit>
  </match>
  <match target="pattern">
    <test name="family"><string>serif</string></test>
    <edit name="family" mode="prepend" binding="strong">
      <string>Noto Serif</string>
      <string>Noto Serif CJK SC</string>
    </edit>
  </match>
  <match target="pattern">
    <test name="family"><string>monospace</string></test>
    <edit name="family" mode="prepend" binding="strong">
      <string>DejaVu Sans Mono</string>
      <string>Noto Sans Mono CJK SC</string>
    </edit>
  </match>
</fontconfig>
fc-cache -f
# 验证
fc-match 'sans-serif:charset=590d'       # 期望 Noto Sans CJK SC
fc-match 'sans-serif'                     # 期望 Noto Sans

fontconfig 在程序启动时读,改完必须彻底重启对应程序(刷新页面没用)。

→ 详细文章(走过的弯路、为什么 <prefer> / append 都不行):Ubuntu 26.04 中文显示成日文字形的修复

3. 中文输入法:fcitx5 → ibus-rime + 拼音加加双拼

装的时候先装的 fcitx5(从 Ubuntu 24 时代过来的肌肉记忆),发现 167% 缩放下 fcitx5 候选框在浏览器里飘到离光标很远的地方。整套换 IBus 后正常。

根因: GNOME 的 mutter 不把 Wayland text-input 协议暴露给第三方输入法,只内建集成 IBus。fcitx5 拿不到合成器的光标位置,只能用应用上报的坐标,在分数缩放下就飘了。这是架构性的,不是 fcitx5 配置问题。

最终选 RIME(而不是 ibus-libpinyin)的理由:想用双拼,RIME 的方案最灵活,自带 6 种双拼,词库可以换雾凇拼音(rime-ice),还能挂八股文 grammar 模型。

# 1. 装 IBus + RIME,清掉 fcitx5
sudo apt purge -y 'fcitx5*'
sudo apt install -y ibus ibus-rime rime-data-double-pinyin librime-plugin-octagram

# 2. /etc/environment 不需要塞 IM 变量(关键)
#    如果之前装 fcitx5 时往里塞过 GTK_IM_MODULE / QT_IM_MODULE / XMODIFIERS,
#    全删掉,留 PATH 一行就行。GNOME 对 IBus 是内建集成,不需要环境变量帮忙;
#    保留 GTK_IM_MODULE / QT_IM_MODULE 反而会让 GTK/Qt 应用走工具包 IM 模块,
#    绕过 Wayland text-input。

# 3. 切换 IM 框架
im-config -n ibus     # 写入 ~/.xinputrc: run_im ibus

# 4. GNOME 输入源(「设置 → 键盘」加,或 gsettings):
#    [('xkb','us'), ('ibus','rime')]
#    用 Super+Space 切换(GNOME 原生集成,fcitx5 时切不动)

/etc/environment 改完要注销重新登录才生效。

RIME 词库 + 双拼方案配置:RIME 自带词库小且老,换成 雾凇拼音 (rime-ice) + 拼音加加双拼:

mkdir -p ~/.config/ibus/rime
cd /tmp && git clone --depth=1 https://github.com/iDvel/rime-ice.git

# 1. 把 rime-ice 仓库根目录下的所有 *.yaml 和 *.dict.yaml 拷进 RIME 用户目录
#    (核心是 rime_ice.schema.yaml、rime_ice.dict.yaml、各个 double_pinyin_*.schema.yaml,
#     以及 default.yaml / cn_dicts/ 等)
cp -r rime-ice/{*.yaml,cn_dicts,opencc} ~/.config/ibus/rime/

# 2. 八股文(grammar)模型:从 lotem/rime-octagram-data 的 hans 分支拿
#    zh-hans-t-essay-bgw.gram(主,~10MB)+ zh-hans-t-essay-bgc.gram(~4MB)
#    放进 ~/.config/ibus/rime/(跟 yaml 同目录即可)

# 3. 在 ~/.config/ibus/rime/ 里新建 default.custom.yaml,指定默认方案:
cat > ~/.config/ibus/rime/default.custom.yaml <<'EOF'
patch:
  schema_list:
    - schema: double_pinyin_jiajia   # 拼音加加双拼,首位即默认
    - schema: rime_ice               # 全拼备选
EOF

# 4. 在 ~/.config/ibus/rime/ 里新建 double_pinyin_jiajia.custom.yaml,开 grammar:
cat > ~/.config/ibus/rime/double_pinyin_jiajia.custom.yaml <<'EOF'
patch:
  grammar:
    language: zh-hans-t-essay-bgw
    collocation_max_length: 5
    collocation_min_length: 2
  translator/contextual_suggestions: true
EOF

ibus restart    # 重新部署(RIME 没有 GUI,改完都靠这条)

RIME 没有偏好窗口——dpkg -L ibus-rime 只装引擎,所有配置 = 编辑 ~/.config/ibus/rime/ 下的 yaml + ibus restart。应用内切换方案按 F4

→ 详细文章(为什么 mutter 只给 IBus 暴露 text-input):Ubuntu 26.04 中文输入法:从 fcitx5 换回 IBus

4. Microsoft Edge + Wayland IME

Edge 通过 deb 源安装。装完默认走 XWayland 路径,中文输入会有问题(IME 候选框定位不准),需要强制走 Wayland 后端 + 开 Wayland IME:

# 装 Edge
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc \
    | sudo gpg --dearmor -o /usr/share/keyrings/microsoft.gpg
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/edge stable main' \
    | sudo tee /etc/apt/sources.list.d/microsoft-edge.list
sudo apt update && sudo apt install -y microsoft-edge-stable

然后复制系统 .desktop 到用户目录覆盖 Exec(这样升级 Edge 时系统文件被覆盖,但用户层的修改保留):

cp /usr/share/applications/microsoft-edge.desktop ~/.local/share/applications/
# 编辑 ~/.local/share/applications/microsoft-edge.desktop
# 把所有 Exec 行(主行 + Actions 的 new-window / new-private-window)改成:
#   Exec=/usr/bin/microsoft-edge-stable --ozone-platform=wayland --enable-wayland-ime %U
update-desktop-database ~/.local/share/applications/

Chromium 系都吃这两个参数。Firefox 默认就走 Wayland,不需要改。

5. VS Code + 开发基础工具

VS Code 用 Microsoft 的 独立仓库(不是 Edge 那个,两个 repo 各自独立):

# VS Code 的 deb 源(注意 keyring 和 repo URL 都跟 Edge 不一样)
sudo install -d -m 0755 /etc/apt/keyrings
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc \
    | sudo gpg --dearmor -o /etc/apt/keyrings/microsoft.gpg
echo 'deb [arch=amd64 signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/code stable main' \
    | sudo tee /etc/apt/sources.list.d/vscode.list
sudo apt update && sudo apt install -y code

# 顺手装的基础工具
sudo apt install -y git curl wireguard

VS Code 在 Wayland 下默认走 XWayland——大多数情况够用,字体清晰度强迫症的话也可以加 --ozone-platform=wayland --enable-wayland-ime,但 Electron 的 Wayland 支持比 Chromium 弱,有时会有边角问题,我自己没开。

6. 终端环境:Ghostty + zsh + oh-my-zsh + p10k + fzf + atuin

Ubuntu 26.04 默认终端是 Ptyxis(GNOME Terminal 26.04 已经不装了),换成 Ghostty(GPU 加速、HiDPI 下字形清晰、配置简单)。Ghostty 用 snap 装:

sudo snap install --classic ghostty

shell 换 zsh + oh-my-zsh + Powerlevel10k:

sudo apt install -y zsh fzf
chsh -s $(which zsh)     # 注销重新登录才生效

# oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# Powerlevel10k 主题
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git \
    ~/.oh-my-zsh/custom/themes/powerlevel10k

# 两个常用插件
git clone https://github.com/zsh-users/zsh-autosuggestions \
    ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting \
    ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting

# atuin —— 跨机同步、模糊搜索的 shell history
sudo apt install -y atuin

.zshrc 关键几段:

# Powerlevel10k instant prompt(必须在最顶,避免输入延迟)
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="powerlevel10k/powerlevel10k"
plugins=(git z extract zsh-autosuggestions zsh-syntax-highlighting fzf)
source $ZSH/oh-my-zsh.sh

# History
export HISTSIZE=50000
export SAVEHIST=50000
setopt INC_APPEND_HISTORY
unsetopt SHARE_HISTORY
setopt HIST_IGNORE_ALL_DUPS HIST_REDUCE_BLANKS

# Atuin(禁掉 up-arrow,只用 Ctrl-R)
command -v atuin &>/dev/null && eval "$(atuin init zsh --disable-up-arrow)"

# p10k 配置
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

第一次进 zsh 会自动跑 p10k configure 走主题向导。

7. RDP 远程桌面:sdl-freerdp

Wayland 会话 + 分数缩放下,RDP 默认是糊的:画面按逻辑分辨率出图、再被合成器整体放大。逐个客户端实测:

客户端路径结果
RemminaXWayland
Thincast (snap)强制 XWayland
Thincast (flatpak, Qt5)Vulkan黑屏(Blackwell 翻车)
sdl-freerdpSDL3 / OpenGL清晰

sdl-freerdp(包名 freerdp-sdl)是这台机器唯一实测清晰的。装完直接用,Remmina 卸了:

sudo apt install -y freerdp-sdl
sudo apt purge -y remmina remmina-plugin-rdp remmina-plugin-vnc remmina-plugin-secret

# 命令
sdl-freerdp /v:<host>:3389 /u:<user> \
    +dynamic-resolution /scale-desktop:150 /scale-device:140 \
    /gfx /sec:nla +f

退出全屏 = Right Shift + Enter。注意 FreeRDP 3.24.2 SDL 客户端在分数缩放下偶尔会因为光标 hotspot 越界崩(Cursor hot spot doesn't lie within cursor),上游 master 已 clamp 修复,等版本 > 3.24.2。

→ 详细文章(各客户端实测、为什么 Thincast 不行):Ubuntu 26.04 远程桌面(RDP)模糊的解决

8. 网络代理:WireGuard + Clash Verge

wireguard 走 apt;Clash Verge.deb 装(GitHub releases 上拿):

sudo apt install -y wireguard          # WireGuard 服务端/客户端
# 从 https://github.com/clash-verge-rev/clash-verge-rev/releases 下 .deb
sudo apt install -y /tmp/clash-verge_*.deb

Clash Verge 装完跑起来订阅链接导入即可,系统托盘里开关代理。如果用 zsh 想给终端走代理,在 .zshrc 里(我自己平时不开,只在需要时取消注释):

# export HTTPS_PROXY=http://localhost:7890
# export HTTP_PROXY=http://localhost:7890
# export ALL_PROXY=socks5://localhost:7890

9. 国产应用:微信、QQ、QQ 音乐(deb 安装)

Tencent 三件套都有官方 Linux .deb,直接装:

# 微信:https://linux.weixin.qq.com/
sudo apt install -y /tmp/WeChatLinux_x86_64.deb

# QQ:https://im.qq.com/linuxqq/
sudo apt install -y /tmp/QQ_amd64.deb

# QQ 音乐:https://y.qq.com/download/
sudo apt install -y /tmp/qqmusic_amd64.deb

三个都是 Electron 应用,装完在 /opt/{wechat,QQ,qqmusic}/,菜单里直接出 .desktop,Wayland 下能跑(Chromium 内核默认 ozone)。HiDPI 缩放显示正常。前面把 IBus 配好之后,中文输入也都能用,不需要额外参数。

但 QQ 音乐装完点开会直接闪退,QQ 和微信都正常,只有 QQ 音乐有问题。原因是它打包的 Electron 用了老的 SUID sandbox,在新内核的 user namespace 限制下起不来,进程一启动就崩。终端里手动跑 /opt/qqmusic/qqmusic 能看到一串 FATAL:setuid_sandbox_host.cc / sandbox not properly bootstrapped 之类的错。

修法:复制 .desktop 到用户目录覆盖,Exec 加 --no-sandbox:

cp /usr/share/applications/qqmusic.desktop ~/.local/share/applications/
# 编辑 ~/.local/share/applications/qqmusic.desktop,把 Exec 改成:
#   Exec=/opt/qqmusic/qqmusic --no-sandbox %U
update-desktop-database ~/.local/share/applications/

跟前面 Edge 用的同一个套路——改用户层 .desktop 而不是 /usr/share/applications/ 下的,这样 QQ 音乐升级覆盖 /usr/share/ 时本地修改不会被洗掉。这次升级新版本时如果不再闪退,把 --no-sandbox 撤掉就行。

--no-sandbox 是关 Chromium 沙箱的安全降级,但 QQ 音乐这种本来就是大量私有协议、上传剪贴板、读取播放列表的国产 Electron 应用,沙箱与否对它的实际威胁面影响不大;能跑起来更重要。QQ 和微信用的是另一套打包,默认就避开了这个坑,不需要 --no-sandbox

10. 多媒体 + 字体管理

零碎的:

sudo apt install -y smplayer font-manager

11. 给博客用的工具链:Hugo

驱动这个博客 (driftnode.cn) 的 Hugo:

sudo apt install -y --no-install-recommends hugo

--no-install-recommends 是为了避免拉一堆推荐依赖(主要是 pandoc 间接拉 TeX)。文章用 Markdown 写,hugo --minifypublic/,再 rsync 到服务器,部署脚本见博客源码。Hugo 自带 goldmark 渲染 Markdown,不需要 pandoc。

装机顺序参考

按依赖关系,从头装一台机器的推荐顺序:

  1. NVIDIA -open 驱动 + 预编译内核模块 → 重启
  2. 设置 → 显示调好缩放/分辨率 → 同步 GDM monitors.xml
  3. 字体修复(80-prefer-sc-default.conf + fc-cache)
  4. 输入法:apt purge fcitx5* → IBus + ibus-rime + rime-ice → 注销重登
  5. 浏览器:Edge → 改 .desktop 加 Wayland IME
  6. 终端环境:Ghostty + zsh + oh-my-zsh + p10k + atuin
  7. 开发工具:VS Code、git、curl、Hugo
  8. 远程桌面:sdl-freerdp
  9. 网络:WireGuard + Clash Verge
  10. 国产应用:微信 / QQ / QQ 音乐 .deb(QQ 音乐 .desktop--no-sandbox)
  11. 媒体:SMPlayer、font-manager

小结

Ubuntu 26.04 配合新硬件 + 分数缩放 + 英文 locale 的组合,默认体验远没到「装完就走」。但每个问题都有明确的工程化路径——共通的规律是: