这些年日常操作系统一直是 windows 和 macOS 交替使用,Linux 一般只作为服务器的操作系统。 然而,咖喱味的 Windows 11 (LTSC)用起来实在难受(平时只玩游戏,下载) arm 的 macbook 虽然能效惊人,但是内存金子价格,软件也封闭(点名finder)和傲慢,实在受不了。 最后,还是转向 Linux,毕竟现在 wayland 基本堪用,国产软件也随着信创逐渐丰富了。
发行版选择 这里选用 KDE Neon user edition,基于 Ubuntu LTS, 有以下优点
Ubuntu 用户基数大,有问题容易解决
可以安装星火应用商店,方便使用国产软件
可以用到最新的 KDE 桌面环境,wayland 支持更好
KDE 远程桌面好用(服务端和客户端)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 OS: KDE neon User Edition x86_64 Host: MS-7D99 (3.0) Kernel: Linux 6.14 .0 -33 -generic Uptime: 1 day, 19 hours, 23 mins Packages: 2831 (dpkg) Shell: bash 5.2 .21 Display (E2434I-T): 1920x1080 @ 60 Hz in 24 " [External] Display (KOS2718): 3840x2160 @ 60 Hz (as 1920x1080) in 27" [External ] * DE: KDE Plasma 6.4 .5 WM: KWin (Wayland) WM Theme: Breeze Theme: Breeze (Light) [Qt ], Breeze [GTK2/3 ]Icons: Breeze [Qt ], breeze [GTK2/3/4 ]Font: 微软雅黑 (10pt) [Qt ], 微软雅黑 (10pt) [GTK2/3/4 ]Terminal: /dev/pts/3 CPU: 13th Gen Intel(R) Core(TM) i5-13500 (20) @ 4.80 GHz GPU 1: NVIDIA GeForce RTX 4060 Ti [Discrete ]GPU 2: Intel AlderLake-S GT1 @ 1.55 GHz [Integrated ]Memory: 25.07 GiB / 46.67 GiB (54%) Swap: 392.00 KiB / 8.00 GiB (0%)
硬件要求
NVIDIA 显卡在 Linux 下对 Wayland 支持不好,容易出现卡死或者重启的情况,建议显示器连到核显
有些主板 Linux 兼容性不行,建议使用御三家主板
系统设置 Nvidia 显卡驱动 显示器插到核显上,只使用 Nvidia 做计算,玩游戏也能调用到显卡。 使用开源服务器驱动,解决 Wayland 兼容性问题,防止玩游戏崩溃
安装驱动
1 sudo ubuntu-drivers install 580 -server -open
启用睡眠支持参考 将显存内容保存,否则唤醒后程序会报错(如CUDA程序)
1 2 3 4 5 options nvidia NVreg_PreserveVideoMemoryAllocations =1 NVreg_TemporaryFilePath =/tmp sudo update-initramfs
docker 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg ; done sudo apt-get updatesudo apt-get install ca-certificates curlsudo install -m 0755 -d /etc/apt/keyringssudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.ascsudo chmod a+r /etc/apt/keyrings/docker.ascecho \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME } " ) stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get updatesudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginsudo usermod -aG docker $USER newgrp docker https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html
ipv6 启用 EUI-64 可以让 ipv6 的ip后缀根据mac生成,可用于配置防火墙规则 使用形如 ::<后缀>/::ffff:ffff:ffff:ffff 的掩码
1 nmcli con modify <WIFI NAME> ipv6.addr-gen-mode eui64
启用休眠文件 1 2 3 4 5 6 7 8 sudo sucd /truncate -s 0 swapfilefallocate -l 8 G swapfile chmod 0600 swapfile mkswap swapfile swapon swapfile
使用英文用户文件夹 用户个人文件夹(文档、下载等),默认是跟随系统语言。 可是中文在终端下输入不太方便,建议使用英文用户文件夹名称。 方法步骤:
语言修改成英文,注销重新登录
打开文件管理器,确认修改为英文
语言修改回中文
打开文件管理器,保留原名称
无线网卡调优 WIFI 启用 WOL(网络唤醒)
1 2 3 4 iw phy0 wowlan show sudo iw phy0 wowlan enable magic-packet
关闭节能模式,解决无线网口入站延迟较大
1 2 3 4 5 6 7 8 cat <<EOF > /etc/NetworkManager/conf.d/wifi-powersave-off.conf [connection] wifi.powersave = 2 EOF sudo iw dev wlo1 set power_save off
睡眠调整 睡眠到内存(suspend)耗电量很低,够用了,没必要开启混合休眠
1 2 3 4 5 6 7 8 9 10 11 12 AllowSuspend =yes AllowHibernation =no AllowSuspendThenHibernate =no AllowHybridSleep =no SuspendState =mem standbysudo systemctl mask hibernate.target hybrid-sleep.target
intel 核显性能优化 10代以上 intel 核显
1 2 3 4 options i915 enable_fbc =1 enable_guc =2 enable_dc =0 sudo update-initramfs -u
RDP 远程桌面 服务端: 使用 KDE 默认的远程桌面 (可惜稳定性一般) 客户端: apt install krdc
其他配置
1 2 3 4 5 6 7 ExecStart= /usr/bin/krdpserver --monitor 0 systemctl --user daemon-reload systemctl --user restart app-org.kde.krdpserver.service
使用新内核(可选) 发行版默认内核版本可能比较老,如有必要可以更新内核注意 :mainline 的内核与 ubuntu-drivers 的 nvidia 显卡驱动不兼容(所以一般不推荐)
1 2 3 sudo add-apt-repository ppa:cappelikan/ppa sudo apt update sudo apt install mainline
软件使用 常见应用替代方案
qq: 使用官方linux版本的flatpak打包
flatpak install com.qq.QQ
任务管理器
flatpak install io.missioncenter.MissionCenter
词典:使用欧陆词典
flatpak install net.eudic.dict
微信
下载管理器:
motrix:普通http下载
qbittorrent: bt下载
虚拟机
游戏
steam:大部分游戏都可以直接运行,性能损耗也不大
视频播放
KVM 虚拟机 安装
1 2 3 sudo apt install qemu-kvm libvirt-daemon-system virt-managersudo usermod -aG libvirt,kvm $USER sudo systemctl enable --now libvirtd
硬盘直通(scsi), 相比下面的方法性能更好
1 2 3 4 5 <disk type ='block' device ='disk' > <driver name ='qemu' type ='raw' cache ='none' io ='native' /> <source dev ='/dev/disk/by-id/ata-TOSHIBA' index ='2' /> <target dev ='sdg' bus ='scsi' /> </disk >
硬盘直通(virtio),samba分享时可能卡顿
1 2 3 4 5 <disk type= "block" device= "disk" > <driver name= "qemu" type= "raw" cache= "none" /> <source dev= "/dev/disk/by-id/ata-ST3000DM008" /> <target dev= "sdc" bus= "virtio" /> </disk>
无线网口不支持桥接,使用路由绕过
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 net.ipv4.ip_forward = 1 net.ipv4.conf.wlo1.proxy_arp=1 net.ipv4.conf.br-routed.proxy_arp=1 [Unit] Description=Create routed bridge br-routed After=network.target Wants=network.target [Service] Type=oneshot RemainAfterExit=yes ExecStartPre=/usr/bin/ip link add br-routed type bridge ExecStart=/usr/bin/ip link set br-routed up ExecStartPost=/usr/bin/ip route add 192.168.1.41/32 dev br-routed ExecStop=/usr/bin/ip link delete br-routed [Install] WantedBy=multi-user.target <interface type ="bridge" > <mac address="00:00:00:00:00:00" /> <source bridge="br-routed" /> <target dev="vnet0" /> <model type ="virtio" /> <alias name="net0" /> <address type ="pci" domain="0x0000" bus="0x0a" slot="0x00" function ="0x0" /> </interface> IPv4 地址 . . . . . . . . . . . . : 192.168.1.41(首选) 子网掩码 . . . . . . . . . . . . : 255.255.255.0 默认网关. . . . . . . . . . . . . : 192.168.1.1 DNS 服务器 . . . . . . . . . . . : 192.168.1.1
dolphin 右键菜单自定义快捷方式 支持文件和文件夹
chmod + ~/.local/share/kio/servicemenus/mklink.desktop
1 2 3 4 5 6 7 8 9 10 [Desktop Entry] Type =ServiceServiceTypes =KonqPopupMenu/PluginMimeType =inode/directoryActions =RunMyScript[Desktop Action RunMyScript] Name =制作符号链接Icon =emblem-symbolic-linkExec =/home/rlj/scripts/mklink.sh "%F"
mklink.sh
1 2 3 4 #!/usr/bin/env bash NAME=$(basename "$1 " ) ln -s "$NAME " "$NAME .lnk"
haruna 视频播放器 haruna 是 mpv 播放器的前端,功能比较齐全
存在的问题:
视频播放器首次最大化窗口,总是跳到另一个屏幕
关闭另一个屏幕,关闭应用,再打开,再最大化,再重新打开屏幕
无法重命名文件
flatpak 使用 1 2 3 4 5 flatpak remote-modify flathub --url=https ://mirrors.ustc.edu.cn/flathub flatpak override --user org.kde.haruna --filesystem=/share
挂载 SMB 共享支持 windows 符号链接 支持原生符号链接(目录连接),双向操作都能同步
步骤
遇到的问题 故障排查方法
查看系统日志 journalctl -k -b0
查看用户日志,比如应用崩溃 journalctl –user -b0
用 AI 搜索相关问题,如果无法解决再尝试 google 搜索
edge 无法启动 edge 异常退出后,有概率无法启动
报错
1 2 Microsoft Edge 进程似乎正在使用此用户配置。Microsoft Edge 已锁定此用户配置以防止损坏。如果你确定没有其他进程正在使用此用户配置,可以将其解锁并重新启动 Microsoft Edge。
处理方法,其他 chromium 内核浏览器可能也类似
1 rm ~/.config/microsoft-edge/SingletonLock
steam 玩游戏卡住 dmesg 信息
1 2 3 4 7 月 27 10 :48 :59 neon kernel: x86/split lock detection: #AC: CPU 0 /KVM/88279 took a split_lock trap at address: 0 xfffff80104613be87 月 27 10 :51 :00 neon kernel: x86/split lock detection: #AC: CPU 2 /KVM/88281 took a split_lock trap at address: 0 xfffff8010465701c7 月 27 10 :52 :51 neon kernel: x86/split lock detection: #AC: CHTTPClientThre/90929 took a split_lock trap at address: 0 xf098fc4f7 月 27 10 :53 :07 neon kernel: x86/split lock detection: #AC: CPU 1 /KVM/88280 took a split_lock trap at address: 0 xfffff8010465701c
解决方法
1 2 3 4 GRUB_CMDLINE_LINUX_DEFAULT='quiet splash split_lock_detect=off' sudo update-grub
迁移系统&修复引导
进入 livecd,使用 Gparted 复制系统到新硬盘
修改新硬盘分区的 /etc/fstab 的挂载点 uuid
重建 grub 引导
1 2 3 4 5 6 7 mount /dev/sdaX /mnt/ mount /dev/sda0 /mnt/boot/efi for i in {proc,dev/sys}; do mount --bind /${i} /mnt/${i} done chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot/efi
睡眠唤醒后很卡 桌面很卡,cpu 频率上不来,只有 800mhz。 映泰主板兼容性问题,换主板解决
终端删除文件到回收站 1 2 sudo apt install trash-clialias rm =trash
electorn 应用无法启动 报错 chrome sandbox 相关
1 2 3 4 5 kernel.apparmor_restrict_unprivileged_userns =0 sudo sysctl -p
登录界面隐藏无关用户 比如某些用于文件共享的用户
1 2 3 4 5 6 7 [Autologin] Session =plasma[Users] HideUsers =data,data-r,data-sHideShells =/usr/sbin/nologin,/bin/false
偶发硬件设备工作不正常 强制重启后或者系统崩溃后,如果设备不正常,可以尝试重启到 windows 再切回 linux
应用在启动器里找不到 1 2 rm -f ~/.config/menus/kbuildsycoca6 --noincremental
修复睡眠唤醒问题 睡眠之后可能出现莫名奇妙的唤醒
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 cat /proc/acpi/wakeup | grep enable for p in /sys/class/wakeup/*/device/power/wakeup; do dev=$(dirname $(dirname $p )); dev_path=$(realpath $dev ) echo ${dev_path} done echo disabled | tee /sys/devices/platform/rtc_cmos/power/wakeup echo disabled | tee /sys/devices/platform/rtc_cmos/rtc/rtc0/alarmtimer.0.auto/power/wakeup echo disabled | tee /sys/devices/platform/ACPI000E:00/power/wakeup cat /proc/acpi/wakeup | grep enable