"mount -a -o rdonly" doesn't work (very well)

Robert Watson rwatson at FreeBSD.org
Sat Nov 17 09:24:13 PST 2007


I noticed this morning while testing some buggy kernel code that a system 
tested in single-user mode was coming back up with an unclean root file 
system.  Turns out, I'd been running "mount -a -o rdonly" to mount /usr before 
running tests, and while /usr had come up read-only, the mount command had 
also remounted / as writable -- not my intended result!  I was wondering if 
someone familiar with the mount flags/etc could take a look at this.  Here's 
the output:

(boot single-user)

# mount
/dev/ad0s1a on / (ufs, local, read-only)
devfs on /dev (devfs, local)
# mount -a -o rdonly
# mount
/dev/ad0s1a on / (ufs, local, soft-updates)
devfs on /dev (devfs, local)
/dev/ad0s1e on /usr (ufs, local, read-only)
# mount -a -o rdonly
/dev/ad0s1a on / (ufs, loal, read-only, soft-updates)
devfs on /dev (devfs, local)
/dev/ad0s1e on /usr (ufs, local, read-only)

As you can see, a somewhat odd sequence, as first the read only flag is 
removed from /, and then re-added the second time.

Robert N M Watson
Computer Laboratory
University of Cambridge


More information about the freebsd-current mailing list