What is fstrim?
fstrim tells SSDs or thin-provisioned storage which blocks are no longer used by the filesystem so they can be reclaimed.
Without TRIM/discard:
deleted data still looks “used” to the storage layer
SSD performance slowly degrades
thin storage pools appear full even when files were deleted
write amplification increases (reduces SSD lifespan)
Running fstrim weekly keeps storage clean and efficient.
Why Proxmox Needs Weekly fstrim
Proxmox commonly uses:
SSD/NVMe drives
LVM-thin
ZFS thin provisioning
Ceph RBD
qcow2 images
When VMs delete files, the host storage does not automatically know space is free.
Weekly fstrim:
✅ returns unused blocks to SSDs
✅ frees space in thin pools
✅ improves VM disk performance
✅ prevents storage from filling unexpectedly
✅ reduces SSD wear
Continuous discard (mount -o discard) is slower; periodic fstrim is the recommended approach.
Step 1 — Edit the fstrim Timer
Open the systemd timer configuration:
systemctl edit –full fstrim.timer
Step 2 — Modify the Timer Configuration
Replace or edit the file to look like this:
[Unit] Description=Discard unused filesystem blocks once a week
Documentation=man:fstrim
#ConditionVirtualization=!container
ConditionPathExists=!/etc/initrd-release [Timer] OnCalendar=weekly
AccuracySec=1h
Persistent=true
RandomizedDelaySec=100min [Install] WantedBy=timers.target
Important change
Comment out:
#ConditionVirtualization=!container
Why Comment This Line?
ConditionVirtualization=!container
This condition prevents the timer from running inside virtualized/container environments.
In Proxmox setups:
some hosts or nested environments are detected as virtualized
systemd may skip running fstrim
TRIM never executes even though storage supports it
Commenting it out ensures:
✅ fstrim runs reliably on Proxmox hosts
✅ TRIM works in nested or special virtualization setups
Step 3 — Save the File
Save and exit the editor.
Step 4 — Reload systemd
Apply the changes:
systemctl daemon-reload
Step 5 — Enable and Start the Timer
Enable weekly execution:
systemctl enable –now fstrim.timer
Step 6 — Verify Timer Status
Check that it is active:
systemctl status fstrim.timer
or:
systemctl list-timers fstrim.timer
You should see the next scheduled run.
Step 7 — Test Manually (Recommended)
Run fstrim once to confirm it works:
fstrim -av
Example output:
/: 12.3 GiB (13207031808 bytes) trimmed
This confirms TRIM is functioning.
How the Timer Works
Setting Meaning
OnCalendar=weekly runs once per week
AccuracySec=1h systemd may shift execution within 1 hour
Persistent=true runs missed jobs after reboot
RandomizedDelaySec=100min avoids many servers trimming simultaneously
Recommended Proxmox Practice
Best setup:
✅ weekly fstrim.timer
❌ avoid permanent discard mount option
✅ enable SSD emulation + discard in VM disk settings
✅ use virtio-scsi for guests
Quick Summary
What you did:
Edited fstrim.timer
Disabled virtualization restriction
Reloaded systemd
Enabled weekly TRIM
Result:
👉 automatic weekly reclaim of unused disk blocks
👉 better SSD performance
👉 accurate thin-storage usage
👉 longer drive lifespan