Skip to content

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

Open

Description

@e-pirate

Hi everyone.
This is a fallow up bug report after a small investigation described on Gentoo forums here.

Long story short: recently I found that there is no shutdown messages in /var/log/rc.log anymore. After some digging I found, that localmount now unmount /var on reboot making /var/log/* inaccessible and therefore preventing rc_logger from saving messages also throwing "Unable to.." red asterisk errors to console.

Temporary moving/redirecting rc.log to /opt directory solved the problem: I see full shutdown logs and no "Unable to" errors during shutdown process.

I have /var as a separate partition on this particular system since 2009 AFAIR (this, a believe, very common case for production systems that may have unpredictable log and data grows that could potentially break the system if located on root partition) and previously had no this issue. I remember to have full shutdown logs having "Stopping.." messages down to udev on this system with /var mounted as separate partition. Unfortunately, I have no evidence because this was perfectly-working and therefore abandoned system until month ago when I upgraded it to a newer platform and had a closer look at what is going on. All logs are rotated and gone, so I have no exact date when things changed.

I believe we should add /var/log to no_umounts_r variable and have it be RW accessible till the very end just as we have root.

Activity

  1. navi-desu commented on Feb 13, 2026

    @navi-desu
    Member

    more specifically, we probably should add $rc_log_path to no_umounts_r, similar to how we do $rc_svcdir

    the mount code got refactored recently to unmount in parallel, but that part wasn't touched, so if this is a regression, seems to be an ooold one

    will send a fix later today

  2. e-pirate commented on Feb 14, 2026

    @e-pirate
    Author

    more specifically, we probably should add $rc_log_path to no_umounts_r, similar to how we do $rc_svcdir

    Even better idea as it could be that rc.log is the only log to be accessible for write in /var/log because all other processes should be already stopped and most likely /var can be unmounted safely.

    the mount code got refactored recently to unmount in parallel, but that part wasn't touched, so if this is a regression, seems to be an ooold one

    Definitely is. The system that I noticed this was set (including separate /var) in 2009 or something like this. It was Core Duo 2Gb RAM fanless headless machine serving my apt. infra. Some 7-8 year ago I moved to g.f. and abandoned the thing. Just let it run as it is. But I remember to investigate random reboots and I bet my bottom dollar, I've seen all the shutdown sequence in rc.log and this is how I figured out that reboots were power (most likely) or hardware related - there were no shutdown messages after previous reboot with shutdown messages present in rc.log. The kernel version was 4.19 and it was Gentoo's stable at the moment which gives us late 2018 when the system was updated last time that kind of corresponds the time I moved to g.f. and stopped updating the system. Some year ago I decided to updated platform to a modern CPU (primarily because of the old system having no PCIE slots preventing me from installation of modern 5Ghz WiFi card) and was forced to update Gentoo. I spent about a week updating Gentoo in 1-2 week steps from historical portage git repo facing almost no problems excepting some sources are missing from mirrors and hard to find. When the Gentoo was up to date I let it settle from several month then switched the motherboard (2 weeks ago) finally noticing the absence of shutdown portion of logs in rc.log and some error stating "Unable to.." that I was unable to figure out what it exactly is because it goes out to fast before system reboots. To draw the line, the umount behavior was changed in last.. 8 years or so - quite a long period many things changed.

  3. e-pirate commented on Feb 18, 2026

    @e-pirate
    Author

    @navi-desu any updates here?

  4. navi-desu commented on Feb 19, 2026

    @navi-desu
    Member

    @navi-desu any updates here?

    sorry, taking a bit longer because i'm not quite sure to handle the path, as do_unmount only takes regexes

  5. e-pirate commented on Feb 19, 2026

    @e-pirate
    Author

    @navi-desu I tried to do it myself with dirname, cut and some other basic bash tricks and now I see what you mean. Finally, I found a working solution but I need to test and work out some rare cases. I will come back with MR soon. I successfully tested my solution with rc.log located on separate partition and on root partition - works as expected. But I also would like to treat the case when file does not exists (initial condition when user just switched the rc_logger and there is no file yet because the system is running and had no chance to write any startup messages).

  6. navi-desu commented on Feb 19, 2026

    @navi-desu
    Member

    i was thinking of adding a mountinfo option to query "what mountpoint is $arg under?"

    though i'll wait to see your PR before trying anything since you've already done some work

  7. e-pirate commented on Feb 20, 2026

    @e-pirate
    Author

    @navi-desu the fix is ready, I test-proved it in various simulated cases and on a real server. It took me some effort to write it in openrc-run-kindish style (especially yesno thing), but it works. I will make MR a little bit later.

  8. e-pirate commented on Feb 26, 2026

    @e-pirate
    Author

    Since stat misses required parameter in both busybox and FreeBSD, I found a way to implement desired behavior with mountpoint and some very schmick string variable manipulation in sh the does the job for Linuxes. After getting a fully working code I found another approach that uses only df and awk and looks to be portable across GNU/Linux, Busybox and FreeBSD giving us a universal solution. I tested most vital parts on Gentoo, Alpine and FreeBSD and they work as expected. I'm still testing new implementation, but it looks like a I'm close to a working solution.

  9. e-pirate commented on Mar 18, 2026

    @e-pirate
    Author

    This will take some extra time because my old Lenovo X230 fan died and I'm unable to run VMs to test-prove my fix on a real FreeBSD and Alpine systems. The new fix that is suppose to work on all distributives is ready and partly tested, but I would like to test it on real systems to be sure it work and will not introduce any new issues.

  10. e-pirate commented on May 9, 2026

    @e-pirate
    Author

    @N-R-K I was able to test my new reworked approach that utilizes df instead of 'stat' and others. While testing on Alpine I found that df behaves slightly different on Gentoo and Alpine and some modification is needed. Finally, I was able to successfully use my code on real Gentoo and Alpine systems test-proving it work as expected in all test cases.

    FreeBSD is another thing. I have tested that my code work in 'simulated test' environment - all parts/logical blocks work as expected including df part that in conjunction with awk return correct mountpoint. But FreeBSD 14.3 that I got running in VirtualBox does not use OpenRC so I can't perform a real life test like I did for Gentoo and Alpine. Could you point out what BSD version uses OpenRC so I can use it for testing?

  11. N-R-K commented on May 9, 2026

    @N-R-K
    Contributor

    Could you point out what BSD version uses OpenRC so I can use it for testing?

    The meson build has explicit support for FreeBSD, Dragonfly and NetBSD. Trying out at least one of them is a good start.

    And FYI, I still think the correct place to solve this is in mountinfo.

  12. e-pirate commented on May 9, 2026

    @e-pirate
    Author

    And FYI, I still think the correct place to solve this is in mountinfo.

    Using mountinfo could be a little bit tricky because of nested mountpoints while df seem to give clear results on the mountpoint of the file, available on all systems and the result is consistent.

    Anyway, I will take a look if mountinfo work any better.

  13. e-pirate commented on May 10, 2026

    @e-pirate
    Author

    I have installed GhostBSD that is claimed to use OpenRC by default here. It does not. Non of familiar OpenRC tools present, no localmount file is found anywhere in the system. It looks like no BSD is using OpenRC, at least by default. Anyway, my solution work as expected on FreeBSD 14.3 and GhostBSD 26.1. I think we can gave up BSDs as OpenRC is not a main stream solution there, but my approach work with zsh and BSDs df implementation. Even Gentoo, Alpine and *BSD implementation of df differ in the way they handle file that does not exists, it is not a problem and can be processed by a simple check, all this implementations are pretty consistent in reporting the mount point of the passed file that exist.

    On the other hand, using /proc/self/mountinfo is very tricky because of possible nested mountpoints (/var can be on one partition and /var/log - on another and it is not that easy to distinguish between this cases). It is not completely impossible to implement pure parsing without any external utilities, but df gives consistent results with a single line in all systems.

    If there is no objections, I can provide new PR.

  14. e-pirate commented on May 20, 2026

    @e-pirate
    Author

    Since there were no objections, I've cancelled my previous PR that was really weak in many ways and made a new PR with a new approach incorporating df. This was tasted to cover all problems pointed in comments for my previous PR, proof-tested on a live Alpine to work as expected and tested on some *BSD systems even non of them use OpenRC (just in case).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions