There is a device file called /dev/console
, whose (major,minor)
is (5,1)
.
When I boot with a serial console, it connects to my UART port as /dev/ttyS0
does.
But when I boot with serial console disabled, the /dev/console
seems to connect to elsewhere, where /dev/ttyS0
always connects to the same physical device, namely UART0
.
Is there any indication (like something in /proc
or /sys
) showing such information? I have tried there but found nothing I want.
I am starting to trace the Linux kernel source to clarify their relationships.
Can anyone give me some hints? When, where, how and what to determine the physical device to which /dev/console
connects?
EDIT: The latest finding is that:
/dev/console
is configured by console=
of the kernel parameters, which in turn is used by getty
to open stdin/stdout/stderr
. If no console=
is specified, /dev/null
is opened as stdin/stdout/stderr
. But I am not sure they are exactly the same with /dev/console
, which implies /dev/console
can have its I/O connecting to different physical devices. /dev/console
can be read if a USB HID keyboard is plugged and the console=
is not configured as UART. Therefore /dev/console
== /dev/null
seems to make little sense.
Need more investigations.According to the POSIX standard, /dev/tty is considered to be the terminal associated with a process group whereas /dev/tty0 is associated with a virtual terminal.
tty0 is just an alias for the current virtual terminal and it's where messages from the system are sent. Thus messages from the system will be seen on the console (monitor) regardless of which virtual terminal it is displaying.
The console is the tty where the kernel logs go to. You select a specific one through kernel parameters when booting, it is seen in the log you provided, in the line "Kernel command line: console=ttyS0,115200 root=/dev/mmcblk0p2 roo twait loglevel=8 panic=10"
First, you need the partition ID ( /dev/sdXY ). You can use the lsblk command to find this. Once you have this ID, you can run sudo mount /dev/sdXY /mnt . Your flash drive's filesystem will now be available at /mnt and can be used from the terminal.
I think /sys/devices/virtual/tty/console/active
is what you're looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With