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

Chris Murphy lists at colorremedies.com
Sun Nov 23 23:23:01 UTC 2014


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).


-- 
Chris Murphy


More information about the test mailing list