12b5691eeSEugene Grosbein.\" 22b5691eeSEugene Grosbein.\" Copyright (c) 2019 Eugene Grosbein <eugen@FreeBSD.org>. 32b5691eeSEugene Grosbein.\" All rights reserved. 42b5691eeSEugene Grosbein.\" 52b5691eeSEugene Grosbein.\" Redistribution and use in source and binary forms, with or without 62b5691eeSEugene Grosbein.\" modification, are permitted provided that the following conditions 72b5691eeSEugene Grosbein.\" are met: 82b5691eeSEugene Grosbein.\" 1. Redistributions of source code must retain the above copyright 92b5691eeSEugene Grosbein.\" notice, this list of conditions and the following disclaimer. 102b5691eeSEugene Grosbein.\" 2. Redistributions in binary form must reproduce the above copyright 112b5691eeSEugene Grosbein.\" notice, this list of conditions and the following disclaimer in the 122b5691eeSEugene Grosbein.\" documentation and/or other materials provided with the distribution. 132b5691eeSEugene Grosbein.\" 142b5691eeSEugene Grosbein.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 152b5691eeSEugene Grosbein.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 162b5691eeSEugene Grosbein.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 172b5691eeSEugene Grosbein.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 182b5691eeSEugene Grosbein.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 192b5691eeSEugene Grosbein.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 202b5691eeSEugene Grosbein.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 212b5691eeSEugene Grosbein.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 222b5691eeSEugene Grosbein.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 232b5691eeSEugene Grosbein.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 242b5691eeSEugene Grosbein.\" SUCH DAMAGE. 252b5691eeSEugene Grosbein.\" 262b5691eeSEugene Grosbein.Dd January 18, 2019 272b5691eeSEugene Grosbein.Dt TRIM 8 282b5691eeSEugene Grosbein.Os 292b5691eeSEugene Grosbein.Sh NAME 302b5691eeSEugene Grosbein.Nm trim 312b5691eeSEugene Grosbein.Nd erase device blocks that have no needed contents 322b5691eeSEugene Grosbein.Sh SYNOPSIS 332b5691eeSEugene Grosbein.Nm 342b5691eeSEugene Grosbein.Op Fl Nfqv 352b5691eeSEugene Grosbein.Fl [ [lo] Xo 362b5691eeSEugene Grosbein.Bk -words 372b5691eeSEugene Grosbein.Sm off 382b5691eeSEugene Grosbein.Ar offset 392b5691eeSEugene Grosbein.Op Cm K | k | M | m | G | g | T | t ] 402b5691eeSEugene Grosbein.Sm on 412b5691eeSEugene Grosbein.Xc 422b5691eeSEugene Grosbein.Ek 432b5691eeSEugene Grosbein.Bk -words 442b5691eeSEugene Grosbein.Op Fl r Ar rfile 452b5691eeSEugene Grosbein.Ek 462b5691eeSEugene Grosbein.Ar device ... 472b5691eeSEugene Grosbein.Sh DESCRIPTION 482b5691eeSEugene GrosbeinThe 492b5691eeSEugene Grosbein.Nm 502b5691eeSEugene Grosbeinutility erases specified region of the device. 512b5691eeSEugene GrosbeinIt is mostly relevant for storage that implement trim (like flash based, 522b5691eeSEugene Grosbeinor thinly provisioned storage). 532b5691eeSEugene Grosbein.Sy All erased data is lost. 542b5691eeSEugene Grosbein.Pp 552b5691eeSEugene GrosbeinThe following options are available: 562b5691eeSEugene Grosbein.Bl -tag -width indent 572b5691eeSEugene Grosbein.It Fl N 582b5691eeSEugene GrosbeinDo not actually erase anything but show what it would do (dry run). 592b5691eeSEugene GrosbeinImplies 602b5691eeSEugene Grosbein.Fl v . 61*a6520796SGordon BerglingThis is the default. 62*a6520796SGordon BerglingOverrides 632b5691eeSEugene Grosbein.Fl f . 642b5691eeSEugene Grosbein.It Fl f 65*a6520796SGordon BerglingPerform the operation. 66*a6520796SGordon BerglingOverrides 672b5691eeSEugene Grosbein.Fl N . 682b5691eeSEugene Grosbein.It Fl l Xo 692b5691eeSEugene Grosbein.Sm off 702b5691eeSEugene Grosbein.Ar offset 712b5691eeSEugene Grosbein.Op Cm K | k | M | m | G | g | T | t 722b5691eeSEugene Grosbein.Sm on 732b5691eeSEugene Grosbein.Xc 742b5691eeSEugene Grosbein.It Fl o Xo 752b5691eeSEugene Grosbein.Sm off 762b5691eeSEugene Grosbein.Ar offset 772b5691eeSEugene Grosbein.Op Cm K | k | M | m | G | g | T | t 782b5691eeSEugene Grosbein.Sm on 792b5691eeSEugene Grosbein.Xc 802b5691eeSEugene GrosbeinSpecify the length 812b5691eeSEugene Grosbein.Fl l 822b5691eeSEugene Grosbeinof the region to trim or its offset 832b5691eeSEugene Grosbein.Fl o 842b5691eeSEugene Grosbeinfrom the beginning of the device. 852b5691eeSEugene Grosbein.Sy The whole device is erased by default 862b5691eeSEugene Grosbeinunless one or both of these options are presented. 872b5691eeSEugene Grosbein.Pp 882b5691eeSEugene GrosbeinThe argument may be suffixed with one of 892b5691eeSEugene Grosbein.Cm K , 902b5691eeSEugene Grosbein.Cm M , 912b5691eeSEugene Grosbein.Cm G 922b5691eeSEugene Grosbeinor 932b5691eeSEugene Grosbein.Cm T 942b5691eeSEugene Grosbein(either upper or lower case) to indicate a multiple of 952b5691eeSEugene GrosbeinKilobytes, Megabytes, Gigabytes or Terabytes 962b5691eeSEugene Grosbeinrespectively. 972b5691eeSEugene Grosbein.It Fl q 982b5691eeSEugene GrosbeinDo not output anything except of possible error messages (quiet mode). 992b5691eeSEugene GrosbeinOverrides 1002b5691eeSEugene Grosbein.Fl v . 1012b5691eeSEugene Grosbein.It Fl r Ar rfile 1022b5691eeSEugene GrosbeinUses the length of given 1032b5691eeSEugene Grosbein.Ar rfile 1042b5691eeSEugene Grosbeinas length of the region to erase. 1052b5691eeSEugene Grosbein.Sy The whole device is erased by default. 1062b5691eeSEugene Grosbein.It Fl v 1072b5691eeSEugene GrosbeinShow offset and length of actual region being erased, in bytes. 1082b5691eeSEugene Grosbein.El 1092b5691eeSEugene Grosbein.Pp 1102b5691eeSEugene GrosbeinLater options override previous ones. 1112b5691eeSEugene Grosbein.Pp 1122b5691eeSEugene GrosbeinNote that actual success of the operation depends of underlying 1132b5691eeSEugene Grosbeindevice driver such as 1142b5691eeSEugene Grosbein.Xr ada 4 , 1152b5691eeSEugene Grosbein.Xr da 4 1162b5691eeSEugene Grosbeinand others. 1172b5691eeSEugene GrosbeinRefer to corresponding manual pages for detail on possible caveats 1182b5691eeSEugene Grosbeinin low level support for ATA TRIM or SCSI UNMAP commands. 1192b5691eeSEugene Grosbein.Sh EXIT STATUS 1202b5691eeSEugene Grosbein.Ex -std 1212b5691eeSEugene GrosbeinIf the final erase operation fails for an argument, the 1222b5691eeSEugene Grosbein.Nm 1232b5691eeSEugene Grosbeinutility returns exit code 1. 1242b5691eeSEugene GrosbeinIt can also return one of the exit codes defined in 1252b5691eeSEugene Grosbein.Xr sysexits 3 , 1262b5691eeSEugene Grosbeinas follows: 1272b5691eeSEugene Grosbein.Bl -tag -width ".Dv EX_UNAVAILABLE" 1282b5691eeSEugene Grosbein.It Dv EX_USAGE 1292b5691eeSEugene GrosbeinThe specified offset or length of the region is incorrect. 1302b5691eeSEugene Grosbein.It Dv EX_OSERR 1312b5691eeSEugene GrosbeinThere is no enough memory to proceed. 1322b5691eeSEugene Grosbein.It Dv EX_NOINPUT 1332b5691eeSEugene GrosbeinThe specified 1342b5691eeSEugene Grosbein.Ar rfile 1352b5691eeSEugene Grosbeincannot be opened (perhaps, it does not exist). 1362b5691eeSEugene Grosbein.It Dv EX_IOERR 1372b5691eeSEugene GrosbeinThe specified 1382b5691eeSEugene Grosbein.Ar rfile 1392b5691eeSEugene Grosbeincannot be examined for its size due to some system input/output error. 1402b5691eeSEugene Grosbein.It Dv EX_DATAERR 1412b5691eeSEugene GrosbeinThe specified 1422b5691eeSEugene Grosbein.Ar rfile 1432b5691eeSEugene Grosbeinis not regular file, directory nor special device, so its size 1442b5691eeSEugene Grosbeincannot be examined. 1452b5691eeSEugene Grosbein.It Dv EX_UNAVAILABLE 1462b5691eeSEugene GrosbeinThe specified 1472b5691eeSEugene Grosbein.Ar rfile 1482b5691eeSEugene Grosbeinis special device file not supporting DIOCGMEDIASIZE 1492b5691eeSEugene Grosbein.Xr ioctl 2 1502b5691eeSEugene Grosbein(probably not a disk), so its size cannot be examined. 1512b5691eeSEugene Grosbein.El 1522b5691eeSEugene Grosbein.Sh SEE ALSO 153*a6520796SGordon Bergling.Xr ioctl 2 , 154*a6520796SGordon Bergling.Xr sysexits 3 , 1552b5691eeSEugene Grosbein.Xr ada 4 , 1562b5691eeSEugene Grosbein.Xr da 4 , 157*a6520796SGordon Bergling.Xr nda 4 1582b5691eeSEugene Grosbein.Sh HISTORY 1592b5691eeSEugene GrosbeinThe 1602b5691eeSEugene Grosbein.Nm 1612b5691eeSEugene Grosbeinutility first appeared in 1622b5691eeSEugene Grosbein.Fx 12.1 . 1632b5691eeSEugene Grosbein.Sh AUTHORS 1642b5691eeSEugene GrosbeinThe 1652b5691eeSEugene Grosbein.Nm 1662b5691eeSEugene Grosbeinutility was written by 1672b5691eeSEugene Grosbein.An Eugene Grosbein Aq Mt eugen@FreeBSD.org . 168