After build caches, intermediate transcoding files, and temporary collection data have been written and deleted repeatedly, df may show that the space has been freed. That only means the filesystem can allocate those blocks again; it does not mean the NVMe device has been notified that those logical ranges are no longer needed. To investigate this, check whether discard requests can pass through the storage stack rather than repeatedly clearing caches or changing mount options straight away.
UdpAmd dedicated servers come standard with two directly attached 1TB NVMe drives and no hardware RAID. Direct attachment, however, does not mean reclamation is automatically enabled in the operating system. The examples below use Ubuntu 24.04 and an ext4 data volume. The commands require appropriate administrative privileges. /srv/batch is an example path and must be replaced with the actual mount point before running them.
1. Distinguish file deletion, space reclamation, and data erasure
When a file is deleted, the filesystem first updates its own allocation records. fstrim then uses the filesystem interface to notify the underlying block device of the ranges currently eligible for reclamation. For NVMe, this ultimately maps to the deallocation mechanism supported by the device.
This does not defragment files or enlarge partitions. The output of a single command cannot tell you how the controller handles these ranges or when it reclaims internal space. Determining whether latency improves under the same workload requires a separate controlled test.
A successful fstrim run is not secure erasure. Do not treat the reported byte count as proof that sensitive data has been destroyed, or use it to promise a performance improvement.
Before proceeding, confirm that backups can be restored and pause batch jobs that would substantially change the test conditions. Schedule the first run for a period of low application load. The aim here is to verify the storage path, not to put sustained pressure on the entire server.
2. Inspect the storage path from the actual mount point
First identify which filesystem contains the path, then check device capabilities:
findmnt --target /srv/batch --output TARGET,SOURCE,FSTYPE,OPTIONS
df -hT /srv/batch
lsblk --output NAME,TYPE,SIZE,FSTYPE,MOUNTPOINTS
lsblk --discard
Pay particular attention to the TARGET returned by findmnt. If it is /, the directory is not a separate mount, and subsequent operations affect the entire root filesystem, not just that directory. Never infer the scope of an operation from the directory name alone.
In the output of lsblk --discard, DISC-GRAN indicates discard granularity, while DISC-MAX indicates the maximum range covered by a single discard request. Nonzero values mean the block layer reports support, but they do not replace an actual filesystem-level test. If the values are zero, investigate the device and any intermediate layers.
Verify every intermediate layer
If the setup uses LVM, software arrays, or encrypted mappings, check each layer along the device tree. Support in the underlying NVMe device does not guarantee that higher layers allow discard requests to pass through. Encrypted volumes also involve an information-disclosure trade-off: allowing discard may reveal which logical ranges are in use. Do not enable it merely to make an error go away.
This procedure does not change array, encryption, or LVM settings. If capabilities differ between layers, save the device tree and configuration first, then consult the documentation for the components actually in use. Do not format, repartition, or unmount production data volumes to “verify support.”
3. Run once, and only on a verified filesystem
After confirming that the target filesystem supports online reclamation, test a single mount point:
sudo fstrim --verbose --minimum 1M /srv/batch
rc=$?
printf 'fstrim_exit=%s\n' "$rc"
--minimum 1M skips free ranges smaller than that threshold, reducing the number of small ranges processed during the initial verification. It is not a site-wide performance setting. The filesystem may also adjust the effective threshold to meet its own constraints. Choose the operational policy based on the local manual pages and workload.
If /srv/batch is not a separate mount point, use the actual TARGET identified in the previous step and reassess the scope of the operation. Do not use --all for the initial verification, as it could affect volumes that have not been checked.
Keep the complete output and exit code. An “unsupported” result does not immediately mean the drive is faulty: the filesystem, a mapping layer, or the device itself may be blocking the operation. If a device I/O error occurs, stop repeating the test and inspect the kernel log:
sudo journalctl -k -b --no-pager
Monitor application latency and disk activity during execution. If either deviates significantly from its normal baseline, stop further testing and investigate the impact first. Do not repeatedly run reclamation during busy periods in pursuit of a larger reported byte count.
4. Check scheduled execution, not just enabled status
Ubuntu 24.04 can perform periodic reclamation through the system-provided service and timer. However, you must check on the server whether they are installed, enabled, and configured to cover the target volume:
systemctl cat fstrim.timer fstrim.service
systemctl list-timers --all fstrim.timer
systemctl status fstrim.timer fstrim.service --no-pager
sudo journalctl -u fstrim.service -b --no-pager
Start by reading the service’s ExecStart to understand how it enumerates filesystems and whether it ignores targets that do not support reclamation. Success for the service as a whole does not guarantee that a particular data volume was processed. Cross-check the output, mount configuration, and enumeration rules.
A timer being enabled only indicates that an enablement relationship exists; it does not mean a recent run succeeded. Likewise, a one-shot service showing inactive after execution has not necessarily failed. Check its exit status and logs.
Once you have confirmed that the scope provided by the distribution matches your requirements, enable the timer:
sudo systemctl enable --now fstrim.timer
Also check for existing custom scheduled jobs so that multiple schedulers do not run the same operation redundantly. If the service would process filesystems you want to exclude, adjust its scope before enabling the full job.
5. Finish with evidence, not assumptions
Keep at least five pieces of evidence for verification: the actual mount point and filesystem type; the device tree and discard capabilities; the manual run’s output and exit code; application behavior during execution; and the timer’s next trigger time together with its historical logs.
The reported byte count may exceed the total size of the files just deleted, and repeated runs may report similar values again. It describes the reclaimable ranges submitted, not an exact count of space reclaimed internally on the physical media. It is also usually consistent for df to remain almost unchanged before and after execution: the filesystem freed the space when the files were deleted.
The presence of continuous discard in the mount options does not, by itself, mean a periodic job should also be added. Continuous and batch reclamation have different overhead profiles, so do not adjust both at once without testing. Record the current state first, then change only one policy at a time so that the results can be interpreted.
The final conclusion should specify which filesystem was processed, which storage layers the requests passed through, which execution succeeded, and which job will continue scheduling it. This is easier to audit than simply saying “TRIM is enabled.” It also makes clear which evidence must be collected again if the filesystem is later replaced or a mapping layer is added.
Frequently asked questions
Do the bytes reported by fstrim represent newly available disk capacity?
No. They describe ranges submitted to the storage layer as reclaimable, not additional capacity or necessarily newly deleted files. Check filesystem free space separately with df.
Can a successful fstrim run prove secure erasure?
No. Discard tells the storage layer that ranges are no longer needed; it does not prove that every physical copy has been erased. Sensitive data disposal requires a separate, verified procedure.
EPYC 7543P Dedicated Server
From $458/month, billed in USD.