[BACK]Return to faq7.html CVS log [TXT][DIR] Up to [local] / www / faq

File: [local] / www / faq / faq7.html (download) (as text)

Revision 1.165, Wed Nov 24 23:32:42 2021 UTC (2 years, 6 months ago) by brynet
Branch: MAIN
CVS Tags: HEAD
Changes since 1.164: +2 -2 lines

macppc also supports switching virtual terminals

<!doctype html>
<html lang=en id=faq>

<!-- If you make edits to any FAQ documents, please start each sentence
     on a new line, and try to keep the general formatting consistent
     with the rest of the pages -->

<title>OpenBSD FAQ: Keyboard and Display Controls</title>
<meta charset=utf-8>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="../openbsd.css">
<link rel="canonical" href="https://www.openbsd.org/faq/faq7.html">

<h2 id=OpenBSD>
<a href="../index.html">
<i>Open</i><b>BSD</b></a>
FAQ - Keyboard and Display Controls
<small>
<a href="index.html">[FAQ Index]</a>
</small>
</h2>
<hr>

<ul>
<li><a href="#Consoles"       >Working on the Console</a>
  <ul>
  <li><a href="#Keyboard"     >Remapping the Keyboard</a>
  <li><a href="#ConsoleMouse" >Console Mouse Support</a>
  <li><a href="#SwitchConsole">Switching Consoles</a>
  </ul>
<li><a href="#VGAConsoles"    >Consoles on VGA Hardware</a>
  <ul>
  <li><a href="#Scrollback"   >The Scrollback Buffer</a>
  <li><a href="#AddConsole"   >Adding More Virtual Consoles</a>
  <li><a href="#Size80x50"    >Changing Console Font and Resolution</a>
  </ul>
<li><a href="#Blanker"        >Blanking an Inactive Console</a>
<li><a href="#SerCon"         >Configuring a Serial Console</a>
</ul>
<hr>

<h2 id="Consoles">Working on the Console</h2>

<h3 id="Keyboard">Remapping the Keyboard</h3>

The <a href="https://man.openbsd.org/kbd">kbd(8)</a> utility can be used to
change the keyboard encoding.
Most keyboard options can be controlled using the
<a href="https://man.openbsd.org/wsconsctl">wsconsctl(8)</a> utility.
For example, to change keymappings with
<a href="https://man.openbsd.org/wsconsctl">wsconsctl(8)</a>,
one would execute the following:

<pre class="cmdbox">
# <b>wsconsctl keyboard.encoding=uk</b>
</pre>

Remap <code>[Caps Lock]</code> to be
<code>[Control L]</code>, the left control key:

<pre class="cmdbox">
# <b>wsconsctl keyboard.map+="keysym Caps_Lock = Control_L"</b>
</pre>

To make changes permanent, use the
<a href="https://man.openbsd.org/wsconsctl.conf">wsconsctl.conf(5)</a> file.

<h3 id="ConsoleMouse">Console Mouse Support</h3>

For the <a href="../alpha.html">alpha</a>, <a href="../amd64.html">amd64</a>
and <a href="../i386.html">i386</a> platforms, OpenBSD provides
<a href="https://man.openbsd.org/wsmoused">wsmoused(8)</a>.
It can be enabled with the <a href="https://man.openbsd.org/rcctl">rcctl(8)</a>
utility also described in the FAQ on the <a href="faq10.html#rc">rc script</a>.

<h3 id="SwitchConsole">Switching Consoles</h3>

On most alpha, macppc, amd64 and i386 systems, OpenBSD provides six virtual
terminals by default: <code>/dev/ttyC0</code> through <code>/dev/ttyC5</code>.
You can switch between them using <code>[CTRL]+[ALT]</code> together with
<code>[F1]</code> through <code>[F6]</code>.
The virtual terminal <code>ttyC4</code> is reserved for use by the
<a href="faq11.html">X Window system</a>.

<h2 id="VGAConsoles">Consoles on VGA Hardware</h2>

<b>Note:</b> This section discusses features of the
<a href="https://man.openbsd.org/vga">vga(4)</a> driver.
They are not supported by all video cards.
The instructions below <b>will not work on modern graphics hardware</b>
that uses the <a href="https://man.openbsd.org/drm">drm(4)</a> driver.

<h3 id="Scrollback">The Scrollback Buffer</h3>

On a few platforms and hardware combinations, OpenBSD provides a console
scrollback buffer.
This allows you to see information that has already scrolled past your screen.
To move up and down in the buffer, use <code>[SHIFT]+[PGUP]</code> and
<code>[SHIFT]+[PGDN]</code>.
The number of pages that you can move up and view is 8.
Switching consoles will clear the scrollback buffer.
Due to space limitations, the install kernels do not have this feature.

