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

NAME

6       fstrim - discard unused blocks on a mounted filesystem
7

SYNOPSIS

9       fstrim [-Aa] [-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, --fstab
41              Trim  all mounted filesystems mentioned in /etc/fstab on devices
42              that support the discard  operation.   The  root  filesystem  is
43              determined from kernel command line if missing in the file.  The
44              other supplied options, like --offset, --length  and  --minimum,
45              are  applied to all these devices.  Errors from filesystems that
46              do not support the  discard  operation,  read-only  devices  and
47              read-only filesystems are silently ignored.
48
49       -a, --all
50              Trim all mounted filesystems on devices that support the discard
51              operation.  The other supplied options, like --offset,  --length
52              and  --minimum,  are  applied to all these devices.  Errors from
53              filesystems that do not support the discard operation, read-only
54              devices and read-only filesystems are silently ignored.
55
56       -n, --dry-run
57              This  option  does  everything  apart  from actually call FITRIM
58              ioctl.
59
60       -o, --offset offset
61              Byte offset in the filesystem from which to begin searching  for
62              free  blocks to discard.  The default value is zero, starting at
63              the beginning of the filesystem.
64
65       -l, --length length
66              The number of bytes (after the starting  point)  to  search  for
67              free blocks to discard.  If the specified value extends past the
68              end of the filesystem, fstrim will stop at the  filesystem  size
69              boundary.   The default value extends to the end of the filesys‐
70              tem.
71
72       -I, --listed-in list
73              Specifies a colon-separated list of files  in  fstab  or  kernel
74              mountinfo  format.  All  missing  or  empty  files  are silently
75              ignored.  The evaluation of the list stops after first non-empty
76              file. For example: --listed-in /etc/fstab:/proc/self/mountinfo.
77
78       -m, --minimum minimum-size
79              Minimum  contiguous free range to discard, in bytes. (This value
80              is internally rounded up to a multiple of the  filesystem  block
81              size.)  Free ranges smaller than this will be ignored and fstrim
82              will adjust the minimum if it's smaller than the device's  mini‐
83              mum,  and  report  that (fstrim_range.minlen) back to userspace.
84              By increasing this value, the  fstrim  operation  will  complete
85              more  quickly  for  filesystems with badly fragmented freespace,
86              although not all blocks will be discarded.  The default value is
87              zero, discarding every free block.
88
89       -v, --verbose
90              Verbose execution.  With this option fstrim will output the num‐
91              ber of bytes passed from the filesystem down the block stack  to
92              the device for potential discard.  This number is a maximum dis‐
93              card amount  from  the  storage  device's  perspective,  because
94              FITRIM  ioctl called repeated will keep sending the same sectors
95              for discard repeatedly.
96
97              fstrim will report the same potential discard bytes  each  time,
98              but  only sectors which had been written to between the discards
99              would actually be discarded by the storage device.  Further, the
100              kernel  block  layer  reserves  the  right to adjust the discard
101              ranges to fit raid stripe geometry, non-trim capable devices  in
102              a  LVM  setup,  etc.  These reductions would not be reflected in
103              fstrim_range.len (the --length option).
104
105       --quiet-unsupported
106              Suppress error messages if  trim  operation  (ioctl)  is  unsup‐
107              ported.  This option is meant to be used in systemd service file
108              or in cron scripts to hide warnings that  are  result  of  known
109              problems, such as NTFS driver reporting Bad file descriptor when
110              device is mounted read-only, or lack of file system support  for
111              ioctl FITRIM call.
112
113       -V, --version
114              Display version information and exit.
115
116       -h, --help
117              Display help text and exit.
118
119

EXIT STATUS

121       0      success
122
123       1      failure
124
125       32     all failed
126
127       64     some filesystem discards have succeeded, some failed
128
129       The  command fstrim --all returns 0 (all succeeded), 32 (all failed) or
130       64 (some failed, some succeeded).
131
132

AUTHORS

134       Lukas Czerner <lczerner@redhat.com>
135       Karel Zak <kzak@redhat.com>
136

SEE ALSO

138       blkdiscard(8), mount(8)
139

AVAILABILITY

141       The fstrim command is part of the util-linux package and  is  available
142       from https://www.kernel.org/pub/linux/utils/util-linux/.
143
144
145
146util-linux                         May 2019                          FSTRIM(8)
Impressum