I also wanted to avoid this in my home router because of frequent power failures and the router being two floors bellow without a console.
What I've done (and I'm quite happy with this almost a year now) is mount some filesystems/directories with mfs (those where changes happen). Check mount_mfs(8) # df -h|grep mfs Filesystem Size Used Avail Capacity Mounted on mfs:23351 124M 4.0K 118M 1% /tmp mfs:42142 7.7M 1.0K 7.3M 1% /ramdisk mfs:40845 3.8M 112K 3.5M 4% /var/run mfs:72120 61.9M 1.7M 57.2M 3% /var/log You will most definitely need /var/run and /var/log there and probably /tmp too. I prepopulate /var/log on boot with -P from /mfs (which is on disk) and sync back regularly. I do it daily in order to not put strain on my eMMC. Worst case I will loose one day logs but I don't mind. # grep mfs /etc/fstab swap /tmp mfs rw,noatime,async,nodev,nosuid,-s=128m 0 0 swap /ramdisk mfs rw,noatime,async,nodev,nosuid,noexec,-s=8m 0 0 swap /var/run mfs rw,noatime,async,nodev,nosuid,noexec,-s=4m 0 0 swap /var/log mfs rw,noatime,async,nodev,nosuid,noexec,-s=64m,-P=/mfs/log 0 0 # crontab -l|grep sync 02 3 * * * /usr/local/sbin/sync-mfs @reboot /usr/local/sbin/sync-mfs # cat /usr/local/sbin/sync-mfs #!/bin/ksh sleep 300 /usr/local/bin/rsync -a /var/log/ /mfs/log/ /usr/local/bin/rsync -a /var/cron/ /mfs/cron/ G On 27/02/2026 16:07, Heinrich Rebehn wrote: > Or run OpenBSD readonly with /var on Ramdisk. > > >> On 23. Feb 2026, at 14:41, Otto Cooper <[email protected]> wrote: >> >> How about adding journaling to the file system? >> >> >> -------- Original Message -------- >> On Sunday, 02/22/26 at 22:13 Kenneth Gober <[email protected]> wrote: >> On Wed, Jul 24, 2024 at 1:52 PM <[email protected]> wrote: >> Thanks Stuart for all these thoughts. That's a lot of great ideas. >> >> Let me try to clarify a few things: >> >> - change `do_fsck` to `do_fsck -y` >> --------------------------------------------- >> I assume you mean Line 410. That seems like a great idea. >> Do I understand correctly that the normal behaviour for this `do_fsck` is >> to run the check, and mark filesystems dirty, and then enter single-user >> mode? >> Whereas if I replace it with `do_fsck -y `, the filesystems will not be >> marked dirty, and it will not enter singe user mode? >> >> Apologies for reviving this old thread, but I had a recent experience with a >> remote router that failed to come up, presumably after having local power >> issues. This router was set up to use fsck -p -y and I learned the hard way >> that when using -p, there are some problems that cause fsck to exit without >> giving you the option to answer yes. Instead, you just get "UNEXPECTED >> INCONSISTENCY; RUN fsck_ffs MANUALLY." followed a bit later by "Automatic >> file system check failed; help!". "do_fsck -y" will not help you here. >> >> Naturally, in this situation you should of course run fsck manually and >> decide what to do based on what fsck reports. Just blindly running fsck -y >> is dangerous and can make a simple issue much worse. But sometimes when a >> device is far away, you can't easily get there yourself, and you don't have >> someone on-site who can address it, an alternative is needed. >> >> Having chosen to accept this risk, I changed /etc/rc, modifying the do_fsck >> function as follows: >> old: fsck -p "$@" >> new: fsck -p "$@" || { for i in a d e f g h; do fsck -y \/dev\/sd0$i; done; >> fsck -p "$@"; } >> >> The idea is that if fsck -p fails, I run fsck -y for each file system where >> I think it's safe to do so unattended. Then I try the fsck -p command again >> to give it a second chance to succeed (if it fails twice then the old >> behavior remains). In this example, the file systems that I have chosen to >> auto-correct are sd0a, sd0d, sd0e, sd0f, sd0g and sd0h. You may choose to >> auto-correct a different set. >> >> I tested this by power-cycling a test router while reordering of libc was in >> progress. This would ordinarily have caused the router to come up >> single-user with the "Automatic file system check failed; help!" message, >> but with the above change the router was able to boot normally (albeit with >> a ton of console spam regarding repairs for files in the /usr/share/relink >> tree): >> >> root on sd0a (5e776adc85699112.a) swap on sd0b dump on sd0b >> WARNING: / was not properly unmounted >> Automatic boot in progress: starting file system checks. >> /dev/sd0a (5e776adc85699112.a): INCORRECT BLOCK COUNT I=32837 (4 should be >> 0) (CORRECTED) >> /dev/sd0a (5e776adc85699112.a): FREE BLK COUNT(S) WRONG IN SUPERBLK >> (SALVAGED) >> /dev/sd0a (5e776adc85699112.a): SUMMARY INFORMATION BAD (SALVAGED) >> /dev/sd0a (5e776adc85699112.a): BLK(S) MISSING IN BIT MAPS (SALVAGED) >> /dev/sd0a (5e776adc85699112.a): 1891 files, 49715 used, 202132 free (116 >> frags, 25252 blocks, 0.0% fragmentation) >> /dev/sd0a (5e776adc85699112.a): MARKING FILE SYSTEM CLEAN >> /dev/sd0d (5e776adc85699112.d): INCORRECT BLOCK COUNT I=54794 (704 should be >> 416) (CORRECTED) >> /dev/sd0d (5e776adc85699112.d): UNALLOCATED I=54976 OWNER=root MODE=100644 >> /dev/sd0d: SIZE=2096 MTIME=Feb 22 20:15 2026 >> FILE=/share/relink/_rebuild.GJZYRqDFYfz5/connect.so >> >> /dev/sd0d (5e776adc85699112.d): UNEXPECTED INCONSISTENCY; RUN fsck_ffs >> MANUALLY. >> /dev/sd0e (5e776adc85699112.e): 78 files, 1779 used, 252068 free (20 frags, >> 31506 blocks, 0.0% fragmentation) >> /dev/sd0e (5e776adc85699112.e): MARKING FILE SYSTEM CLEAN >> /dev/sd0f (5e776adc85699112.f): INCORRECT BLOCK COUNT I=49194 (128 should be >> 0) (CORRECTED) >> /dev/sd0f (5e776adc85699112.f): FREE BLK COUNT(S) WRONG IN SUPERBLK >> (SALVAGED) >> /dev/sd0f (5e776adc85699112.f): SUMMARY INFORMATION BAD (SALVAGED) >> /dev/sd0f (5e776adc85699112.f): BLK(S) MISSING IN BIT MAPS (SALVAGED) >> /dev/sd0f (5e776adc85699112.f): 423 files, 15221 used, 238626 free (90 >> frags, 29817 blocks, 0.0% fragmentation) >> /dev/sd0f (5e776adc85699112.f): MARKING FILE SYSTEM CLEAN >> /dev/sd0g (5e776adc85699112.g): INCORRECT BLOCK COUNT I=3 (4 should be 0) >> (CORRECTED) >> /dev/sd0g (5e776adc85699112.g): UNREF FILE I=3 OWNER=root MODE=100600 >> /dev/sd0g: SIZE=0 MTIME=Feb 22 20:15 2026 (CLEARED) >> /dev/sd0g (5e776adc85699112.g): 8 files, 6 used, 253841 free (33 frags, >> 31726 blocks, 0.0% fragmentation) >> /dev/sd0g (5e776adc85699112.g): MARKING FILE SYSTEM CLEAN >> /dev/sd0h (5e776adc85699112.h): 12 files, 11 used, 1520716 free (28 frags, >> 190086 blocks, 0.0% fragmentation) >> /dev/sd0h (5e776adc85699112.h): MARKING FILE SYSTEM CLEAN >> THE FOLLOWING FILE SYSTEM HAD AN UNEXPECTED INCONSISTENCY: >> ffs: 5e776adc85699112.d (/usr) >> ** /dev/rsd0a >> ** File system is clean; not checking >> ** /dev/rsd0d >> ** Last Mounted on /usr >> ** Phase 1 - Check Blocks and Sizes >> ** Phase 2 - Check Pathnames >> UNALLOCATED I=54976 OWNER=root MODE=100644 >> SIZE=2096 MTIME=Feb 22 20:15 2026 >> FILE=/share/relink/_rebuild.GJZYRqDFYfz5/connect.so >> >> REMOVE? yes >> >> UNALLOCATED I=54977 OWNER=root MODE=100644 >> SIZE=2080 MTIME=Feb 22 20:15 2026 >> FILE=/share/relink/_rebuild.GJZYRqDFYfz5/fcntl.so >> >> REMOVE? yes >> >> UNALLOCATED I=54978 OWNER=root MODE=100644 >> SIZE=2080 MTIME=Feb 22 20:15 2026 >> FILE=/share/relink/_rebuild.GJZYRqDFYfz5/fsync.so >> >> REMOVE? yes >> >> UNALLOCATED I=54979 OWNER=root MODE=100644 >> SIZE=2088 MTIME=Feb 22 20:15 2026 >> FILE=/share/relink/_rebuild.GJZYRqDFYfz5/msgrcv.so >> >> REMOVE? yes >> >> UNALLOCATED I=54980 OWNER=root MODE=100644 >> SIZE=2088 MTIME=Feb 22 20:15 2026 >> FILE=/share/relink/_rebuild.GJZYRqDFYfz5/msgsnd.so >> >> REMOVE? yes >> >> (many more lines of fsck output removed, until eventually fsck -p runs again) >> >> /dev/sd0a (5e776adc85699112.a): file system is clean; not checking >> /dev/sd0d (5e776adc85699112.d): file system is clean; not checking >> /dev/sd0e (5e776adc85699112.e): file system is clean; not checking >> /dev/sd0f (5e776adc85699112.f): file system is clean; not checking >> /dev/sd0g (5e776adc85699112.g): file system is clean; not checking >> /dev/sd0h (5e776adc85699112.h): file system is clean; not checking >> pf enabled >> starting network >> reordering: ld.so libc libcrypto sshd sshd-session sshd-auth ssh-agent. >> starting early daemons: syslogd pflogd ntpd. >> starting RPC daemons:. >> savecore: /dev/sd0b: Device not configured >> checking quotas: done. >> clearing /tmp >> kern.securelevel: 0 -> 1 >> creating runtime link editor directory cache. >> preserving editor files. >> starting network daemons: sshd smtpd sndiod. >> starting local daemons: cron. >> Sun Feb 22 15:16:34 EST 2026 >> >> OpenBSD/amd64 (apu2d4.utility.internal) (tty00) >> >> login:

