1.4.5. VMs Disk Space and Performance Optimizations¶
IF YOU’RE DOING THIS ON A VM WITH SENSITIVE DATA DO A BACKUP FIRST.
There are a few tweaks in Proxmox that you might not think about but are very important for VM disk optimizations. Trimming is super important as it will considerably shrink down your backup sizes due to empty sectors being correctly discarded.
Some settings might be shared between OSes, however there are a few specific settings you’ll have to set differently for Windows Machines.
First let’s check the Linux use case scenario. Here it’s a bit more simple:
Set the VM disks to VirtIO SCSI (NOT VirtIO BLOCK) and toggle the Discard option/checkbox.
Inside the VM enable the fstrim service in Systemd.
sudo systemctl enable fstrim.timer sudo systemctl start fstrim.timer
Once you’ve done that manually run the fstrim command
sudo fstrim -av
If your VM is old(ish) or has seen some use it might take a bit and actually… you know, trim sectors.
You can check the list of systemd timers with the command systemctl list-timers –all
In Windows VMs the principle is the same, set the disks to VirtIO SCSI, however you must first install the appropriate drivers in a specific way.
Boot up your VM and mount the downloaded VirtIO ISO onto the VM’s CD/DVD Drive.
Then add a small (e.g.: 1 GB) VirtIO SCSI Disk to the VM.
Press [WIN] + R and write devmgmt.msc to open the Device Manager service console.
There you’ll find a disk (the one you just added) without proper drivers and a warning sign, right-click it and do Install/Update Drivers.
Select the drivers on the ISO under the relative path: .\vioscsi\*(your Windows version)*\amd64
Change to i386 or ARM64 if you’re doing it on one of those architectures.
After that you’ll want to shutdown the VM.
Once the VM shuts down detach both disks (feel free to delete the 1GB disk).
Re-attach the original disk as a VirtIO SCSI drive with SSD Emulation, Discard, and Writeback Cache ON.
Test boot (If the boot doesn’t work roll-back the changes).
After it boots run a disk trim from the “Defragment and Optimize Drives” Application in your Windows VM.