Bug 278993 - fsck not checking disk if sysctl kern.boottrace.enabled=1 is set
Summary: fsck not checking disk if sysctl kern.boottrace.enabled=1 is set
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: 14.0-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-15 05:58 UTC by Oleksii Samorukov
Modified: 2024-05-29 03:04 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oleksii Samorukov freebsd_committer freebsd_triage 2024-05-15 05:58:52 UTC
Recently I found that some of my VPS-s fsck is not running (what is causing failed mount root in case of hard reset). 

After troubleshooting, I was able to find a root cause - it was kern.boottrace.enabled=1 in the /boot/loader.conf. This is caused by missing "$autoboot" variable in the /etc/rc.d/fsck when that script is running, so it does not run correctly. 

To reproduce on the clean system:

1. Add kern.boottrace.enabled=1 to the /boot/loader.conf
2. Add background_fsck="NO" to the /etc/rc.conf
3. Reset system and check logs. Fsck will not be started.
Comment 1 Oleksii Samorukov freebsd_committer freebsd_triage 2024-05-15 06:05:35 UTC
Okay, so the problem is that "$autoboot" is used by the fsck script but not exported, so when the boot trace is running, the script does not work. Without a backtrace, export is not needed as the script is sourced.
Comment 2 Oleksii Samorukov freebsd_committer freebsd_triage 2024-05-15 06:18:23 UTC
P.S. Looks like fsck is only rc.d script depending on $autoboot. Not sure if its better to export it or change fsck to no use it...
Comment 3 Oleksii Samorukov freebsd_committer freebsd_triage 2024-05-28 14:53:31 UTC
Proposed fix is at https://github.com/freebsd/freebsd-src/pull/1261
Comment 4 Warner Losh freebsd_committer freebsd_triage 2024-05-29 03:04:17 UTC
So part of the problem is that the boottrace stuff doesn't export any of the variables.  What about _boot or rc_fast? It looks like rc_fast is reconstructed whenver _boot is fast* in rc.subr and only set when _boot has been set to 'faststart'.

The fix is a bit of a hack.