“加速 Ubuntu Minimal”可以从系统启动速度、运行性能、资源占用几个层面入手。下面按实用程度分类说明(适用于 Ubuntu Minimal / Server / 云镜像)。
systemd-analyze
systemd-analyze blame
systemd-analyze critical-chain
Ubuntu Minimal 一般已经较轻,但仍可能有不需要的服务:
sudo systemctl disable --now bluetooth.service
sudo systemctl disable --now avahi-daemon.service
sudo systemctl disable --now snapd.service # 如果不用 snap
systemd 精简配置或改用 runit(不推荐一般用户)Ubuntu Minimal 默认已是通用内核,可换:
sudo apt install linux-image-lowlatency
或服务器用:
linux-image-virtual
sudo swapoff -a
sudo systemctl mask swap.target
⚠ 内存小于 2GB 不建议
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
避免:
| 替代 | 原方案 |
|---|---|
vim / nano |
IDE |
dash |
bash(默认已是 dash) |
curl |
浏览器 |
chrony |
systemd-timesyncd |
sudo nano /etc/fstab
添加:
noatime,discard
sudo systemctl enable fstrim.timer
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo apt install resolvconf
使用 1.1.1.1 或 8.8.8.8
ubuntu-minimal 镜像apparmor(仅测试环境)sudo systemctl disable apparmor
systemd-analyze
free -h
top -b -n1 | head
如果你能说明:
我可以给你更针对性的优化方案。