Mounting XFS with discard option only works for /boot but not /

John Tall mjtallx at gmail.com
Tue Nov 25 19:53:26 UTC 2014


On Mon, Nov 24, 2014 at 12:23 AM, Chris Murphy <lists at colorremedies.com> wrote:
> On Sun, Nov 23, 2014 at 3:06 PM, John Tall <mjtallx at gmail.com> wrote:
>
>>> See if this works while you're at it:
>>> # mount -o remount,discard /
>>>
>>> And then check mounts. It should now show discard is enabled.
>>
>> Unfortunately not, it does not show discard in /proc/mounts.
>
> Ed Greshko points to the cause for this, looks like discard can't be
> added with remount. So now I think I know what's going on:
>
> Systemd mounts the root device read only at /sysroot, and only then
> can it read fstab to know what the mount options are. It then remounts
> rw and includes the mount options in fstab. So any options that aren't
> supported by remount, won't work.
>
> What's odd is that I'm certain discard worked for root on Btrfs, so I
> wonder if this remount limitation is XFS only or if it applies to any
> filesystem? In which case, how is anyone getting trim to work on the
> root device?
>
> The only answer I'm thinking of is pretty obscure: use boot parameter
> rootflags=discard. The rootflags= parameter accepts mount options and
> applies them to the volume defined by root=. I only know this because
> Btrfs installs depend on rootflags=subvol=<rootname> to mount the
> correct subvolume containing root, and subvol=<name> is just a repeat
> of what's in fstab (typically).

It worked after adding rootflags=discard to /etc/default/grub and
running grub2-mkconfig.
Thanks for the help!

J


More information about the test mailing list