[SOLVED] Trim cronjob not working - PVE 7.3.4

tipex

Member
Jan 7, 2023
50
7
8
UK
Just wondering if anyone else has the same problem. In the default install I can see there are two cron jobs; one for scrubbing and one for triming:

nano /etc/cron.d/zfsutils-linux

1675076265014.png

I wanted to check that these jobs actually do something so I manually ran the following commands in the terminal:

/usr/lib/zfs-linux/trim
/usr/lib/zfs-linux/scrub

Using zpool status I could see that the scrub command worked.
Using zpool status -t the trim command seemed to not work as it showed both disks as being untrimmed:
1675076664836.png

I tried zpool trim rpool instead and that did work:
1675076744801.png

So now I'm left wondering why the command that cron is using does not work.

Any one else found the same?
 
/usr/lib/zfs-linux/trim; echo $? shows me that it returns exit code 1 and indeed fails to do something. I'm sure someone can add some echo statements and find out what is failing.
I have multiple pools with different characteristics (that are usually not running is night), so I don't use those scripts and just run zpool from my own cron jobs.
 
I wanted to check that these jobs actually do something so I manually ran the following commands in the terminal:

/usr/lib/zfs-linux/trim
check the script itself - it only automatically trims a pool if it's nvme only:
Code:
-|auto) pool_is_nvme_only "${pool}" && trim_if_not_already_trimming "${pool}" ;;

without explicitly trying the setting - 'org.debian:periodic-trim' to enable should run the periodic job also for other pools (in your case SATA SSDs)

I hope this explains it.
 
Ok yes. I did some poking around in the trim script. Added some print statements etc so I could understand what you mean.
It boils down to these two functions:
1675082936467.png

In my case the get_transp function does not = "nvme"
This then means the following highlighted line fails and so the next part after the && wont ever be run and therefore no trim will be done.
1675083433668.png

I can now see why it does not run. I will update my proxmox notes to reflect this, although really its nothing to do with proxmox.
Instead I will add a new cron job for the pools I'm interested in. For example, to trim first sunday of every month:
24 0 1-7 * * root if [ $(date +\%w) -eq 0 ]; then /usr/sbin/zpool trim rpool; fi

Thanks for your help in getting me to the point of understanding why it was not running.
 
Last edited:
  • Like
Reactions: Stoiko Ivanov
Didnt realise this problem until now, I set the property on my pools with SATA SSDs.

Doesnt seem to be blocking here either.
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!