TRIM(8)
π
TRIM(8) β the trim girlies' manual β¨
ok so bestie, welcome to trim(8), from the System Manager's Manual. This is the whole page, every single flag, no gatekeeping π
πΈ NAME πΈ
trim β the icon that erases device blocks that have no needed contents. she's literally a block deleter, that's her whole thing π«Ά
β SYNOPSIS β
trim [-Nfqv] [-[lo] offset[K|k|M|m|G|g|T|t|P|p|E|e]] [-r rfile] device
...
note the device ... at the end β she takes one or more devices, like a true main character with a whole entourage π
π¦ DESCRIPTION π¦
So trim erases a specified region of the device. That's it, that's the plot β¨ She's mostly relevant for storage that implements trim β think flash-based storage, or thinly provisioned storage. And okay bestie, listen: all erased data is lost. Not "moved to trash", not "recoverable with an app", lost. π
And now the big warning, because the kernel is not playing around:
Do not run trim on a mounted file system, or on active devices that are part of an imported ZFS pool or any other software RAID. The kernel generally doesn't even permit it. Ngl she will refuse.
But here's the tea π β if you do use her on a not-mounted file system or an inactive device, trim erases blocks non-selectively, whether a block is occupied or not. Like she's not checking, she's just wiping. So if you want the selective, careful version:
- peep
fsck_ffs(8), which has a flag-Ethat trims free blocks inside a populated UFS π - peep
zpool-trim(8)to trim an existing ZFS pool π
The following options are available (get comfy, there's a list):
β¨ OPTIONS β¨
-Nβ do not actually erase anything, just show what she would do (dry run, queen of manifestation π). Implies-v. This is the default. Overrides-f.-fβ actually perform the operation, fr fr. Overrides-N. π₯-l offset[K|k|M|m|G|g|T|t|P|p|E|e]-o offset[K|k|M|m|G|g|T|t|P|p|E|e]β these two together specify the region.-lgives the length of the region to trim,-ogives its offset from the beginning of the device. By default the whole device gets erased unless one or both of these options are presented π
The argument may be suffixed with one of K, M, G, T, P or E (either upper or lower case) to indicate a multiple of Kilobytes, Megabytes, Gigabytes, Terabytes, Petabytes or Exabytes, respectively. cute little unit letters, love that for us π§
-qβ do not output anything except possible error messages (quiet mode, she's giving mysterious π€«). Overrides-v.-r rfileβ uses the length of the given rfile as the length of the region to erase. The whole device is erased by default.-vβ show the offset and length of the actual region being erased, in bytes. Receipts! π§Ύ
Later options override previous ones. Periodt. π
One more note bestie: whether the operation actually succeeds depends on the underlying device driver β likeada(4),da(4)and others. Refer to the corresponding manual pages for the details on possible caveats in low-level support for ATA TRIM or SCSI UNMAP commands. iykyk π
π EXIT STATUS π
trim exits 0 on success, and >0 if an error occurs. If the final erase operation fails for an argument, trim returns exit code 1. She can also return one of the exit codes defined in sysexits(3), as follows:
EX_USAGEβ the specified offset or length of the region is incorrect. πEX_OSERRβ there is no enough memory to proceed. πEX_NOINPUTβ the specified rfile cannot be opened (perhaps it does not exist).EX_IOERRβ the specified rfile cannot be examined for its size due to some system input/output error.EX_DATAERRβ the specified rfile is not a regular file, directory nor special device, so its size cannot be examined. not her type, apparently πEX_UNAVAILABLEβ the specified rfile is a special device file not supporting theDIOCGMEDIASIZEioctl(2)(probably not a disk), so its size cannot be examined.
π SEE ALSO π
ioctl(2), sysexits(3), ada(4), da(4), nda(4), fsck_ffs(8), zpool-trim(8)
the whole squad, go say hi π«Ά
π HISTORY π
trim first appeared in FreeBSD 12.1. a legend from day one β
π AUTHORS π
trim was written by Eugene Grosbein <eugen@FreeBSD.org>. thank you eugene, icon behaviour π«‘π
and that's the whole manual, bestie β go forth and trim responsibly (or just use -N and vibe) π¦β¨
this page is from the Debian edition of the manual, dated December 9, 2025 β mwah, see u in the group chat π
π¦ where this page comes from
- freebsd 15.1: base 15.1
- Copyright (c) 2019 Eugene Grosbein <eugen@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms