View previous topic :: View next topic |
Author |
Message |
Massimo B. Veteran
Joined: 09 Feb 2005 Posts: 1768 Location: PB, Germany
|
Posted: Fri Jun 24, 2022 7:21 am Post subject: How to get dmesg on terminal F12 |
|
|
Hello,
how do I get the dmesg output on some virtual terminal like CTRL+ALT+F12?
I'm using OpenRC and metalog.
Is it something in /etc/inittab.d/ or some CMDLINE as described in https://unix.stackexchange.com/a/398146 ?
Actually metalog also supports such a thing, but it doesn't work:
/etc/metalog.conf: | echo "$@" > /dev/tty10 |
_________________ HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770 |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20067
|
Posted: Fri Jun 24, 2022 1:56 pm Post subject: |
|
|
Normally I would expect something like this: But I've not used metalog. I can't recall if dmesg provides some other information than kern. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
pa4wdh l33t
Joined: 16 Dec 2005 Posts: 811
|
Posted: Fri Jun 24, 2022 2:54 pm Post subject: |
|
|
If you just want dmesg you could add something like this to inittab:
Code: | c12:2345:respawn:/sbin/agetty -i -a nobody -l /bin/dmesg -o -w 38400 tty12 linux |
Agetty makes sure the tty works, the autologin is fake (even a non existent user would work) and start dmesg as it's login program, passing -w to dmesg will make sure it keeps running in tail -f like style. Is works here if started manually, i haven't actually tested with inittab. _________________ The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world
My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com |
|
Back to top |
|
|
Massimo B. Veteran
Joined: 09 Feb 2005 Posts: 1768 Location: PB, Germany
|
Posted: Mon Jun 27, 2022 7:52 am Post subject: |
|
|
Wow, that seems to work, I just added that line to /etc/inittab.d/dmesg and tried locally as root:
Code: | agetty -i -a nobody -l /bin/dmesg -o -w 38400 tty12 linux | which provides a colorful dmesg on F12.
I'm not sure if this is a job of the logging service. On severe issues this service could fail to start. On the other hand it would be possible to log far more than only dmesg to the tty12, but this could also be a security issue to pipe all syslog messages there. _________________ HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770 |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20067
|
Posted: Mon Jun 27, 2022 10:27 pm Post subject: |
|
|
Access to tty12 would seem to imply physical access, so I'm not sure hw risky that would be. If that were the case, a logging facility that filtered some "sensitive" messages might be a better choice (rsyslog is the only one I've used to do that, but others may do it as well).
Whether or not the logging facility should be doing it is an interesting thought. However, it has historically been the logging service's job. See man syslog.conf, specifically look for "facility" and "Terminal and Console."
I wonder what wouldn't be captured on the console in the case of "severe issues" affecting the logging service that would be be caught by getty /bin/dmesg broadcasting to tty12. Failure of the logging service maybe? _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
gentoo_ram Guru
Joined: 25 Oct 2007 Posts: 474 Location: San Diego, California USA
|
Posted: Tue Jun 28, 2022 12:11 am Post subject: |
|
|
If you have some kind of syslog or logging package set up, let it do it. In my case I'm using syslog-ng.
Doing what you want would be something along the lines of:
Code: | source kern { file("/proc/kmsg"); };
destination console_all { file("/dev/tty12"); };
log { source(kern); destination(console_all); }; |
I'm dumping all syslog logging to /dev/tty12 on my machine. |
|
Back to top |
|
|
Massimo B. Veteran
Joined: 09 Feb 2005 Posts: 1768 Location: PB, Germany
|
Posted: Thu Oct 13, 2022 7:59 am Post subject: |
|
|
Ok, for syslog messages I got this working now with metalog:
/etc/metalog.conf: | #...
console logging :
facility = "*"
command = "/sbin/consolelog.sh"
#... |
/etc/conf.d/metalog: | #...
# Options used by /usr/sbin/consolelog.sh
# Space delimited list of devices to write "console" messages to
#CONSOLE="/dev/console /dev/tty10"
CONSOLE="/dev/tty11"
#... |
For additional dmesg I can get this routed to tty12 via
Code: | agetty -i -a nobody -l /bin/dmesg -o -w 38400 tty12 linux & |
For getting this on every startup is it sane to move that line into some /etc/local.d/dmesg_console.start ?
How can I get the framebuffer on F11 and F12 using the whole screen? In local terminals this works:
Code: | fbset -xres 2560 -yres 1440 | But doing it like this fails:
Code: | fbset -fb /dev/tty12 -xres 2560 -yres 1440
ioctl FBIOGET_VSCREENINFO: Inappropriate ioctl for device | Any idea? _________________ HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770 |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3131
|
Posted: Thu Oct 13, 2022 10:23 am Post subject: |
|
|
Quote: | For getting this on every startup is it sane to move that line into some /etc/local.d/dmesg_console.start ? | Looks like a job for inittab.
Perhaps rc.local would do as well. |
|
Back to top |
|
|
Massimo B. Veteran
Joined: 09 Feb 2005 Posts: 1768 Location: PB, Germany
|
Posted: Fri Nov 04, 2022 9:33 am Post subject: |
|
|
Ok, as for the dmesg I got that configured like this:
/etc/local.d/dmesg_tty12: | c12:2345:respawn:/sbin/agetty -i -a nobody -l /bin/dmesg -o -w 38400 tty12 linux |
_________________ HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Last edited by Massimo B. on Wed Nov 09, 2022 9:23 am; edited 1 time in total |
|
Back to top |
|
|
figueroa Advocate
Joined: 14 Aug 2005 Posts: 2961 Location: Edge of marsh USA
|
Posted: Sun Nov 06, 2022 4:09 am Post subject: |
|
|
I like it. I think it's sane in /etc/local.d. I created the file /etc/local.d/dmesg_f12_console.start containing:
Code: | #!/bin/sh
agetty -i -a nobody -l /bin/dmesg -o -w 38400 tty12 linux |
I've been accustomed to running dmesg or dmesg | tail from a terminal multiple times a day. Using tty12 feels like a new super power. _________________ Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi |
|
Back to top |
|
|
Massimo B. Veteran
Joined: 09 Feb 2005 Posts: 1768 Location: PB, Germany
|
Posted: Wed Nov 09, 2022 9:27 am Post subject: |
|
|
Sorry, that was a typo in my post above and I have fixed it already. That's what I also did, I created /etc/local.d/dmesg_tty12.start, not /etc/init.d/dmesg_tty12.
Btw. there is also /etc/init.d/dmesg which is linked here by /etc/runlevels/sysinit/dmesg. Then there is /etc/conf.d/dmesg: | dmesg_level="1" | What does that do? _________________ HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Last edited by Massimo B. on Tue Nov 29, 2022 7:08 am; edited 1 time in total |
|
Back to top |
|
|
Massimo B. Veteran
Joined: 09 Feb 2005 Posts: 1768 Location: PB, Germany
|
Posted: Wed Nov 09, 2022 9:32 am Post subject: |
|
|
figueroa wrote: | ...dmesg | tail from a terminal multiple times a day. Using tty12 feels like a new super power. | That's not a new idea. I remember from other big Linux distributions 15 years earlier, there already where logs on some of the ttys which might be handy when everything is frozen. Because dmesg and syslog are still quite separate things my idea was to paste both to ttys. _________________ HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770 |
|
Back to top |
|
|
figueroa Advocate
Joined: 14 Aug 2005 Posts: 2961 Location: Edge of marsh USA
|
Posted: Sat Nov 19, 2022 6:07 pm Post subject: |
|
|
figueroa wrote: | I like it. I think it's sane in /etc/local.d. I created the file /etc/local.d/dmesg_f12_console.start containing:
Code: | #!/bin/sh
agetty -i -a nobody -l /bin/dmesg -o -w 38400 tty12 linux |
I've been accustomed to running dmesg or dmesg | tail from a terminal multiple times a day. Using tty12 feels like a new super power. |
An unexpected consequence: Running this script causes me to NOT have a login prompt on any other TTY. Commenting out the agetty line and rebooting made everything normal again. _________________ Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi |
|
Back to top |
|
|
pa4wdh l33t
Joined: 16 Dec 2005 Posts: 811
|
Posted: Sat Nov 19, 2022 6:31 pm Post subject: |
|
|
I guess that is because this gets started before any logins are started and the agetty line never finishes.
Backgrounding it with an & at the end of the command line should do the trick. And i guess this is one of the reasons why starting it from inittab would be a better solution, an other one is that init will re-start it in case it exits for some reason. _________________ The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world
My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com |
|
Back to top |
|
|
Massimo B. Veteran
Joined: 09 Feb 2005 Posts: 1768 Location: PB, Germany
|
Posted: Fri Nov 25, 2022 10:58 am Post subject: |
|
|
pa4wdh wrote: | If you just want dmesg you could add something like this to inittab:
Code: | c12:2345:respawn:/sbin/agetty -i -a nobody -l /bin/dmesg -o -w 38400 tty12 linux |
|
For the mentioned reason I would prefer inittab, but I can't get it working: Code: | ls -al /etc/inittab.d/dmesg
-rw-r--r-- 1 root root 81 8. Jul 07:42 /etc/inittab.d/dmesg
cat /etc/inittab.d/dmesg
c12:2345:respawn:/sbin/agetty -i -a nobody -l /bin/dmesg -o -w 38400 tty12 linux |
Only this works: Code: | ls -al /etc/local.d/dmesg_tty12.start
-rwx------ 1 root root 66 25. Nov 11:50 /etc/local.d/dmesg_tty12.start*
cat /etc/local.d/dmesg_tty12.start
/sbin/agetty -i -a nobody -l /bin/dmesg -o -w 38400 tty12 linux & |
_________________ HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Last edited by Massimo B. on Tue Nov 29, 2022 7:03 am; edited 2 times in total |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3131
|
Posted: Fri Nov 25, 2022 3:32 pm Post subject: |
|
|
Code: | $ grep -C 3 dmesg /etc/inittab
c4:2345:respawn:/sbin/agetty 38400 tty4 linux
c5:2345:respawn:/sbin/agetty 38400 tty5 linux
c6:2345:respawn:/sbin/agetty 38400 tty6 linux
c12:12345:respawn:/sbin/agetty -i -a nobody -l /bin/dmesg -o -HTw 38400 tty12 linux
# SERIAL CONSOLES
#s0:12345:respawn:/sbin/agetty -L 115200 ttyS0 vt100
|
#worksforme
Are you using systemd by any chance? It doesn't use inittab at all, so this could be the cause.
This said, it would be nice to pair it with a pager to allow some scrollback, but I guess inittab doesn't bother preparing env, so how would dmesg know to call less? Launching it inside (attached) screen would do the trick too. |
|
Back to top |
|
|
Massimo B. Veteran
Joined: 09 Feb 2005 Posts: 1768 Location: PB, Germany
|
Posted: Tue Nov 29, 2022 7:06 am Post subject: |
|
|
A scrollback would be nice. However using the whole screen would be nice as well. How can I get the tty use the whole screen? Manually I usually do fbset -xres 2560 -yres 1440. _________________ HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770 |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3131
|
Posted: Tue Nov 29, 2022 1:28 pm Post subject: |
|
|
I think the screen size depends on your video driver.
I recall watching it change during boot as more advanced drivers replace the generic one and hardware discovery kicks in. So perhaps setting the resolution with kernel command line option would do the trick? There was something regarding vesa for example. OR was it VGA mode? Something along those lines anyway. |
|
Back to top |
|
|
Massimo B. Veteran
Joined: 09 Feb 2005 Posts: 1768 Location: PB, Germany
|
Posted: Thu Aug 17, 2023 8:29 am Post subject: |
|
|
Massimo B. wrote: | Code: | ls -al /etc/inittab.d/dmesg
-rw-r--r-- 1 root root 81 8. Jul 07:42 /etc/inittab.d/dmesg
cat /etc/inittab.d/dmesg
c12:2345:respawn:/sbin/agetty -i -a nobody -l /bin/dmesg -o -w 38400 tty12 linux |
| Why this still does not work here with sys-apps/openrc-0.47.1? _________________ HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770 |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3131
|
Posted: Thu Aug 17, 2023 9:01 am Post subject: |
|
|
Like, what doesn't work and in what way it fails?
I'm quite happy with the results I got. |
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3339 Location: Rasi, Finland
|
Posted: Thu Aug 17, 2023 9:50 am Post subject: |
|
|
Massimo B. wrote: | Massimo B. wrote: | Code: | ls -al /etc/inittab.d/dmesg
-rw-r--r-- 1 root root 81 8. Jul 07:42 /etc/inittab.d/dmesg
cat /etc/inittab.d/dmesg
c12:2345:respawn:/sbin/agetty -i -a nobody -l /bin/dmesg -o -w 38400 tty12 linux |
| Why this still does not work here with sys-apps/openrc-0.47.1? | I don't think openrc is involved into this at all. sysvinit, however, is.
If I were you, I'd create a init script which would run dmesg -w > /dev/tty12 or so. _________________ ..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
figueroa Advocate
Joined: 14 Aug 2005 Posts: 2961 Location: Edge of marsh USA
|
Posted: Thu Aug 17, 2023 6:54 pm Post subject: |
|
|
I added a line to the end of the TERMINALS section of /etc/inittab and this works perfectly. I recommend it.
Code: | # TERMINALS
#x1:12345:respawn:/sbin/agetty 38400 console linux
c1:12345:respawn:/sbin/agetty --noclear 38400 tty1 linux
c2:2345:respawn:/sbin/agetty 38400 tty2 linux
c3:2345:respawn:/sbin/agetty 38400 tty3 linux
c4:2345:respawn:/sbin/agetty 38400 tty4 linux
c5:2345:respawn:/sbin/agetty 38400 tty5 linux
c6:2345:respawn:/sbin/agetty 38400 tty6 linux
c12:12345:respawn:/sbin/agetty -i -a nobody -l /bin/dmesg -o -HTw 38400 tty12 linux |
ADDED: Same as noted by szatox. _________________ Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi |
|
Back to top |
|
|
grknight Retired Dev
Joined: 20 Feb 2015 Posts: 1653
|
Posted: Thu Aug 17, 2023 7:33 pm Post subject: |
|
|
Massimo B. wrote: | Massimo B. wrote: | Code: | ls -al /etc/inittab.d/dmesg
-rw-r--r-- 1 root root 81 8. Jul 07:42 /etc/inittab.d/dmesg
cat /etc/inittab.d/dmesg
c12:2345:respawn:/sbin/agetty -i -a nobody -l /bin/dmesg -o -w 38400 tty12 linux |
| Why this still does not work here with sys-apps/openrc-0.47.1? |
What is /etc/inittab.d/? I've never heard of any init daemon looking here for configuration here.
This line should be added to the FILE /etc/inittab for sysvinit to use it. |
|
Back to top |
|
|
figueroa Advocate
Joined: 14 Aug 2005 Posts: 2961 Location: Edge of marsh USA
|
Posted: Thu Aug 17, 2023 8:11 pm Post subject: |
|
|
This:
Code: | $ equery b /etc/inittab.d
* Searching for /etc/inittab.d ...
sys-apps/sysvinit-3.07 (/etc/inittab.d) |
and:
Code: | $ equery b /etc/inittab.d/.keep_sys-apps_sysvinit-0
* Searching for /etc/inittab.d/.keep_sys-apps_sysvinit-0 ...
sys-apps/sysvinit-3.07 (/etc/inittab.d/.keep_sys-apps_sysvinit-0) |
Note date Jun 10:
Code: | $ ls -ld /etc/inittab.d/
drwxr-xr-x 2 root root 4096 Jun 10 13:29 /etc/inittab.d//
$ ls -la /etc/inittab.d/.keep_sys-apps_sysvinit-0
-rw-r--r-- 1 root root 0 Jun 10 13:29 /etc/inittab.d/.keep_sys-apps_sysvinit-0 |
Code: | $ ls -ltr /var/log/portage/ | grep sysv
-rw-rw---- 1 portage portage 12651 Mar 5 14:29 sys-apps:sysvinit-3.06-r1:20230305-192921.log
-rw-rw---- 1 portage portage 12805 Jun 10 13:29 sys-apps:sysvinit-3.07:20230610-172918.log |
_________________ Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi |
|
Back to top |
|
|
grknight Retired Dev
Joined: 20 Feb 2015 Posts: 1653
|
Posted: Thu Aug 17, 2023 8:34 pm Post subject: |
|
|
figueroa wrote: | This:
Code: | $ equery b /etc/inittab.d
* Searching for /etc/inittab.d ...
sys-apps/sysvinit-3.07 (/etc/inittab.d) |
|
Ah, something new since I left sysvinit. Unfortunately it is poorly documented.
Code reads like:
Code: | if( (file_entry = readdir(tabdir))!=NULL){
/* ignore files not like *.tab */
if (!strcmp(file_entry->d_name, ".") || !strcmp(file_entry->d_name, ".."))
continue;
if (strlen(file_entry->d_name) < 5 || strcmp(file_entry->d_name + strlen(file_entry->d_name) - 4, ".tab"))
continue; |
So /etc/inittab.d/dmesg is ignored. If it was named /etc/inittab.d/dmesg.tab, then it would be read. |
|
Back to top |
|
|
|