<h3 id="AddConsole">Adding More Virtual Consoles</h3>

If you wish to have more than the default number of virtual consoles, use the
<a href="https://man.openbsd.org/wsconscfg">wsconscfg(8)</a> command to create
screens for <code>ttyC6</code>, <code>ttyC7</code> and above.
For example:

<pre class="cmdbox">
# <b>wsconscfg -t 80x25 6</b>       # this will not work on systems using drm(4)
</pre>

This will create a virtual terminal for <code>ttyC6</code>, accessed by
<code>[CTRL]+[ALT]+[F7]</code>.
To get a <code>login:</code> prompt on the newly created virtual console,
you need to set it to <code>on</code>
in <a href="https://man.openbsd.org/ttys">ttys(5)</a>,
and either reboot or send <a href="https://man.openbsd.org/init">init(8)</a>
a HUP signal using <a href="https://man.openbsd.org/kill">kill(1)</a>.
Add this command to <a href="https://man.openbsd.org/rc.local">rc.local(8)</a>
if you want the extra screen the next time you boot the computer.

<h3 id="Size80x50">Changing Console Font and Resolution</h3>

Many VGA video cards on alpha, amd64 and i386 are capable of displaying a higher
text resolution of 50 lines instead of the usual 25 lines.
The standard 80x25 text screen uses 8x16 pixel fonts.
To double the number of lines, we first load an 8x8 pixel font with
<a href="https://man.openbsd.org/wsfontload">wsfontload(8)</a>.
Then we delete and recreate a virtual console with the desired screen resolution
using <a href="https://man.openbsd.org/wsconscfg">wsconscfg(8)</a>.
This can be done automatically at boot by adding the following commands to
the end of the <a href="https://man.openbsd.org/rc.local">rc.local(8)</a>
script:

<pre class="cmdbox">
wsfontload -h 8 -e ibm /usr/share/misc/pcvtfonts/vt220l.808	# load 8x8 font
wsconscfg -dF 5			# delete screen 5 accessed by [CTRL]+[ALT]+[F6]
wsconscfg -t 80x50 5		# add screen 5 with 50 lines of 80 characters
</pre>

If you wish to modify other screens, simply repeat the delete and add screen
steps for whichever screens you want running at the 80x50 resolution.
It is not possible to change the resolution of the primary console device
<code>ttyC0</code> accessed by <code>[CTRL]+[ALT]+[F1]</code>.
Avoid changing screen 4 which is used by X as a graphical screen.

<h2 id="Blanker">Blanking an Inactive Console</h2>

If you wish to blank your console after a period of inactivity without using X,
modify the following <a href="https://man.openbsd.org/wscons">wscons(4)</a>
variables:

<ul>
  <li><b><code>display.screen_off</code></b>
    determines the blanking time in milliseconds.
  <li><b><code>display.kbdact</code></b>
    if set to <code>on</code>, keyboard activity will unblank the screen.
  <li><b><code>display.msact</code></b>
    if set to <code>on</code>, <a href="#ConsoleMouse" >console mouse</a>
    activity will unblank the screen.
  <li><b><code>display.outact</code></b>
    if set to <code>on</code>, screen output will unblank the screen.
  <li><b><code>display.vblank</code></b>
    if set to <code>on</code> will disable the vertical sync pulse.
    This will cause many monitors to go into an energy saver mode.
</ul>

For example:

<pre class="cmdbox">
# <b>wsconsctl display.screen_off=60000</b>
display.screen_off -> 60000
</pre>

Set them permanently by editing
<a href="https://man.openbsd.org/wsconsctl.conf">wsconsctl.conf(5)</a>.
The blanker is activated when either <code>display.kbdact</code> or
<code>display.outact</code> is set to <code>on</code>.
Note that one of those two must be <code>off</code>.

<h2 id="SerCon">Configuring a Serial Console</h2>

OpenBSD supports serial console on most platforms, however details vary greatly
between platforms.
In addition to allowing users to log in, they're also useful for recording
console output.

<p>
There are two parts to getting a fully functional serial console on an OpenBSD
system:

<ul>
  <li>Enable the serial port to be used as an interactive terminal, so a user
      can log in to it when running multi-user.
  <li>Configure OpenBSD to use your serial port as a console for status and
      single user mode.
      This part is very platform-dependent.
</ul>

<h3 id="SerContty">Change <code>/etc/ttys</code> to get a login prompt</h3>

