ZFS TRIM on Proxmox

norsemangrey

Member
Feb 8, 2021
63
9
13
40
Could someone please explain ZFS TRIM on Proxmox? Particularly the difference between setting autotrim=on and using zpool trim and best practices for use on SSD zpools an a Proxmox server (simple home lab server).
 
Last edited:
  • Like
Reactions: agroshev
The man page for zpool trim [1] provides a good explanation. Basically TRIM is used to discard unused storage blocks in the filesystem. This improves SSD performance and lifespan as it does not need to continually delete old blocks on every write. It also allows thinly provisioned storage to reclaim space that is unused by the guest operating system.

Particularly the difference between setting autotrim=on and using zpool trim
There are two main differences here. The first and most obvious is that autotrim=on allows trim operations to run automatically in the background while zpool trim must be called manually. The second is that zpool trim reclaims every free block it finds, while the autotrim feature waits until a large enough range of blocks have become free before it trims, for the sake of optimization [2].


best practices for use on SSD zpools an a Proxmox server (simple home lab server)
The zpoolprops man page [2] also mentions that autotrim can put significant stress on the underlying storage devices, depending on their quality. With this, it also implies that for lower end (non-enterprise grade) devices, running zpool trim periodically could be the better option. You could, for example, set up a cronjob to run zpool trim as often as you feel appropriate for your system and at times of lower activity.


[1] https://openzfs.github.io/openzfs-docs/man/8/zpool-trim.8.html
[2] https://openzfs.github.io/openzfs-docs/man/8/zpoolprops.8.html?highlight=autotrim
 
Last edited:
The man page for zpool trim [1] provides a good explanation. Basically TRIM is used to discard unused storage blocks in the filesystem. This improves SSD performance and lifespan as it does not need to continually delete old blocks on every write. It also allows thinly provisioned storage to reclaim space that is unused by the guest operating system.


There are two main differences here. The first and most obvious is that autotrim=on allows trim operations to run automatically in the background while zpool trim must be called manually. The second is that zpool trim reclaims every free block it finds, while the autotrim feature waits until a large enough range of blocks have become free before it trims, for the sake of optimization [2].



The zpoolprops man page [2] also mentions that autotrim can put significant stress on the underlying storage devices, depending on their quality. With this, it also implies that for lower end (non-enterprise grade) devices, running zpool trim periodically could be the better option. You could, for example, set up a cronjob to run zpool trim as often as you feel appropriate for your system and at times of lower activity.


[1] https://openzfs.github.io/openzfs-docs/man/8/zpool-trim.8.html
[2] https://openzfs.github.io/openzfs-docs/man/8/zpoolprops.8.html?highlight=autotrim

Thank you for the informative answer!
 
Interesting. I was not aware of zpool trim, but used fstrim -a instead, but I was not shure if it works, since the zvol are not mounted on the host.
It would trim the root filesystem, if you are using ZFS root. But it would not trim the ZVOLs that are the backing store for the VM's drives.
 

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!