Rotate display in Linux when not using an X Server

In general you would use a desktop version of whatever Linux Distro you decided suits your needs and you may have an external display that you use to write scripts on or whatever else you do that would work best with a rotated (portrait) display; for me that is note taking or scripting. I have mine hard mounted to the wall and if I need to rotate it it’s almost impossible because I have displays on either side of it that are also hard mounted on the wall.

The last few days I’ve been playing with building a Linux (Ubuntu Server 18.04 LTS) based Gateway to run my network in server mode and I had to use this rotated display as I had other things going on that were taking up the other displays. As you are aware, using a portrait display to see what you’re doing on a server is no fun and yes I can ssh into the server but I wanted to work directly off the server while tasks on my other machine were still going on. Yes, I did make this extra complicated for myself but it made me learn things that I and not many normally people think about. I could make this easy by installing a GUI but that would add extra things to my system that I do not need and that would take up resources that I prefer to go to the task I’m creating this system for.

What to do?

I set out the understand how a server with no sense of GUI would work. Going into this, my thoughts were that I may need to spin a special bistro or something or that it would be all but impossible. Well, turns out it’s actually easier than one would expect.

fbcon to the rescue

What is fbcon you ask?

Basically, it’s a Framebuffer Console that allows you to control features that can be attributed to the graphical nature of the framebuffer. The framebuffer console supports high resolutions, varying font types, display rotation, primitive multihead, etc. Theoretically, multi-colored fonts, blending, aliasing, and any feature made available by the underlying graphics card are also possible.

For this purpose we’ll focus on the rotate feature.

fbcon=rotate:

This option changes the orientation angle of the console display. The
value 'n' accepts the following:

0 - normal orientation (0 degree)
1 - clockwise orientation (90 degrees)
2 - upside down orientation (180 degrees)
3 - counterclockwise orientation (270 degrees)

The angle can be changed anytime afterwards by 'echoing' the same
numbers to any one of the 2 attributes found in
/sys/class/graphics/fbcon

rotate - rotate the display of the active console
rotate_all - rotate the display of all consoles

Console rotation will only become available if Console Rotation
Support is compiled in your kernel.

NOTE: This is purely console rotation. Any other applications that
use the framebuffer will remain at their 'normal'orientation.
Actually, the underlying fb driver is totally ignorant of console
rotation.

Rotate all the frame buffers by running the following command:

Tip: Make sure you change the rotation value to reflect the rotation of your display as noted above (options are 0 -3). Mine rotates country-clockwise so I selected clockwise (1) rotation to match. You can always try the echo command with the different options until it works if you’re not 100% sure then update GRUB to match.
echo 1 | sudo tee /sys/class/graphics/fbcon/rotate_all

Edit /etc/default/grub, find the line named GRUB_CMDLINE_LINUX and add fbcon=rotate:1, so it looks like this:

GRUB_CMDLINE_LINUX="fbcon=rotate:1"

Now run sudo update-grub and sudo update-grub2 to make the change take effect.

That’s it. Let me know if this works for you or if you have a better way to do this in the comments section.

Was this helpful for you? Leave us a comment below. Thanks.

Share your thoughts

This site uses Akismet to reduce spam. Learn how your comment data is processed.