Re: newfs TRIM flag device support

From: Ordinary Bit <ordinarybit_at_proton.me>
Date: Fri, 16 Feb 2024 09:18:47 UTC




Sent with Proton Mail secure email.

On Friday, 16 February 2024 at 14:02, Mark Millard <marklmi@yahoo.com> wrote:

> 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.
> 

Oh, that's amazing! I try it with my SanDisk Ultra microSDXC 64GB and mount it in a USB reader and it shows enabled in the tunefs and is detected in the dmesg, the same as yours. Therefore, SanDisk Ultra microSD supports it!

root@sd-extreme:~ # /sbin/newfs -U -t /dev/da0s2a
/dev/da0s2a: 59000.9MB (120833920 sectors) block size 32768, fragment size 4096
        using 95 cylinder groups of 625.22MB, 20007 blks, 80128 inodes.
        with soft updates
super-block backups (for fsck_ffs -b #) at:
 192, 1280640, 2561088, 3841536, 5121984, 6402432, 7682880, 8963328, 10243776, 11524224, 12804672, 14085120,
 15365568, 16646016, 17926464, 19206912, 20487360, 21767808, 23048256, 24328704, 25609152, 26889600, 28170048,
 29450496, 30730944, 32011392, 33291840, 34572288, 35852736, 37133184, 38413632, 39694080, 40974528, 42254976,
 43535424, 44815872, 46096320, 47376768, 48657216, 49937664, 51218112, 52498560, 53779008, 55059456, 56339904,
 57620352, 58900800, 60181248, 61461696, 62742144, 64022592, 65303040, 66583488, 67863936, 69144384, 70424832,
 71705280, 72985728, 74266176, 75546624, 76827072, 78107520, 79387968, 80668416, 81948864, 83229312, 84509760,
 85790208, 87070656, 88351104, 89631552, 90912000, 92192448, 93472896, 94753344, 96033792, 97314240, 98594688,
 99875136, 101155584, 102436032, 103716480, 104996928, 106277376, 107557824, 108838272, 110118720, 111399168,
 112679616, 113960064, 115240512, 116520960, 117801408, 119081856, 120362304

root@sd-extreme:~ # dmesg | grep TRIM
WARNING: /mnt: TRIM flag on fs but disk does not support TRIM

root@sd-extreme:~ # 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)

I plan to have TRIM flag enabled in the rootfs partition (/dev/ufs/rootfs) of my Raspberry Pi. Do you think of any implications when enabled? As shown below, it is disabled.

root@sd-extreme:~ # tunefs -p /dev/ufs/rootfs
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)                                         disabled
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)                                 rootfs

BR,
orbit