What is a virtual console and how do I make more?

What is a virtual console and how do I make more?

Virtual consoles, put simply, enable you to have several simultaneous sessions on the same machine without doing anything complicated like setting up a network or running X.

When the system starts, it will display a login prompt on the monitor after displaying all the boot messages. You can then type in your login name and password and start working (or playing!) on the first virtual console.

At some point, you will probably wish to start another session, perhaps to look at documentation for a program you are running or to read your mail while waiting for an FTP transfer to finish. Just do Alt+F2 (hold down the Alt key and press the F2 key), and you will find a login prompt waiting for you on the second ``virtual console''! When you want to go back to the original session, do Alt+F1.

The default FreeBSD installation has three virtual consoles enabled (8 starting with 3.3-RELEASE), and Alt+F1, Alt+F2, and Alt+F3 will switch between these virtual consoles.

To enable more of them, edit /etc/ttys (see ttys(5)) and add entries for ttyv4 to ttyvc after the comment on ``Virtual terminals'':

    # Edit the existing entry for ttyv3 in /etc/ttys and change
    # "off" to "on".
    ttyv3   "/usr/libexec/getty Pc"         cons25  on secure
    ttyv4   "/usr/libexec/getty Pc"         cons25  on secure
    ttyv5   "/usr/libexec/getty Pc"         cons25  on secure
    ttyv6   "/usr/libexec/getty Pc"         cons25  on secure
    ttyv7   "/usr/libexec/getty Pc"         cons25  on secure
    ttyv8   "/usr/libexec/getty Pc"         cons25  on secure
    ttyv9   "/usr/libexec/getty Pc"         cons25  on secure
    ttyva   "/usr/libexec/getty Pc"         cons25  on secure
    ttyvb   "/usr/libexec/getty Pc"         cons25  on secure

Use as many or as few as you want. The more virtual terminals you have, the more resources that are used; this can be important if you have 8MB RAM or less. You may also want to change the secure to insecure.

Important: If you want to run an X server you must leave at least one virtual terminal unused (or turned off) for it to use. That is to say that if you want to have a login prompt pop up for all twelve of your Alt-function keys, you are out of luck - you can only do this for eleven of them if you also want to run an X server on the same machine.

The easiest way to disable a console is by turning it off. For example, if you had the full 12 terminal allocation mentioned above and you wanted to run X, you would change settings for virtual terminal 12 from:

    ttyvb   "/usr/libexec/getty Pc"         cons25  on  secure

to:

    ttyvb   "/usr/libexec/getty Pc"         cons25  off secure

If your keyboard has only ten function keys, you would end up with:

    ttyv9   "/usr/libexec/getty Pc"         cons25  off secure
    ttyva   "/usr/libexec/getty Pc"         cons25  off secure
    ttyvb   "/usr/libexec/getty Pc"         cons25  off secure

(You could also just delete these lines.)

Once you have edited /etc/ttys, the next step is to make sure that you have enough virtual terminal devices. The easiest way to do this is:

    # cd /dev
    # sh MAKEDEV vty12

Next, the easiest (and cleanest) way to activate the virtual consoles is to reboot. However, if you really do not want to reboot, you can just shut down the X Window system and execute (as root):

    # kill -HUP 1

It is imperative that you completely shut down X Window if it is running, before running this command. If you do not, your system will probably appear to hang/lock up after executing the kill command.



Home
FAQ