Subject: understanding mount -u and read-only
To: None <netbsd-users@netbsd.org>
From: Ian D. Leroux <ian_leroux@fastmail.fm>
List: netbsd-users
Date: 02/12/2005 18:38:55
Item the first:
It would seem that the atime of files gets updated even on file-systems
mounted read-only. This clashes with my idea of "read-only" a bit.
Example:
$ mount | grep /usr
/dev/wd1e on /usr type ffs (read-only, local)
$ ls -l -u /usr
total 40
drwxr-xr-x 8 root wheel - 512 Feb 12 14:30 X11R6/
drwxr-xr-x 2 root wheel - 6656 Feb 12 14:30 bin/
drwxr-xr-x 3 root wheel - 512 Feb 12 14:30 games/
# ... other lines elided
$ ls /usr/X11R6/ >/dev/null
$ ls -l -u /usr
total 40
drwxr-xr-x 8 root wheel - 512 Feb 12 18:08 X11R6/
drwxr-xr-x 2 root wheel - 6656 Feb 12 14:30 bin/
drwxr-xr-x 3 root wheel - 512 Feb 12 14:30 games/
# ...
Instance the second:
mount -u remounts partitions read-write unless an -r flag is explicitly
specified. From the relevant section of man mount (quoted below), I'd
assumed that it would either honour the setting of ro/rw in fstab or
leave the existing state unchanged. The relevance of this is that you
can't use "mount -u /mountpoint" in a script to restore a partition to
its default options.
-u The -u flag indicates that the status of an already mounted file
system should be changed. Any of the options discussed above
(the -o option) may be changed; also a file system can be changed
from read-only to read-write or vice versa. An attempt to change
from read-write to read-only will fail if any files on the
filesystem are currently open for writing unless the -f flag is
also specified. The set of options is determined by first
extracting the options for the file system from the fstab(5)
file, then applying any options specified by the -o argument, and
finally applying the -r or -w option.
Example:
$ grep " /usr" /etc/fstab
/dev/wd1e /usr ffs ro,nodev 1 2
$ mount |grep /usr
/dev/wd1e on /usr type ffs (read-only, local)
$ sudo mount -u /usr
$ mount |grep /usr
/dev/wd1e on /usr type ffs (local)
So: sw-bug, doc-bug, configuration problem on my machine or wetware bug
on my part?
As to why I care: I'm trying to backup data (using rsync) to another
system without modifying the atimes on the source disk (and yes I
do know about dump, I'm just looking at other options). I keep
/usr mounted read-only. I ran into the first behaviour when I
assumed that I could just copy it without worrying about the atimes
(it being read-only), and discovered the second while trying to
automate remounting partitions noatime during the backup.
Cheers,
Ian Leroux