Fstrim on Ubuntu 18.04

Recently I discovered that my backups of my proxmox virtual machines were taking up too much space on my storage server. After doing some research, i found out that I could run fstrim -v / to remove deleted space from my drive.

Now what I needed was a way to automated it. Using Cron I was able to make it run every 30 min and generate a log file, to verify and make sure its working correctly. But after adding the cron entry, it was not running. I added the entry under

sudo crontab -e

Then added the folowering command at the end of the file:

*/30 * * * * fstrim -v / >> /home/user/trim.log

This would run fstrim on the selected volume / (root). But, since things are not as easy as that, it was recording an error:

fstrim: not found 

After doing more research, I found out that sudo crontab -e would need the full path of the program. I went and made the following changes:

*/30 * * * * /sbin/fstrim -v / >> /home/user/trim.log

Now I have a log of fstrim then I added another line to the cron schedule

*/30 * * * * date >> /home/user/trim.log

Now i have a date time and result.


So empty here ... leave a comment!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.