Terminal sessions are controlled by the
<a href="https://man.openbsd.org/ttys">ttys(5)</a> file.
Before OpenBSD will give you a <code>login:</code> prompt at a device,
it has to be enabled in <code>/etc/ttys</code>.
The serial terminal is disabled by default on platforms which typically have
a keyboard and screen attached.
We'll use the amd64 platform as an example.
In this case, you must edit the line that reads:

<pre class="cmdbox">
tty00   "/usr/libexec/getty std.9600"   unknown off
</pre>

to read something like:

<pre class="cmdbox">
tty00   "/usr/libexec/getty std.9600"   vt220   on secure
</pre>

Here, <code>tty00</code> is the serial port we are using as a console and
<code>vt220</code> is the
<a href="https://man.openbsd.org/termcap.5">termcap(5)</a>
entry that matches your terminal.
Other likely options might include <code>vt100</code>, <code>xterm</code>, etc.
The <code>on</code> bit enables the login prompt by activating
<a href="https://man.openbsd.org/getty">getty(8)</a> for that serial port.
The <code>secure</code> bit permits a <code>root</code> login at this console.
The <code>9600</code> bit is the terminal baud rate.

<p>
Note that you can use a serial console for install without doing this step, as
the system is running in single user mode, and not using <code>getty</code> for
login.

<p>
On some platforms and some configurations, you must bring the system up in
single user mode to make this change if a serial console is all you have
available.

<h3>amd64 and i386</h3>

To configure the boot process to use the serial port as a console, your
<a href="https://man.openbsd.org/amd64/boot.conf">boot.conf(5)</a> file should
include the line:

<pre class="cmdbox">
set tty com0
</pre>

This file is put on your boot drive, which could also be your install media.
Use the <code>stty</code> option if you need a baud rate other than 9600bps.

<p>
Some systems may be able to operate without a video card in the machine,
but certainly not all -- many consider this an error condition.
Others are capable of redirecting all BIOS keyboard and screen activity to
a serial port through a configuration option, so the machine can be
completely maintained through the serial port.
Your results may vary.
When using this feature, some BIOS implementations may prevent the boot loader
from seeing the serial port, thus the kernel will not be told to use it.
There may be a BIOS option "Continue Console Redirection after POST."
This should be set to OFF, so the boot loader and the kernel can handle
their own console.

<p>
To use the machine in multi-user mode, you will need to edit
<code>/etc/ttys</code> as <a href="#SerContty">explained above</a>.

<h3>sparc64</h3>

These machines are designed to be completely maintainable with a serial console.
Simply remove the keyboard from the machine, and the system will run serial.

<p>
On some systems, the serial ports are labeled <code>ttya</code>,
<code>ttyb</code>, <code>ttyh0</code> or <code>ttyh1</code>.
It is not necessary to make any changes to <code>/etc/ttys</code> to use a
serial console in multi-user mode.

<p>
Some sparc64 systems interpret a BREAK signal on the console port to be the
same as a STOP-A command.
This kicks the system back to the Forth prompt, stopping any application
and operating system at that point.
This is handy when desired, but unfortunately, some serial terminals at
power-down and some RS-232 switching devices send something the computer
interprets as a break signal, halting the machine.
Test before you go into production.

<p>
If you have a keyboard and monitor attached, you can still force the
serial console to be used instead by using the following commands at the
<code>ok</code> prompt:

<pre class="cmdbox">
ok <b>setenv input-device ttya</b>
ok <b>setenv output-device ttya</b>
ok <b>reset</b>
</pre>

If <code>ttyC0</code> is active in <code>/etc/ttys</code>, as
<a href="#SerContty">explained above</a>, you can use the keyboard and
monitor in X.

<h3>macppc</h3>

The macppc machines are configured for a serial console through OpenFirmware.
Use the commands:

<pre class="cmdbox">
ok <b>setenv output-device scca</b>
ok <b>setenv input-device scca</b>
ok <b>reset-all</b>
</pre>

Set your serial console to 57600bps, 8N1.

<p>
Unfortunately, serial console is not directly possible on most MacPPCs.
While most of these machines do have serial hardware, it isn't accessible
outside the machine.
Fortunately, a few companies offer add-on devices for several Macintosh
models which will make this port available for use as a serial console.

<p>
You will have to change <code>tty00</code> in <code>/etc/ttys</code> to
<code>on</code> and set the speed to 57600 instead of the default of 9600 as
detailed <a href="#SerContty">above</a> in single user mode before booting
multi-user and having the serial console functional.

<h3>I get input/output error when trying to use my tty devices</h3>

You need to use <code>/dev/cuaXX</code> for connections initiated from the
OpenBSD system.
The <code>/dev/ttyXX</code> devices are intended only for terminal or dial-in
usage.
Refer to the <a href="https://man.openbsd.org/cua">cua(4)</a> manual for more
details.