Bug 2401 - Workaround/ Mounting RO after mounting RW can be very slow on nanoBSD
-
Posting this separately so it's easier to find…
Description:
https://redmine.pfsense.org/issues/2401
Mounting read-only after mounting read-write can be very slow on NanoBSD
/sbin/mount -u -r -f -o sync,noatime /
takes ages to finish, thus any changes in the web interfaces take a lot of time when one clicks 'save'.
Remounting /cf doesn't seem to cause any problems.I have tried killing almost all processes, yet there was no change in behavior. Even when I remounted / RW and RO back to back with no delay, it stalled at the remount RO.
Workaround (not a fix!):
in /etc/inc/config.lib.inc line 361 replace
mwexec("/sbin/mount -u -r -f -o sync,noatime /");
with
mwexec("/sbin/mount -u -w -f -o async,noatime / && /sbin/mount -u -r -f -o async,noatime / && /sbin/mount -u -r -f -o sync,noatime /");
Possible problems
Note the async option.
This may lead to loss of data, actually, but hasn't caused any problems for me so far.
Time for remount RO has dropped on my Alix Board from ~ 70 seconds to ~7 seconds. -
async is scary dangerous. Try pulling the plug on your ALIX at random times with async or sync. See what happens.
From mount(8):
async All I/O to the file system should be done asynchronously.
This is a dangerous flag to set, since it does not guar-
antee that the file system structure on the disk will
remain consistent. For this reason, the async flag
should be used sparingly, and only when some data recov-
ery mechanism is present. -
I know it's dangerous, yet I'm only enabling async for a very short period of time while re-enabling the RO mode and I disable it right after (check the code, it's RW+sync to RW+async -> RO+async -> RO+sync). It doesn't stay in async mode.
Chances of messing up the filesystem should be very slim since I would have to pull the plug during those <10 seconds for that to happen.
I hope I got this right. -
I would very much like to this guy I met, he's called murphy. You'll love him, he has a great sense of humor.