Re: newfs TRIM flag device support

From: Mark Millard <marklmi_at_yahoo.com>
Date: Fri, 16 Feb 2024 06:02:44 UTC
On Feb 15, 2024, at 20:08, Ordinary Bit <ordinarybit@proton.me> wrote:

> Hi!

Hello.

> On Friday, 16 February 2024 at 11:41, Mark Millard <marklmi@yahoo.com> wrote:
> 
>> [Only replying to lists I subscribe to.]
>> 
>> On Feb 15, 2024, at 19:19, Ordinary Bit ordinarybit@proton.me wrote:
>> 
>>> I'm reading the newfs manual https://man.freebsd.org/cgi/man.cgi?newfs(8) to be able to know about the TRIM flag. In the manual under -t parameter, it mentioned about "underlying device support", what exactly is this device?
>> 
>> 
>> 2 contrasting examples:
>> 
>> 
>> Example 0: Optane NVMe media (PCIe card or U.2, for example)
>> 
>> Optane has no need of TRIM and, so, never supports TRIM.
>> 
>> 
>> Example 1: microsd card media usage
>> 
>> A microsd card in the normal type of microsd card slot on
>> Small Board Computers (normally) supports TRIM. Take the
>> same card and put it in a USB reader/writer and use it
>> via USB on the same system: no TRIM is supported by
>> FreeBSD over USB.
>> 
> 
> So you mean to say that if I have a Rasperry Pi 3 or 4 now and then have my FreeBSD installed in a microSD card (for example, SanDisk Extreme card) with UFS/FFS filesytem in it with TRIM enabled parameter then is it going to recognize it? How to verify?
> 
>> 
>> FYI:
>> 
>> When the file system has TRIM enabled, FreeBSD put out a
>> notice if TRIM will not actually be used in the actual
>> context in use.
>> 
> 
> Ok, got it. How to check this as well?

The console gets a message like:

WARNING: /mnt: TRIM flag on fs but disk does not support TRIM

when a mount is attempted (automatic or manually) for a
file system with the trim flag enabled but trim does not
end up active.

So, for example:

# dmesg -a | grep TRIM
WARNING: /mnt: TRIM flag on fs but disk does not support TRIM

(This was a microsd card in a USB reader/writer that was not
used as the boot media: a separate manual mount was used.)

The file system's TRIM flag status can be checked via use of
"tunefs -p . . .":

# tunefs -p /mnt
tunefs: POSIX.1e ACLs: (-a)                                disabled
tunefs: NFSv4 ACLs: (-N)                                   disabled
tunefs: MAC multilabel: (-l)                               disabled
tunefs: soft updates: (-n)                                 enabled
tunefs: soft update journaling: (-j)                       disabled
tunefs: gjournal: (-J)                                     disabled
tunefs: trim: (-t)                                         enabled
tunefs: maximum blocks per file in a cylinder group: (-e)  4096
tunefs: average file size: (-f)                            16384
tunefs: average number of files in a directory: (-s)       64
tunefs: minimum percentage of free space: (-m)             8%
tunefs: space to hold for metadata blocks: (-k)            6400
tunefs: optimization preference: (-o)                      time
tunefs: volume label: (-L)                                 

If the trim flag is enabled but the mount does not produce the
console message, then TRIM is active.

===
Mark Millard
marklmi at yahoo.com