“Debian minimal”通常指最小安装的 Debian(如 netinst 只装 base system,或服务器版不选桌面)。这类系统本身已经很轻量,但仍可从启动、内核、服务、资源占用、安全等方面进一步优化。
下面按实用优先级给你一份优化清单(适用于 Debian 11/12)。
查看正在运行的服务:
systemctl list-unit-files --type=service | grep enabled
常见可禁用的(视用途而定):
systemctl disable --now bluetooth
systemctl disable --now avahi-daemon
systemctl disable --now rpcbind
systemctl disable --now cups
如果是纯服务器,基本只保留
ssh
查看启动耗时:
systemd-analyze blame
禁用明显无用的:
systemctl disable <service>
查看已加载模块:
lsmod
如果是云服务器/虚拟机,可卸载无用驱动(谨慎):
modprobe -r <module>
并在 /etc/modprobe.d/blacklist.conf 中禁用。
编辑:
/etc/default/grub
可加:
GRUB_TIMEOUT=2
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
更新:
update-grub
systemd(稳定,不建议换)dash 代替 bash(更快):dpkg-reconfigure dash
swapoff -a
并注释 /etc/fstab 中 swap 行。
云服务器内存 ≥2G 通常可关
示例 /etc/sysctl.d/99-tuning.conf:
vm.swappiness=10
net.ipv4.tcp_fin_timeout=30
net.core.somaxconn=1024
生效:
sysctl --system
apt autoremove --purge
apt clean
apt install --no-install-recommends xxx
/etc/systemd/journald.conf
SystemMaxUse=50M
systemctl restart systemd-journald
/etc/fstab 示例:
ext4 defaults,noatime 0 1
/etc/ssh/sshd_config
PermitRootLogin no
systemctl restart ssh
apt install --no-install-recommends htop cron
如果你想要极限 minimal:
debootstrap 自建系统systemd(用 runit / openrc)⚠️ 不推荐生产环境随便搞
Debian minimal 的优化核心:关服务、减模块、控日志、限资源、保安全
如果你能说明使用场景(服务器 / 容器 / 嵌入式 / 桌面),我可以给你更针对性的优化方案。