Serial Console: Difference between revisions

serial console login
DHCP (talk | contribs)
m style fixes and improvements
 
Line 7: Line 7:
=== With <code>tio</code> ===
=== With <code>tio</code> ===


  tio -b 115200 /dev/ttyS0
<syntaxhighlight lang=console>
$ tio -b 115200 /dev/ttyS0
</syntaxhighlight>


=== With <code>screen</code> ===
=== With <code>screen</code> ===


  screen /dev/ttyS0 115200
<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.kernelParams = [ "console=ttyS0,115200n8" ];
  boot.loader.grub.extraConfig = "
boot.loader.grub.extraConfig = "
    serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1
  serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1
    terminal_input serial
  terminal_input serial
    terminal_output 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>:


    users.users.<name>.extraGroups = [ "dialout" ];
<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:


$ echo "stty rows $(tput lines) cols $(tput cols)"
<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>:


  bind R run "echo \"stty columns $(tmux display -p \#{pane_width}); stty rows $(tmux display -p \#{pane_height})\" | tmux load-buffer - ; tmux paste-buffer"
{{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<syntaxhighlight lang="nix">
This configuration seems to work
#
{{file|serial-tty.nix|nix|3=
# serial-tty.nix
#
# 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
}
}
 
}}
</syntaxhighlight>