Virtual Drive TRIM
How to perform TRIM/UNMAP operations on virtual drives in Windows and Linux to reclaim unused vSAN space, especially after importing thick-provisioned VMs.
After importing a virtual machine from another hypervisor, sometimes the free space available inside the virtual machine does not match the free space reported to the VergeOS platform. This discrepancy is often due to the virtual disk being thick-provisioned from the VM source, making VergeOS unaware of the unused disk space. To resolve this, a TRIM/UNMAP operation needs to be performed on the virtual disk from within the virtual machine.
Prerequisites for Running a TRIM Command
Edit the virtual drive(s) in question in the VergeOS UI and ensure Discard is enabled.
Ensure the virtual drive(s) is using a drive type of virtIO-SCSI or SATA.
Ensure the virtual drive(s) is assigned to a Solid State Tier (usually tier 1-3).
Trimming a Windows Drive
To perform a manual TRIM operation in a Windows environment, follow these steps:
Launch PowerShell as an admin user.
From the PowerShell prompt, type the following command:
Optimize-Volume -DriveLetter YourDriveLetter -ReTrim -VerboseExample:
Optimize-Volume -DriveLetter E -ReTrim -VerbosePress Enter and wait for the command to complete.
As the TRIM operation progresses, you can watch the reported free space in the VergeOS dashboard increase as the blank data on the volume is removed.
If this does not resolve the issue, TRIM may not be enabled. To check if TRIM is enabled:
Run the following FSUTIL command:
fsutil behavior query disabledeletenotifyIf the value is 1, TRIM is not enabled on the drive.
To enable TRIM, run:
fsutil behavior set disabledeletenotify 0After enabling, rerun the TRIM commands.
Trimming a Linux Drive
Newer Linux distros have TRIM enabled by default via a systemd service or a cron job. To check if automated TRIM is enabled, follow these steps:
Ensure the prerequisite steps from above are complete.
Example: Ubuntu Server
Launch a terminal.
Enter the following commands to check the status:
Check TRIM Timer/Schedule Status:
Check TRIM Service Status:
If TRIM is enabled, an operation will run at the next scheduled time. If TRIM is not enabled, you can run a manual TRIM using:
To enable automatic TRIM, run:
For more information on fstrim, visit the man page.
Last updated
Was this helpful?