1FSTRIM(8)                    System Administration                   FSTRIM(8)
2
3
4

NAME

6       fstrim - discard unused blocks on a mounted filesystem
7

SYNOPSIS

9       fstrim [-a] [-o offset] [-l length] [-m minimum-size] [-v] mountpoint
10
11

DESCRIPTION

13       fstrim  is  used  on a mounted filesystem to discard (or "trim") blocks
14       which are not in use by the filesystem.  This is useful for solid-state
15       drives (SSDs) and thinly-provisioned storage.
16
17       By  default,  fstrim  will discard all unused blocks in the filesystem.
18       Options may be used to modify this behavior based on range or size,  as
19       explained below.
20
21       The  mountpoint  argument  is  the  pathname of the directory where the
22       filesystem is mounted.
23
24       Running fstrim frequently, or even using mount -o discard, might  nega‐
25       tively affect the lifetime of poor-quality SSD devices.  For most desk‐
26       top and server systems a sufficient trimming frequency is once a  week.
27       Note  that  not all devices support a queued trim, so each trim command
28       incurs a performance penalty on whatever else might be  trying  to  use
29       the disk at the time.
30
31

OPTIONS

33       The  offset,  length, and minimum-size arguments may be followed by the
34       multiplicative suffixes KiB (=1024), MiB (=1024*1024), and  so  on  for
35       GiB,  TiB,  PiB,  EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has
36       the same meaning as "KiB") or the suffixes KB (=1000), MB (=1000*1000),
37       and so on for GB, TB, PB, EB, ZB and YB.
38
39
40       -a, --all
41              Trim all mounted filesystems on devices that support the discard
42              operation.  The other supplied options, like --offset,  --length
43              and  --minimum,  are  applied to all these devices.  Errors from
44              filesystems that  do  not  support  the  discard  operation  are
45              silently ignored.
46
47       -o, --offset offset
48              Byte  offset in the filesystem from which to begin searching for
49              free blocks to discard.  The default value is zero, starting  at
50              the beginning of the filesystem.
51
52       -l, --length length
53              The  number  of  bytes  (after the starting point) to search for
54              free blocks to discard.  If the specified value extends past the
55              end  of  the filesystem, fstrim will stop at the filesystem size
56              boundary.  The default value extends to the end of the  filesys‐
57              tem.
58
59       -m, --minimum minimum-size
60              Minimum  contiguous free range to discard, in bytes. (This value
61              is internally rounded up to a multiple of the  filesystem  block
62              size.)   Free  ranges  smaller  than  this  will be ignored.  By
63              increasing this value, the fstrim operation will  complete  more
64              quickly   for   filesystems  with  badly  fragmented  freespace,
65              although not all blocks will be discarded.  The default value is
66              zero, discarding every free block.
67
68       -v, --verbose
69              Verbose execution.  With this option fstrim will output the num‐
70              ber of bytes passed from the filesystem down the block stack  to
71              the device for potential discard.  This number is a maximum dis‐
72              card amount  from  the  storage  device's  perspective,  because
73              FITRIM  ioctl called repeated will keep sending the same sectors
74              for discard repeatedly.
75
76              fstrim will report the same potential discard bytes  each  time,
77              but  only sectors which had been written to between the discards
78              would actually be discarded by the storage device.  Further, the
79              kernel  block  layer  reserves  the  right to adjust the discard
80              ranges to fit raid stripe geometry, non-trim capable devices  in
81              a  LVM  setup,  etc.  These reductions would not be reflected in
82              fstrim_range.len (the --length option).
83
84       -V, --version
85              Display version information and exit.
86
87       -h, --help
88              Display help text and exit.
89
90

RETURN CODES

92       0      success
93
94       1      failure
95
96       32     all failed
97
98       64     some filesystem discards have succeeded, some failed
99
100       The command fstrim --all returns 0 (all succeeded), 32 (all failed)  or
101       64 (some failed, some succeeded).
102
103

AUTHOR

105       Lukas Czerner <lczerner@redhat.com>
106       Karel Zak <kzak@redhat.com>
107

SEE ALSO

109       blkdiscard(8), mount(8)
110

AVAILABILITY

112       The  fstrim  command is part of the util-linux package and is available
113       from https://www.kernel.org/pub/linux/utils/util-linux/.
114
115
116
117util-linux                         July 2014                         FSTRIM(8)
Impressum