温馨提示×

怎样加速ubuntu minimal

小樊
40
2026-09-13 07:52:20
栏目: 智能运维

“加速 Ubuntu Minimal”可以从系统启动速度、运行性能、资源占用几个层面入手。下面按实用程度分类说明(适用于 Ubuntu Minimal / Server / 云镜像)。


一、启动加速(Boot Speed)

1. 查看启动耗时

systemd-analyze
systemd-analyze blame
systemd-analyze critical-chain

2. 禁用不必要的服务

Ubuntu Minimal 一般已经较轻,但仍可能有不需要的服务:

sudo systemctl disable --now bluetooth.service
sudo systemctl disable --now avahi-daemon.service
sudo systemctl disable --now snapd.service   # 如果不用 snap

3. 使用轻量 Init 替代(进阶)

  • 不建议新手改
  • 可考虑 systemd 精简配置或改用 runit(不推荐一般用户)

二、系统运行加速(Performance)

4. 使用轻量内核

Ubuntu Minimal 默认已是通用内核,可换:

sudo apt install linux-image-lowlatency

或服务器用:

linux-image-virtual

5. 关闭 Swap(内存足够时)

sudo swapoff -a
sudo systemctl mask swap.target

⚠ 内存小于 2GB 不建议

6. 调整 swappiness

echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

三、减少资源占用(Memory / CPU)

7. 不装桌面环境(你已经用 Minimal ✅)

避免:

  • GNOME
  • snap 应用
  • 冗余守护进程

8. 使用轻量软件替代

替代 原方案
vim / nano IDE
dash bash(默认已是 dash)
curl 浏览器
chrony systemd-timesyncd

四、磁盘 & IO 加速

9. 使用 SSD + ext4 / noatime

sudo nano /etc/fstab

添加:

noatime,discard

10. 启用 TRIM(SSD)

sudo systemctl enable fstrim.timer

五、网络加速

11. 禁用 IPv6(如不需要)

sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1

12. 使用轻量 DNS

sudo apt install resolvconf

使用 1.1.1.18.8.8.8


六、虚拟机 / 容器场景

13. KVM / Docker 优化

  • 使用 ubuntu-minimal 镜像
  • 关闭 apparmor(仅测试环境)
sudo systemctl disable apparmor

七、一键“加速检查脚本”(示例)

systemd-analyze
free -h
top -b -n1 | head

如果你能说明:

  • 物理机 / 虚拟机 / 容器
  • 用途(服务器 / 开发 / 嵌入式)
  • 卡在哪个环节(启动慢 / 运行慢)

我可以给你更针对性的优化方案

0