FreeBSD 12.2-RELEASE-p9 trim: open failed: /dev/ada0: Operation not permitted

David Christensen dpchrist at
Sat Sep 4 01:54:55 UTC 2021

On 9/3/21 1:49 PM, Kurt Hackenberg wrote:
> On 2021/09/03 16:30, David Christensen wrote:
>>> It might be that a raw device could be trimmed, but perhaps there's 
>>> some safety there to stop it from wiping a device that is backing a 
>>> mounted filesystem.
> ...
>> That is a good point -- the filesystem knows what blocks are in use, 
>> what blocks are not in use, and when blocks are removed from use. 
>> Somehow, trim(8) gets this information (from the kernel filesystem 
>> stack?).
>> RTFM trim(8):
> Do I understand correctly that you want to set a state, so that the 
> filesystem, ongoing, erases a block when it frees the block?

My goal is to invoke a userspace utility that trims the unused blocks of 
the SSD prior to taking a raw binary image.  On Linux, it is pronounced 

> According to that man page, the trim command does something different: 
> it erases blocks immediately, unconditionally, regardless of whether 
> they're in use.
> The man page says:
> "The trim utility erases specified region of the device."
> "The whole device is erased by default..."

If so, I am lucky that trim(8) did not work (!).

> If you're using ZFS, perhaps you should look for a way to configure the 
> ZFS filesystem to erase on free.

A reply from another reader indicates OpenZFS on FreBSD 14 supports both 
automatic trim and userspace trim on command.


More information about the freebsd-questions mailing list