1*2b5691eeSEugene Grosbein.\" 2*2b5691eeSEugene Grosbein.\" Copyright (c) 2019 Eugene Grosbein <eugen@FreeBSD.org>. 3*2b5691eeSEugene Grosbein.\" All rights reserved. 4*2b5691eeSEugene Grosbein.\" 5*2b5691eeSEugene Grosbein.\" Redistribution and use in source and binary forms, with or without 6*2b5691eeSEugene Grosbein.\" modification, are permitted provided that the following conditions 7*2b5691eeSEugene Grosbein.\" are met: 8*2b5691eeSEugene Grosbein.\" 1. Redistributions of source code must retain the above copyright 9*2b5691eeSEugene Grosbein.\" notice, this list of conditions and the following disclaimer. 10*2b5691eeSEugene Grosbein.\" 2. Redistributions in binary form must reproduce the above copyright 11*2b5691eeSEugene Grosbein.\" notice, this list of conditions and the following disclaimer in the 12*2b5691eeSEugene Grosbein.\" documentation and/or other materials provided with the distribution. 13*2b5691eeSEugene Grosbein.\" 14*2b5691eeSEugene Grosbein.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15*2b5691eeSEugene Grosbein.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*2b5691eeSEugene Grosbein.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*2b5691eeSEugene Grosbein.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18*2b5691eeSEugene Grosbein.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19*2b5691eeSEugene Grosbein.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20*2b5691eeSEugene Grosbein.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21*2b5691eeSEugene Grosbein.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22*2b5691eeSEugene Grosbein.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23*2b5691eeSEugene Grosbein.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24*2b5691eeSEugene Grosbein.\" SUCH DAMAGE. 25*2b5691eeSEugene Grosbein.\" 26*2b5691eeSEugene Grosbein.\" $FreeBSD$ 27*2b5691eeSEugene Grosbein.\" 28*2b5691eeSEugene Grosbein.Dd January 18, 2019 29*2b5691eeSEugene Grosbein.Dt TRIM 8 30*2b5691eeSEugene Grosbein.Os 31*2b5691eeSEugene Grosbein.Sh NAME 32*2b5691eeSEugene Grosbein.Nm trim 33*2b5691eeSEugene Grosbein.Nd erase device blocks that have no needed contents 34*2b5691eeSEugene Grosbein.Sh SYNOPSIS 35*2b5691eeSEugene Grosbein.Nm 36*2b5691eeSEugene Grosbein.Op Fl Nfqv 37*2b5691eeSEugene Grosbein.Fl [ [lo] Xo 38*2b5691eeSEugene Grosbein.Bk -words 39*2b5691eeSEugene Grosbein.Sm off 40*2b5691eeSEugene Grosbein.Ar offset 41*2b5691eeSEugene Grosbein.Op Cm K | k | M | m | G | g | T | t ] 42*2b5691eeSEugene Grosbein.Sm on 43*2b5691eeSEugene Grosbein.Xc 44*2b5691eeSEugene Grosbein.Ek 45*2b5691eeSEugene Grosbein.Bk -words 46*2b5691eeSEugene Grosbein.Op Fl r Ar rfile 47*2b5691eeSEugene Grosbein.Ek 48*2b5691eeSEugene Grosbein.Ar device ... 49*2b5691eeSEugene Grosbein.Sh DESCRIPTION 50*2b5691eeSEugene GrosbeinThe 51*2b5691eeSEugene Grosbein.Nm 52*2b5691eeSEugene Grosbeinutility erases specified region of the device. 53*2b5691eeSEugene GrosbeinIt is mostly relevant for storage that implement trim (like flash based, 54*2b5691eeSEugene Grosbeinor thinly provisioned storage). 55*2b5691eeSEugene Grosbein.Sy All erased data is lost. 56*2b5691eeSEugene Grosbein.Pp 57*2b5691eeSEugene GrosbeinThe following options are available: 58*2b5691eeSEugene Grosbein.Bl -tag -width indent 59*2b5691eeSEugene Grosbein.It Fl N 60*2b5691eeSEugene GrosbeinDo not actually erase anything but show what it would do (dry run). 61*2b5691eeSEugene GrosbeinImplies 62*2b5691eeSEugene Grosbein.Fl v . 63*2b5691eeSEugene GrosbeinThis is the default. Overrides 64*2b5691eeSEugene Grosbein.Fl f . 65*2b5691eeSEugene Grosbein.It Fl f 66*2b5691eeSEugene GrosbeinPerform the operation. Overrides 67*2b5691eeSEugene Grosbein.Fl N . 68*2b5691eeSEugene Grosbein.It Fl l Xo 69*2b5691eeSEugene Grosbein.Sm off 70*2b5691eeSEugene Grosbein.Ar offset 71*2b5691eeSEugene Grosbein.Op Cm K | k | M | m | G | g | T | t 72*2b5691eeSEugene Grosbein.Sm on 73*2b5691eeSEugene Grosbein.Xc 74*2b5691eeSEugene Grosbein.It Fl o Xo 75*2b5691eeSEugene Grosbein.Sm off 76*2b5691eeSEugene Grosbein.Ar offset 77*2b5691eeSEugene Grosbein.Op Cm K | k | M | m | G | g | T | t 78*2b5691eeSEugene Grosbein.Sm on 79*2b5691eeSEugene Grosbein.Xc 80*2b5691eeSEugene GrosbeinSpecify the length 81*2b5691eeSEugene Grosbein.Fl l 82*2b5691eeSEugene Grosbeinof the region to trim or its offset 83*2b5691eeSEugene Grosbein.Fl o 84*2b5691eeSEugene Grosbeinfrom the beginning of the device. 85*2b5691eeSEugene Grosbein.Sy The whole device is erased by default 86*2b5691eeSEugene Grosbeinunless one or both of these options are presented. 87*2b5691eeSEugene Grosbein.Pp 88*2b5691eeSEugene GrosbeinThe argument may be suffixed with one of 89*2b5691eeSEugene Grosbein.Cm K , 90*2b5691eeSEugene Grosbein.Cm M , 91*2b5691eeSEugene Grosbein.Cm G 92*2b5691eeSEugene Grosbeinor 93*2b5691eeSEugene Grosbein.Cm T 94*2b5691eeSEugene Grosbein(either upper or lower case) to indicate a multiple of 95*2b5691eeSEugene GrosbeinKilobytes, Megabytes, Gigabytes or Terabytes 96*2b5691eeSEugene Grosbeinrespectively. 97*2b5691eeSEugene Grosbein.It Fl q 98*2b5691eeSEugene GrosbeinDo not output anything except of possible error messages (quiet mode). 99*2b5691eeSEugene GrosbeinOverrides 100*2b5691eeSEugene Grosbein.Fl v . 101*2b5691eeSEugene Grosbein.It Fl r Ar rfile 102*2b5691eeSEugene GrosbeinUses the length of given 103*2b5691eeSEugene Grosbein.Ar rfile 104*2b5691eeSEugene Grosbeinas length of the region to erase. 105*2b5691eeSEugene Grosbein.Sy The whole device is erased by default. 106*2b5691eeSEugene Grosbein.It Fl v 107*2b5691eeSEugene GrosbeinShow offset and length of actual region being erased, in bytes. 108*2b5691eeSEugene Grosbein.El 109*2b5691eeSEugene Grosbein.Pp 110*2b5691eeSEugene GrosbeinLater options override previous ones. 111*2b5691eeSEugene Grosbein.Pp 112*2b5691eeSEugene GrosbeinNote that actual success of the operation depends of underlying 113*2b5691eeSEugene Grosbeindevice driver such as 114*2b5691eeSEugene Grosbein.Xr ada 4 , 115*2b5691eeSEugene Grosbein.Xr da 4 116*2b5691eeSEugene Grosbeinand others. 117*2b5691eeSEugene GrosbeinRefer to corresponding manual pages for detail on possible caveats 118*2b5691eeSEugene Grosbeinin low level support for ATA TRIM or SCSI UNMAP commands. 119*2b5691eeSEugene Grosbein.Sh EXIT STATUS 120*2b5691eeSEugene Grosbein.Ex -std 121*2b5691eeSEugene GrosbeinIf the final erase operation fails for an argument, the 122*2b5691eeSEugene Grosbein.Nm 123*2b5691eeSEugene Grosbeinutility returns exit code 1. 124*2b5691eeSEugene GrosbeinIt can also return one of the exit codes defined in 125*2b5691eeSEugene Grosbein.Xr sysexits 3 , 126*2b5691eeSEugene Grosbeinas follows: 127*2b5691eeSEugene Grosbein.Bl -tag -width ".Dv EX_UNAVAILABLE" 128*2b5691eeSEugene Grosbein.It Dv EX_USAGE 129*2b5691eeSEugene GrosbeinThe specified offset or length of the region is incorrect. 130*2b5691eeSEugene Grosbein.It Dv EX_OSERR 131*2b5691eeSEugene GrosbeinThere is no enough memory to proceed. 132*2b5691eeSEugene Grosbein.It Dv EX_NOINPUT 133*2b5691eeSEugene GrosbeinThe specified 134*2b5691eeSEugene Grosbein.Ar rfile 135*2b5691eeSEugene Grosbeincannot be opened (perhaps, it does not exist). 136*2b5691eeSEugene Grosbein.It Dv EX_IOERR 137*2b5691eeSEugene GrosbeinThe specified 138*2b5691eeSEugene Grosbein.Ar rfile 139*2b5691eeSEugene Grosbeincannot be examined for its size due to some system input/output error. 140*2b5691eeSEugene Grosbein.It Dv EX_DATAERR 141*2b5691eeSEugene GrosbeinThe specified 142*2b5691eeSEugene Grosbein.Ar rfile 143*2b5691eeSEugene Grosbeinis not regular file, directory nor special device, so its size 144*2b5691eeSEugene Grosbeincannot be examined. 145*2b5691eeSEugene Grosbein.It Dv EX_UNAVAILABLE 146*2b5691eeSEugene GrosbeinThe specified 147*2b5691eeSEugene Grosbein.Ar rfile 148*2b5691eeSEugene Grosbeinis special device file not supporting DIOCGMEDIASIZE 149*2b5691eeSEugene Grosbein.Xr ioctl 2 150*2b5691eeSEugene Grosbein(probably not a disk), so its size cannot be examined. 151*2b5691eeSEugene Grosbein.El 152*2b5691eeSEugene Grosbein.Sh SEE ALSO 153*2b5691eeSEugene Grosbein.Xr ada 4 , 154*2b5691eeSEugene Grosbein.Xr da 4 , 155*2b5691eeSEugene Grosbein.Xr ioctl 2 , 156*2b5691eeSEugene Grosbein.Xr nda 4 , 157*2b5691eeSEugene Grosbein.Xr sysexits 3 158*2b5691eeSEugene Grosbein.Sh HISTORY 159*2b5691eeSEugene GrosbeinThe 160*2b5691eeSEugene Grosbein.Nm 161*2b5691eeSEugene Grosbeinutility first appeared in 162*2b5691eeSEugene Grosbein.Fx 12.1 . 163*2b5691eeSEugene Grosbein.Sh AUTHORS 164*2b5691eeSEugene GrosbeinThe 165*2b5691eeSEugene Grosbein.Nm 166*2b5691eeSEugene Grosbeinutility was written by 167*2b5691eeSEugene Grosbein.An Eugene Grosbein Aq Mt eugen@FreeBSD.org . 168