]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fstrim: Add fstab option X-fstrim.notrim
authorStanislav Brabec <sbrabec@suse.cz>
Mon, 31 Jan 2022 09:53:20 +0000 (10:53 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 31 Jan 2022 09:53:20 +0000 (10:53 +0100)
Sometimes it makes sense to skip fstrim for selected file mounts, but
still be able to use fstrim.service.

Add a possibility to specify "X-fstrim.notrim" in fstab.

Do not use "notrim", as it collides with the kernel rbd driver.

[kzak@redhat.com: - rename x-fstrim to X-fstrim]

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/fstrim.8.adoc
sys-utils/fstrim.c

index b2c1fce2270355a9e8acb90da238f2b28385d2f2..004eb0bdaac372b1bdacb3e3baf4abcc1a4c31ad 100644 (file)
@@ -29,7 +29,7 @@ Running *fstrim* frequently, or even using *mount -o discard*, might negatively
 The _offset_, _length_, and _minimum-size_ 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.
 
 *-A, --fstab*::
-Trim all mounted filesystems mentioned in _/etc/fstab_ 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 *--offset*, *--length* and *--minimum*, are applied to all these devices. Errors from filesystems that do not support the discard operation, read-only devices, autofs and read-only filesystems are silently ignored.
+Trim all mounted filesystems mentioned in _/etc/fstab_ 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 *--offset*, *--length* and *--minimum*, are applied to all these devices. Errors from filesystems that do not support the discard operation, read-only devices, autofs and read-only filesystems are silently ignored. Filesystems with "X-fstrim.notrim" mount option are skipped.
 
 *-a, --all*::
 Trim all mounted filesystems on devices that support the discard operation. The other supplied options, like *--offset*, *--length* and *--minimum*, 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.
index 88397f0ec38d7da7a9c182902fcce8e379921e85..0d6cabeb96ba9d6f6dc854423a4c5d9564e9bed5 100644 (file)
@@ -224,6 +224,8 @@ static int is_unwanted_fs(struct libmnt_fs *fs, const char *tgt)
                return 1;
        if (mnt_fs_match_options(fs, "ro"))
                return 1;
+       if (mnt_fs_match_options(fs, "+X-fstrim.notrim"))
+               return 1;
 
        fd = open(tgt, O_PATH);
        if (fd < 0)