1.4.5. VMs Disk Space and Performance Optimizations

Warning

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.

Linux VMs

First let’s check the Linux use case scenario. Here it’s a bit more simple:

  1. Set the VM disks to VirtIO SCSI (NOT VirtIO BLOCK) and toggle the Discard option/checkbox.

  2. Inside the VM enable the fstrim service in Systemd.

    sudo systemctl enable fstrim.timer
    sudo systemctl start fstrim.timer
    
  3. Once you’ve done that manually run the fstrim command

    sudo fstrim -av
    
  4. If your VM is old(ish) or has seen some use it might take a bit and actually… you know, trim sectors.

Note

You can check the list of systemd timers with the command systemctl list-timers –all

Windows VMs

Requirements: Download the Latest Stable VirtIO Drivers ISO (for Windows)

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.

  1. Boot up your VM and mount the downloaded VirtIO ISO onto the VM’s CD/DVD Drive.

  2. Then add a small (e.g.: 1 GB) VirtIO SCSI Disk to the VM.

  3. Press [WIN] + R and write devmgmt.msc to open the Device Manager service console.

  4. 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.

  5. Select the drivers on the ISO under the relative path: .\vioscsi\*(your Windows version)*\amd64

    Note

    Change to i386 or ARM64 if you’re doing it on one of those architectures.

  6. After that you’ll want to shutdown the VM.

  7. Once the VM shuts down detach both disks (feel free to delete the 1GB disk).

  8. Re-attach the original disk as a VirtIO SCSI drive with SSD Emulation, Discard, and Writeback Cache ON.

  9. 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.

SOURCES: