An irritation with Linux's 'mount -t nfs' output

May 6, 2009

The problem with 'mount -t nfs' is that it can't make up its mind about what NFS mount options it lists. Is its purpose to list all of the NFS mount options, or is its purpose to list only user-supplied ones? Right now the answer is some peculiar mixed blend; most of the time it lists only user-supplied options, but sometimes it will also list additional ones.

I care about this because I have programs that parse mount's output to see if we need to remount NFS filesystems to update their mount options. When mount -t nfs starts throwing in random additional options, the code explodes; it always thinks that the state is different and so always does remounts (which has various consequences).

I can deal with this in code, and have, but it's irritatingly inconsistent, especially because the list of sometimes-added mount options changes between different versions of mount. This is clearly going to make system upgrades somewhat more exciting in the future.

(And my code has to be somewhat complicated, because included in the extra options that mount can list are options that we sometimes set ourselves, so I can't just pretend that those mount options don't exist at all.)

Sidebar: what extra NFS mount options get added

The ones that I know of so far are:

  • addr=..., for the IP address of the NFS server; always added.
  • proto=udp, listed on Ubuntu 8.04 if the NFS server only supports NFS over UDP. (This doesn't happen on Ubuntu 6.06.)

Comments on this page:

From 82.239.74.21 at 2009-05-06 08:54:31:

Mhhh maybe use /proc/mounts instead ? There's a good chance it might be inconsistent too though, I guess :p

By cks at 2009-05-06 10:29:24:

/proc/mounts is consistent, but it has all of the options in effect for an NFS mount, including a lot of ones that you didn't explicitly supply and just took the defaults on. The theoretical advantage of 'mount -t nfs' is that you don't have to deal with all of those default options (and thus you don't need to know what the defaults are).

(We need to know the default values so that we can distinguish between 'took the default value' and 'previously specified a non-default value but now don't'; we want to leave the NFS mount alone in the first case but fix the options in the second.)

Written on 06 May 2009.
« How we periodically scrub our ZFS pools
How to set up your xorg.conf for RandR-based dual-headed systems »

Page tools: View Source, View Normal, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Wed May 6 01:39:14 2009
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.