优化 Ubuntu 虚拟机(VM)通常可以从宿主机配置、虚拟机设置、Ubuntu 系统内部优化三个层面来做。下面按实用程度分类说明,适用于 VirtualBox / VMware / KVM / 云主机。
virtiosudo sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
sudo apt update
systemctl disable bluetooth
systemctl disable cups
systemctl disable snapd
sudo apt install xubuntu-desktop
sudo systemctl enable fstrim.timer
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
sudo nano /etc/default/grub
# 修改
GRUB_TIMEOUT=0
sudo update-grub
linux-generic-hwe
sudo systemctl set-default multi-user.target
sudo apt install virtualbox-guest-dkms virtualbox-guest-utils
sudo apt install open-vm-tools
echo 'net.ipv4.tcp_timestamps=0' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
❌ 给虚拟机太多 CPU
❌ 使用 NAT + 高并发
❌ 在 VM 里跑大量 Docker 不调资源
如果你能告诉我:
我可以给你一套针对性优化方案。