How to see shutdown log

Polytropon freebsd at edvax.de
Sun Jul 26 20:18:35 UTC 2020


On Sun, 26 Jul 2020 09:41:43 -0400, Ernie Luzar wrote:
> Polytropon wrote:
> > On Fri, 24 Jul 2020 20:58:01 -0400, Ernie Luzar wrote:
> >> When you boot the system a bunch of messages roll across the screen to 
> >> fast to read. The dmesg -a command will show these to you to read at 
> >> your own pace. When you issue the shutdown or halt command a bunch of 
> >> different messages roll across the screen to fast to read.
> >>
> >> Is there a way view these messages after the system comes back up later?
> > 
> > Yes, those are located to /var/log/messages, as long as
> > file system access is possible; the last kernel messages
> > therefore aren't being logged.
> 
> 
> I checked and what is logged to /var/log/messages on host shutdown is no 
> were close to the messages I see fly past on the console terminal.

The problem probably is that at a certain point, messages will
only be written to terminal and to memory buffer, but not to a
file because no file access is possible anymore (kernel still
runs, but disks have been unmounted, so no VFS access can be
done anymore).

Messages in the RAM will not survive a reboot. However, those
created at system startup are copied to the log file as soon
as it becomes accessible.



> This is real easy for people to test so give it a run.

Sure. There is a possibility that might work, even though I
have not tested it: You could "hijack" the kernel printing
routine (the one that emits the messages) and have it copy
characters to a line printer, a virtual one or a real one,
and then you could see those messages.

It would maybe also be possible to read the system console's
file /dev/console and copy everything that is written to it
to /dev/lpt0.



> Thinking maybe something else is controlling what goes to the message 
> file on shutdown. Have any ideas where I should look?

Basically, /var/log/messages contains all messages created
with the system logging mechanism. When programs decide to
emit messages by a simple printf() to whatever is their
controlling terminal, those won't be logged. To get those
messages, checking the console buffer (rather than the
system message buffer) is probably a better way to do.

Again, note that file access is made impossible at a certain
stage during system shutdown that is usually followed by
other stages that also can print messages. If you really
want to get those messages, you need a way to capture them
independently from anything that is a log file unter VFS
control...




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list