Skip to content

Fix rc.log missing shutdown messages in some cases#1009

Open
e-pirate wants to merge 1 commit into
OpenRC:masterfrom
e-pirate:master
Open

Fix rc.log missing shutdown messages in some cases#1009
e-pirate wants to merge 1 commit into
OpenRC:masterfrom
e-pirate:master

Conversation

@e-pirate
Copy link
Copy Markdown

@e-pirate e-pirate commented May 20, 2026

Fix rc.log missing shutdown messages if located on separate (non-root) file system by preventing localmount from unmouting corresponding file system to early thus keeping rc.log file writable. Second attempt. Tested on live Gentoo and Alpine systems including system boots in various configuration and rc_logger, rc_log_path values. Partially tested on FreeBSD and GhostBSD for comparability where possible.

Closes: #977

@N-R-K
Copy link
Copy Markdown
Contributor

N-R-K commented May 20, 2026

"This was tested [...] on a live Alpine to work as expected and tested on some *BSD systems"

Please add this information to the commit message as well.

…) file

system by preventing localmount from unmouting corresponding file system
to early thus keeping rc.log file writable. Second attempt. Tested on live
Gentoo and Alpine systems including system boots in various configuration
and rc_logger, rc_log_path values. Partially tested on FreeBSD and GhostBSD
for comparability where possible.

Closes: OpenRC#977
@e-pirate
Copy link
Copy Markdown
Author

Please add this information to the commit message as well.

Here we go.

Comment thread init.d/localmount.in
Comment on lines +76 to +78
if [ ! -f "${_log_file}" ]; then
touch "${_log_file}" || unset _log_file
fi
Copy link
Copy Markdown
Member

@navi-desu navi-desu May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we skip this whole block if the file doesn't exist? e.g.

if yesno ${rc_logger:-NO} || [ -f "${_log_file=:${rc_log_path:-/var/log/rc.log}}" ]
	local rc_log_mntpnt="$(df ${_log_file} 2>/dev/null | awk 'NR==2 { print $6 }')"
	if [ "$rc_log_mntpnt" != '/' ]; then
		no_umounts_r="$no_umounts_r|${rc_log_mntpnt}"
	fi
fi

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, touching is needed for the df to work correctly. The highlighted block addresses the "corner" case when user enables logging for the first time and the log file is missing. df will not work for the missing file therefore all messages during shutdown process will be lost, to circumvent this rare case I introduced the touch and an extra safety unset measure. On the next boot log file will be created and everything will start to work as expected. This covers all cases when log file is missing. Block removal will make user lose shutdown messages from current "session". I found this during live tests (as mentioned before). Originally I had something as suggested, but I believe this is pretty important to support such condition, especially the solution is pretty easy and short.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did my home work very well as I understand the responsibility if this PR is accepted and rolls out to all Gentoo and Alpine systems :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i forgot live logs go to tmpfs before going to the log file dir (and i have no idea why we do that, concurrent openrc.1 instances isn't really a thing we support)

hmm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

localmount unmount /var/log on shutdown preventing rc_logger from saving messages and throwing "Unable to.." errors

3 participants