How to live-change the TTY rows and columns

tty

This is a question about Linux running on a Compulab device named
Utilite Pro, but I think it is worth the price to ask this
question here to get it solved for any platform (if possible).

I use to work with ConSpy, a wonderful remote control program for the TTY text mode consoles.
If I boot my Utilite to Ubuntu 12.04 with HDMI cable connected to my 720p home screen, I can remotely connect to any TTY, for example the first TTY:

# conspy 1

But if I disconnect the cable and reboot:

luis@utilite-desktop:~$ sudo conspy 1
conspy: screen too large.  I only handle up to 200x80.

It seems the resolution goes up to 1080p, and so columns/rows in TTY text mode are too big for ConSpy to manage them.

Same results with Kali v1.0.9.

For what I have read, it seems (incredibly, but it is true) that Linux has terrible problems to change the text mode resolution.
All the methods I have found require for GRUB modifications, but Utilite uses U-Boot instead of GRUB, and it is too cryptic for me to manage (never talk about the risk of saving data to flash).

Isn't there any simpler method to change the TTY text resolution (this is: rows and columns)?

I have tried:

# nano /etc/rc.local

… and then adding:

stty cols 83 rows 40

But results stay the same.

Best Answer

It’s unclear which namely text buffer dimension is too large for ConSpy (stty --all or so isn’t provided), so recommendations about both number of text lines and cpl follow.

There are different parameters about a TUI console:

  • video mode (i. e. how many scan lines × screen width (in dots));
  • how many character boxes are there (i. e. text lines × cpl).

Generally:
   text lines = scan lines / character height
   cpl = screen width (in dots) / character width
Character height and width are in dots. Division is integer, where remainder is dropped.

To decrease number of text lines, load a font with greater character height. To decrease cpl (characters per line), load a font with character width 12 or more. For example:

 setfont /usr/share/consolefonts/Uni3-TerminusBold24x12.psf.gz

(although IMHO Terminus is ugly in many respects).

On Ubuntu, a custom /etc/init/console-setup.conf script may be manufactured, to be executed on boot. Namely, instead of

exec loadkeys /etc/console-setup/cached.kmap.gz

one may write

script
    setfont /usr/share/consolefonts/Uni3-TerminusBold24x12.psf.gz
    loadkeys /etc/console-setup/cached.kmap.gz
end script

Note that cached.kmap.gz is a (keymap) and doesn’t interfere with fonts. It is not necessary to execute setfont namely from “console-setup.conf”. Because of the meaning of the term “console” that choice seems logical.
Update: There is /etc/init/console-font.conf task in Ubuntu.

Or read this stuff at Ask Ubuntu, maybe will find something of use.

Most recommendations above assume framebuffer (fbdev) driver enabled. Also, in this case, the fbset command without arguments (or sudo fbset from a user shell) reports geometry of the current video mode, as:
   geometry screen_width scan_lines

In hardware VGA-like mode, obsolete in modern Linuxes, maximal character width is 9. So one can decrease cpl (characters per line) only by enabling a non-standard (decreased) screen width, hence non-standard mode with decreased pixel clock frequency. It isn’t always possible and safe.


One more note about text lines × cpl at Linux virtual consoles. These values can be obtained with
sudo od -t u1 -N 2 /dev/vcsanumber
The first decimal number is text lines and the second is cpl. See vcs(4) and od(1) for explanations how it works.

Related Question