A comprehensive optimization tool specifically designed for Linux virtual machines running on Proxmox VE. This tool automatically detects your system configuration and applies optimal settings for memory management, disk I/O, network performance, and Proxmox-specific features.
Author: David Touzeau [email protected] License: MIT Language: Go 1.21+
-
Memory Optimization
- Dynamic swappiness adjustment based on available RAM
- Cache pressure tuning
- Transparent hugepages configuration
- Dirty page ratio optimization
- Optional cache dropping for cleanup
-
Disk I/O Optimization
- Automatic SSD/HDD detection
- Optimal I/O scheduler selection (none/mq-deadline for SSD, mq-deadline/bfq for HDD)
- Read-ahead buffer tuning
- I/O queue depth optimization
- Persistent udev rules creation
-
Network Performance
- TCP buffer size optimization
- BBR/CUBIC congestion control
- TCP Fast Open enablement
- Connection tracking optimization
- IPv6 optimizations
-
Proxmox VM Specific
- QEMU Guest Agent installation and configuration
- VirtIO driver optimization (multi-queue support)
- VirtIO balloon driver support
- Hardware RNG optimization
- CPU governor tuning
- Unnecessary service disabling
-
Safety Features
- Automatic backup before changes
- Full rollback capability
- Dry-run mode
- Persistent configuration across reboots
- Go 1.21 or higher
- Root/sudo access
- Linux kernel 4.0+ (recommended 5.0+)
- Running on a Proxmox VM (for VM-specific optimizations)
cd proxmox-optimizer
go mod init proxmox-optimizer
go mod tidy
go build -ldflags="-s -w" -o proxmox-optimizersudo cp proxmox-optimizer /usr/local/bin/
sudo chmod +x /usr/local/bin/proxmox-optimizerShow system information:
sudo proxmox-optimizer -infoApply all optimizations with automatic backup:
sudo proxmox-optimizerDry-run to see what would be changed:
sudo proxmox-optimizer -dry-runApply specific optimization categories:
# Memory optimizations only
sudo proxmox-optimizer -optimize memory
# Disk I/O optimizations only
sudo proxmox-optimizer -optimize disk
# Network optimizations only
sudo proxmox-optimizer -optimize network
# Proxmox VM specific optimizations only
sudo proxmox-optimizer -optimize proxmox
# All optimizations (default)
sudo proxmox-optimizer -optimize allFor high-performance systems (use with caution):
sudo proxmox-optimizer -aggressiveAggressive mode applies:
- Swappiness = 1 (minimal swapping)
- Smaller dirty page ratios
- BBR congestion control
- Performance CPU governor
- Cache dropping
- Higher buffer sizes
Generate a sample configuration:
proxmox-optimizer -generate-config > optimizer-config.jsonUse custom configuration:
sudo proxmox-optimizer -config optimizer-config.jsonExample configuration file:
{
"memory": {
"swappiness": 10,
"cache_pressure": 100,
"dirty_ratio": 15,
"dirty_background_ratio": 10,
"enable_hugepages": true,
"drop_caches": false
},
"disk": {
"ssd_scheduler": "mq-deadline",
"hdd_scheduler": "mq-deadline",
"readahead_ssd": 256,
"readahead_hdd": 2048,
"nr_requests": 128,
"enable_write_cache": false
},
"network": {
"rmem_max": 16777216,
"wmem_max": 16777216,
"tcp_mem_min": 4096,
"tcp_mem_default": 87380,
"tcp_mem_max": 16777216,
"congestion_control": "cubic",
"netdev_max_backlog": 2000,
"somaxconn": 1024,
"enable_ipv6": true
},
"proxmox": {
"enable_guest_agent": true,
"optimize_virtio": true,
"enable_balloon": true,
"optimize_rng": true,
"enable_timesync": true,
"disable_unnecessary_services": false,
"cpu_governor": "ondemand"
}
}Create backup without applying changes:
sudo proxmox-optimizer -backup -dry-runDisable automatic backup:
sudo proxmox-optimizer -backup=falseRestore from backup:
sudo proxmox-optimizer -restore /var/backups/proxmox-optimizer/backup-20250114-120000.tar.gzList available backups:
ls -lh /var/backups/proxmox-optimizer/The tool modifies the following kernel parameters:
Memory:
vm.swappiness- Controls swap usage preferencevm.vfs_cache_pressure- Inode/dentry cache reclaim pressurevm.dirty_ratio- Percentage of RAM that can be filled with dirty pagesvm.dirty_background_ratio- Background writeback thresholdvm.min_free_kbytes- Minimum free memory reservedvm.page-cluster- Swap readahead pages (0 for SSD)
Network:
net.core.rmem_max/net.core.wmem_max- Maximum socket buffer sizesnet.ipv4.tcp_rmem/net.ipv4.tcp_wmem- TCP buffer sizesnet.ipv4.tcp_mem- TCP memory allocationnet.ipv4.tcp_congestion_control- Congestion control algorithmnet.core.netdev_max_backlog- Network device backlognet.core.somaxconn- Socket listen backlognet.ipv4.tcp_fastopen- TCP Fast Opennet.ipv4.tcp_mtu_probing- Path MTU discovery- Many more TCP/IP optimizations...
Per-device optimizations:
- I/O scheduler (
/sys/block/*/queue/scheduler) - Read-ahead buffer (
/sys/block/*/queue/read_ahead_kb) - I/O queue depth (
/sys/block/*/queue/nr_requests) - Write cache settings (
/sys/block/*/queue/write_cache) - Entropy collection (
/sys/block/*/queue/add_random)
Persistent rules:
- Udev rules created at
/etc/udev/rules.d/60-proxmox-optimizer-disk.rules
Installed/Enabled:
qemu-guest-agent- Communication with Proxmox hostrng-tools- Hardware RNG utilizationsystemd-timesyncd- Time synchronization
Potentially Disabled (in aggressive mode):
bluetooth.serviceModemManager.serviceavahi-daemon.servicecups.service
Check applied settings:
# Check sysctl values
sysctl vm.swappiness
sysctl net.ipv4.tcp_congestion_control
# Check disk scheduler
cat /sys/block/sda/queue/scheduler
# Check QEMU guest agent
systemctl status qemu-guest-agent
# View all custom settings
cat /etc/sysctl.d/99-proxmox-optimizer.confBefore and after benchmarks:
# Disk I/O
sudo fio --name=randread --ioengine=libaio --iodepth=16 --rw=randread --bs=4k --direct=1 --size=1G --numjobs=4 --runtime=60 --group_reporting
# Network throughput
iperf3 -c <server-ip>
# Memory bandwidth
sysbench memory runTested on:
- Debian 11/12
- Ubuntu 20.04/22.04/24.04
- Proxmox VE 7.x/8.x guests
- Kernel 5.4+
Should work on any systemd-based Linux distribution.
- Always test in a development environment first
- Backups are created automatically at
/var/backups/proxmox-optimizer/ - Aggressive mode may cause issues on systems with limited resources
- Some optimizations require reboot to take full effect
- BBR congestion control requires kernel module support
# Check if BBR module is available
modprobe tcp_bbr
lsmod | grep bbr
# If not available, use cubic (default)# Ensure you're running as root
sudo proxmox-optimizer -info# Verify sysctl config
cat /etc/sysctl.d/99-proxmox-optimizer.conf
# Manually reload
sudo sysctl --system# Reload udev
sudo udevadm control --reload-rules
sudo udevadm triggerRemove all optimizations:
# Restore from latest backup
LATEST_BACKUP=$(ls -t /var/backups/proxmox-optimizer/backup-*.tar.gz | head -1)
sudo proxmox-optimizer -restore "$LATEST_BACKUP"
# Or manually remove
sudo rm /etc/sysctl.d/99-proxmox-optimizer.conf
sudo rm /etc/udev/rules.d/60-proxmox-optimizer-disk.rules
sudo sysctl --system
sudo udevadm control --reload-rules && sudo udevadm triggerThis tool is part of a larger system optimization toolkit. Improvements welcome!
MIT License - See LICENSE file for details
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
David Touzeau [email protected]
Created for optimizing Proxmox VE virtual machines in production environments.