Ubuntu 启动速度优化实操指南
一 定位瓶颈
systemd-analyze timesystemd-analyze blamesystemd-analyze critical-chainjournalctl -b -p 3sudo smartctl -a /dev/sdasudo apt install bootchart pybootchartgui,重启后在 /var/log/bootchart 查看 PNG。二 精简与并行化系统服务
sudo systemctl disable bluetooth.servicesudo systemctl disable cups.servicesudo systemctl disable ModemManager.servicenetworkd-dispatcher.serviceaccounts-daemon.servicemask:sudo systemctl mask <service>systemctl list-dependencies <service> --reverseDefaultTimeoutStartSec=、DefaultTimeoutStopSec= 设为合理值(如 10s),并启用并行:DefaultParallelization=yes,然后 sudo systemctl daemon-reexec 生效。三 调整内核与 GRUB 启动参数
GRUB_TIMEOUT=2GRUB_CMDLINE_LINUX_DEFAULT="quiet splash noresume fsck.mode=skip"
noresume:未使用休眠可跳过恢复检查fsck.mode=skip:跳过启动时的文件系统检查(有数据风险,谨慎)sudo update-grub四 存储与文件系统优化
sudo systemctl enable fstrim.timer(周期性 TRIM)discard(可选,部分设备/内核已自动处理):
UUID=xxxx / ext4 defaults,noatime,discard 0 0pass 值(1/2)。五 登录后启动项与桌面环境优化
gnome-session-propertiessudo sed -i 's/NoDisplay=true/NoDisplay=false/g' /etc/xdg/autostart/*.desktopsudo apt install preloadsudo apt install lightdm && sudo dpkg-reconfigure lightdmsudo apt autoremove --purgesystemd-analyze time、systemd-analyze blame 对比前后差异。