How do I make noatime mounts default?
I'm making an Ubuntu derivative, and I want to make noatime the default mount option for all filesystems (instead of relatime which is default in Ubuntu).
There seems to be a boolean default_relatime
kernel parameter for switching between defaulting to atime or relatime (also available by writing to /proc/sys/kernel/default_relatime), but I can't find an equivalent for noatime and I don't know how to enable that in a distro by default.
How to configure to record data to pendrive instantly? suggests that there's a way to add noatime mount parameter via udev, but I have no idea if that will work for internal media and how to do it.
What's the least invasive way to make the kernel default to noatime?
Current default can be viewed using "cat /proc/mounts" because it shows even implicit mount parameters; don't trust "mount".
Yes, I've read Is it worth to tune Ext4 with noatime? and I still want to do it.
The kernel used to have a config option for whether to use ATIME or RELATIME; dunno if that also included some option for NOATIME. In any case, that's gone now.
I studied util-linux as well, to see if the mount command had configurable defaults or could be modified, but it did not appear to be the case.
However, it looks like you can patch the kernel to change the default behavior. Modify ./fs/namespace.c, around lines 2334:
long do_mount(...)
...
/* Default to relatime unless overriden */
if (!(flags & MS_NOATIME))
mnt_flags |= MNT_RELATIME;
...
Swap that around:
long do_mount(...)
...
/* Default to noatime unless overriden */
if (!(flags & MS_RELATIME))
mnt_flags |= MNT_NOATIME;
...
And that should do it.