222 lines
6.7 KiB
HTML
222 lines
6.7 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of FSTRIM</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>FSTRIM</H1>
|
|
Section: System Administration (8)<BR>Updated: May 2019<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
fstrim - discard unused blocks on a mounted filesystem
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>fstrim</B>
|
|
|
|
[<B>-Aa</B>]
|
|
|
|
[<B>-o</B>
|
|
|
|
<I>offset</I>]
|
|
|
|
[<B>-l</B>
|
|
|
|
<I>length</I>]
|
|
|
|
[<B>-m</B>
|
|
|
|
<I>minimum-size</I>]
|
|
|
|
[<B>-v</B>]
|
|
|
|
<I>mountpoint</I>
|
|
|
|
<P>
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<B>fstrim</B>
|
|
|
|
is used on a mounted filesystem to discard (or "trim") blocks which are not in
|
|
use by the filesystem. This is useful for solid-state drives (SSDs) and
|
|
thinly-provisioned storage.
|
|
<P>
|
|
|
|
By default,
|
|
<B>fstrim</B>
|
|
|
|
will discard all unused blocks in the filesystem. Options may be used to
|
|
modify this behavior based on range or size, as explained below.
|
|
<P>
|
|
|
|
The
|
|
<I>mountpoint</I>
|
|
|
|
argument is the pathname of the directory where the filesystem
|
|
is mounted.
|
|
<P>
|
|
|
|
Running
|
|
<B>fstrim</B>
|
|
|
|
frequently, or even using
|
|
<B>mount -o discard</B>,
|
|
|
|
might negatively affect the lifetime of poor-quality SSD devices. For most
|
|
desktop and server systems a sufficient trimming frequency is once a week.
|
|
Note that not all
|
|
devices support a queued trim, so each trim command incurs a performance penalty
|
|
on whatever else might be trying to use the disk at the time.
|
|
<P>
|
|
<A NAME="lbAE"> </A>
|
|
<H2>OPTIONS</H2>
|
|
|
|
The <I>offset</I>, <I>length</I>, and <I>minimum-size</I> arguments may be
|
|
followed by the multiplicative suffixes KiB (=1024),
|
|
MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB"
|
|
is optional, e.g., "K" has the same meaning as "KiB") or the suffixes
|
|
KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.
|
|
<P>
|
|
<DL COMPACT>
|
|
<DT id="1"><B>-A, --fstab</B><DD>
|
|
Trim all mounted filesystems mentioned in <I>/etc/fstab</I> on devices that support the
|
|
discard operation. The root filesystem is determined from kernel command line if missing
|
|
in the file.
|
|
The other supplied options, like <B>--offset</B>, <B>--length</B> and
|
|
<B>--minimum</B>, are applied to all these devices.
|
|
Errors from filesystems that do not support the discard operation,
|
|
read-only devices and read-only filesystems are silently ignored.
|
|
<DT id="2"><B>-a, --all</B><DD>
|
|
Trim all mounted filesystems on devices that support the discard operation.
|
|
The other supplied options, like <B>--offset</B>, <B>--length</B> and
|
|
<B>--minimum</B>, are applied to all these devices.
|
|
Errors from filesystems that do not support the discard operation,
|
|
read-only devices and read-only filesystems are silently ignored.
|
|
<DT id="3"><B>-n, --dry-run</B><DD>
|
|
This option does everything apart from actually call FITRIM ioctl.
|
|
<DT id="4"><B>-o, --offset</B> <I>offset</I><DD>
|
|
Byte offset in the filesystem from which to begin searching for free blocks
|
|
to discard. The default value is zero, starting at the beginning of the
|
|
filesystem.
|
|
<DT id="5"><B>-l, --length</B> <I>length</I><DD>
|
|
The number of bytes (after the starting point) to search for free blocks
|
|
to discard. If the specified value extends past the end of the filesystem,
|
|
<B>fstrim</B>
|
|
|
|
will stop at the filesystem size boundary. The default value extends to
|
|
the end of the filesystem.
|
|
<DT id="6"><B>-m, --minimum</B> <I>minimum-size</I><DD>
|
|
Minimum contiguous free range to discard, in bytes. (This value is internally
|
|
rounded up to a multiple of the filesystem block size.) Free ranges smaller
|
|
than this will be ignored and fstrim will adjust the minimum if it's smaller than
|
|
the device's minimum, and report that (fstrim_range.minlen) back to userspace.
|
|
By increasing this value, the fstrim operation will complete more quickly for
|
|
filesystems with badly fragmented freespace, although not all blocks will be
|
|
discarded. The default value is zero, discarding every free block.
|
|
<DT id="7"><B>-v, --verbose</B><DD>
|
|
Verbose execution. With this option
|
|
<B>fstrim</B>
|
|
|
|
will output the number of bytes passed from the filesystem
|
|
down the block stack to the device for potential discard. This number is a
|
|
maximum discard amount from the storage device's perspective, because
|
|
<I>FITRIM</I>
|
|
|
|
ioctl called repeated will keep sending the same sectors for discard repeatedly.
|
|
<P>
|
|
<B>fstrim</B>
|
|
|
|
will report the same potential discard bytes each time, but only sectors which
|
|
had been written to between the discards would actually be discarded by the
|
|
storage device. Further, the kernel block layer reserves the right to adjust
|
|
the discard ranges to fit raid stripe geometry, non-trim capable devices in a
|
|
LVM setup, etc. These reductions would not be reflected in fstrim_range.len
|
|
(the
|
|
<B>--length</B>
|
|
|
|
option).
|
|
<DT id="8"><B>--quiet</B>
|
|
|
|
<DD>
|
|
Suppress error messages. This option is meant to be used in systemd service
|
|
file or in cron scripts to hide warnings that are result of known problems,
|
|
such as NTFS driver
|
|
reporting
|
|
<I>Bad file descriptor</I>
|
|
|
|
when device is mounted read-only, or lack of file system support for ioctl
|
|
FITRIM call.
|
|
<DT id="9"><B>-V</B>,<B> --version</B>
|
|
|
|
<DD>
|
|
Display version information and exit.
|
|
<DT id="10"><B>-h</B>,<B> --help</B>
|
|
|
|
<DD>
|
|
Display help text and exit.
|
|
<P>
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>RETURN CODES</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="11">0<DD>
|
|
success
|
|
<DT id="12">1<DD>
|
|
failure
|
|
<DT id="13">32<DD>
|
|
all failed
|
|
<DT id="14">64<DD>
|
|
some filesystem discards have succeeded, some failed
|
|
</DL>
|
|
<P>
|
|
|
|
The command
|
|
<B>fstrim --all</B>
|
|
|
|
returns 0 (all succeeded), 32 (all failed) or 64 (some failed, some succeeded).
|
|
<P>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
<PRE>
|
|
Lukas Czerner <<A HREF="mailto:lczerner@redhat.com">lczerner@redhat.com</A>>
|
|
Karel Zak <<A HREF="mailto:kzak@redhat.com">kzak@redhat.com</A>>
|
|
</PRE>
|
|
|
|
<A NAME="lbAH"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?8+blkdiscard">blkdiscard</A></B>(8),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?8+mount">mount</A></B>(8)
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H2>AVAILABILITY</H2>
|
|
|
|
The fstrim command is part of the util-linux package and is available from
|
|
<A HREF="https://www.kernel.org/pub/linux/utils/util-linux/.">https://www.kernel.org/pub/linux/utils/util-linux/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="15"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="16"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="17"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="18"><A HREF="#lbAE">OPTIONS</A><DD>
|
|
<DT id="19"><A HREF="#lbAF">RETURN CODES</A><DD>
|
|
<DT id="20"><A HREF="#lbAG">AUTHOR</A><DD>
|
|
<DT id="21"><A HREF="#lbAH">SEE ALSO</A><DD>
|
|
<DT id="22"><A HREF="#lbAI">AVAILABILITY</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:12 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|