Open probonopd opened 1 year ago
Does this have any ill effect on non-SSDs?
Can we detect programmatically whether the pool is on a SSD?
Does this have any ill effect on non-SSDs?
Can we detect programmatically whether the pool is on a SSD?
hello% sudo smartctl -a /dev/ada0 | grep Solid
Rotation Rate: Solid State Device
NVME or USB SSDs don't show up under /dev/ada0
Is there any reason why this is not enabled by default in FreeBSD?
https://fosstodon.org/@pulkomandy@mastodon.tetaneutral.net/109406855529592690:
The reason it's off by default is more likely that some disks can crash their firmware when receiving commands they don't implement correctly
zpool-trim.8 — OpenZFS documentation
… Can we detect programmatically whether the pool is on a SSD?
zpoolprops.7 — OpenZFS documentation, see autotrim
.
Does this have any ill effect on non-SSDs?
Attention to a mobile hard disk drive, and a USB flash drive with a sole partition that's used for L2ARC:
root@mowa219-gjp4-8570p-freebsd:~ # zpool list -v
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
Transcend 464G 334G 130G - - 42% 72% 1.00x ONLINE -
gpt/Transcend 466G 334G 130G - - 42% 72.0% - ONLINE
indirect-1 - - - - - - - - ONLINE
cache - - - - - - - - -
gpt/cache-transcend 14.5G 6.44G 8.01G - - 0% 44.6% - ONLINE
august 912G 705G 207G - - 59% 77% 1.00x ONLINE -
ada0p3.eli 915G 705G 207G - - 59% 77.3% - ONLINE
cache - - - - - - - - -
gpt/cache-august 28.8G 11.9G 16.9G - - 0% 41.4% - ONLINE
gpt/cache2-august 14.4G 13.7G 772M - - 0% 94.8% - ONLINE
root@mowa219-gjp4-8570p-freebsd:~ # lsblk
DEVICE MAJ:MIN SIZE TYPE LABEL MOUNT
ada0 0:119 932G GPT - -
ada0p1 0:121 260M efi gpt/efiboot0 -
<FREE> -:- 1.0M - - -
ada0p2 0:123 16G freebsd-swap gpt/swap0 SWAP
ada0p2.eli 2:50 16G freebsd-swap - SWAP
ada0p3 0:125 915G freebsd-zfs gpt/zfs0 <ZFS>
ada0p3.eli 0:131 915G zfs - -
<FREE> -:- 708K - - -
da0 0:168 466G GPT - -
<FREE> -:- 1.0M - - -
da0p1 0:169 466G freebsd-zfs gpt/Transcend <ZFS>
da1 0:176 29G GPT - -
<FREE> -:- 1.0M - - -
da1p1 0:177 29G freebsd-zfs gpt/cache-august <ZFS>
da2 0:184 14G GPT - -
<FREE> -:- 1.0M - - -
da2p1 0:187 14G freebsd-zfs gpt/cache2-august <ZFS>
<FREE> -:- 1.0M - - -
da3 0:198 14G GPT - -
<FREE> -:- 1.0M - - -
da3p1 0:199 14G freebsd-zfs gpt/cache-transcend <ZFS>
root@mowa219-gjp4-8570p-freebsd:~ # geom disk list da0 da3
Geom name: da0
Providers:
1. Name: da0
Mediasize: 500107862016 (466G)
Sectorsize: 512
Stripesize: 4096
Stripeoffset: 0
Mode: r1w1e3
descr: StoreJet Transcend
lunid: 5000000000000001
ident: X3E1SAKRS
rotationrate: unknown
fwsectors: 63
fwheads: 255
Geom name: da3
Providers:
1. Name: da3
Mediasize: 15518924800 (14G)
Sectorsize: 512
Mode: r1w1e3
descr: Kingston DataTraveler 3.0
lunname: KingstonDataTraveler 3.0
lunid: KingstonDataTraveler 3.0
ident: 60A44C3FACC93110B9970045
rotationrate: 0
fwsectors: 63
fwheads: 255
root@mowa219-gjp4-8570p-freebsd:~ # zpool trim Transcend
cannot trim: no devices in pool support trim operations
root@mowa219-gjp4-8570p-freebsd:~ # zpool offline Transcend gpt/cache-transcend
root@mowa219-gjp4-8570p-freebsd:~ # zpool trim Transcend gpt/cache-transcend
cannot trim 'gpt/cache-transcend': device is in use as a cache
root@mowa219-gjp4-8570p-freebsd:~ # zpool online Transcend gpt/cache-transcend
root@mowa219-gjp4-8570p-freebsd:~ # sysctl vfs.zfs.l2arc.trim_ahead
vfs.zfs.l2arc.trim_ahead: 0
root@mowa219-gjp4-8570p-freebsd:~ #
Cross-reference:
NVME or USB SSDs don't show up under
/dev/ada0
That is expected.
So, for example:
% ls /dev/ada*
/dev/ada0 /dev/ada0p1 /dev/ada0p2 /dev/ada0p2.eli /dev/ada0p3 /dev/ada0p3.eli
% ls /dev/da*
/dev/da0 /dev/da1 /dev/da2 /dev/da3
/dev/da0p1 /dev/da1p1 /dev/da2p1 /dev/da3p1
% ls /dev/n*
/dev/netdump /dev/netmap /dev/null
% ls /dev/nvme*
ls: No match.
%
See tunefs(8) flag -t
.
trim
You might be curious about the trim
binary,
/usr/sbin/trim
Beware: it's not what some people might expect. From the DESCRIPTION of trim(8):
The trim utility erases (a) specified region of the device. …
So, for example, a dry run:
root@mowa219-gjp4-8570p-freebsd:~ # trim -N da4
trim da4 offset 0 length 2004877312
dry run: add -f to actually perform the operation
root@mowa219-gjp4-8570p-freebsd:~ #
A non-dry run would erase the device.
root@mowa219-gjp4-8570p-freebsd:~ # geom disk list da4
Geom name: da4
Providers:
1. Name: da4
Mediasize: 2004877312 (1.9G)
Sectorsize: 512
Mode: r1w1e2
descr: JetFlash Transcend 2GB
ident: FTRR0IBTVZ58PPPJ
rotationrate: unknown
fwsectors: 63
fwheads: 255
root@mowa219-gjp4-8570p-freebsd:~ #
Thanks @grahamperrin. Can you imagine a simple, straightforward shell script that enables TRIM on disks on which it is safe to be enabled?
Not me, sorry, I'm not a scripter.
https://www.crucial.com/articles/about-ssd/what-is-trim
Automatically:
Currently it is off
Manually:
Source: https://forums.freebsd.org/threads/how-to-enable-autotrim-for-zfs.86091/