Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
3  
Relatime is the default option in the kernel, not in Ubuntu itself. You'd have to modify the kernel or add options to /etc/fstab. –  arrange Aug 29 '11 at 20:15

1 Answer 1

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.

share|improve this answer
1  
Second @Bryce's solution -- this appears to be the only way to do it. Of course, that means rolling your own kernel updates with this patch -- how invasive that is is up to you :) –  izx Jul 5 '12 at 17:04
    
That's really invasive IMHO because it requires maintaining custom kernel builds and will result in a damn lot of headache with secure boot. Still, +1 because this is workable. –  Shnatsel Jul 5 '12 at 22:20
    
askubuntu.com/questions/61448/… suggests that udev rules can append mount parameters, maybe that will work? I'll update the body with this link now... –  Shnatsel Jul 5 '12 at 22:26
    
These are lines 2315+ in Linux 3.2, see lxr.free-electrons.com/source/fs/namespace.c?v=3.2#L2315 if (flags & MS_NOATIME) mnt_flags |= MNT_NOATIME; in line 2326 kinda bothers me, I guess I'll have to flip that too. Thanks for your help! –  Shnatsel Jul 10 '12 at 9:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.