Serial Console: Difference between revisions
serial console login |
m style fixes and improvements |
||
| Line 7: | Line 7: | ||
=== With <code>tio</code> === | === With <code>tio</code> === | ||
<syntaxhighlight lang=console> | |||
$ tio -b 115200 /dev/ttyS0 | |||
</syntaxhighlight> | |||
=== With <code>screen</code> === | === With <code>screen</code> === | ||
<syntaxhighlight lang=console> | |||
$ screen /dev/ttyS0 115200 | |||
</syntaxhighlight> | |||
== Serial devices == | == Serial devices == | ||
| Line 27: | Line 31: | ||
An example for GRUB bootloader: | An example for GRUB bootloader: | ||
<syntaxhighlight lang=nix> | |||
boot.kernelParams = [ "console=ttyS0,115200n8" ]; | |||
boot.loader.grub.extraConfig = " | |||
serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1 | |||
terminal_input serial | |||
terminal_output serial | |||
"; | |||
</syntaxhighlight> | |||
== Unprivileged access to serial device == | == Unprivileged access to serial device == | ||
| Line 43: | Line 48: | ||
Add a user to group <code>dialout</code>: | Add a user to group <code>dialout</code>: | ||
<syntaxhighlight lang=nix> | |||
users.users.<name>.extraGroups = [ "dialout" ]; | |||
</syntaxhighlight> | |||
== Tips == | == Tips == | ||
| Line 55: | Line 62: | ||
In a console sized like yours, e.g. a new tab or tmux window: | In a console sized like yours, e.g. a new tab or tmux window: | ||
<syntaxhighlight lang=console> | |||
$ echo "stty rows $(tput lines) cols $(tput cols)" | |||
</syntaxhighlight> | |||
This will give you the exact invocation for your current terminal size. | This will give you the exact invocation for your current terminal size. | ||
In case tmux is used an alternative is to add the following snippet to the <code>tmux.conf</code> | In case tmux is used an alternative is to add the following snippet to the <code>tmux.conf</code>: | ||
{{file|tmux.conf|3= | |||
<nowiki> | |||
bind R run "echo \"stty columns $(tmux display -p \#{pane_width}); stty rows $(tmux display -p \#{pane_height})\" | tmux load-buffer - ; tmux paste-buffer" | |||
</nowiki> | |||
}} | |||
In this case fixing the terminal size can be achieved by pressing R. | In this case fixing the terminal size can be achieved by pressing R. | ||
| Line 68: | Line 81: | ||
There is a long thread here: https://github.com/NixOS/nixpkgs/issues/84105 | There is a long thread here: https://github.com/NixOS/nixpkgs/issues/84105 | ||
This configuration seems to work | This configuration seems to work | ||
{{file|serial-tty.nix|nix|3= | |||
# Serial console configuration for /dev/ttyS0 | # Serial console configuration for /dev/ttyS0 | ||
# Enables login via serial interface | # Enables login via serial interface | ||
| Line 118: | Line 129: | ||
boot.initrd.verbose = true; # Show initrd messages | boot.initrd.verbose = true; # Show initrd messages | ||
} | } | ||
}} | |||