How to rotate the console?

Hi all,

EDIT 2:
Despite all the documentation saying that ‘rotate_all’ is a thing, it doesn’t seem to work for me, but ‘rotate’ does. I suppose this could change at some point though.

The good news is that from my limited understanding of unix, rotate seems to be doing what I expected rotate_all would be required to achieve. That is to say, setting just rotate and not rotate_all, seems to result in all local consoles being rotated anyway (i.e. alt + f1, alt + f2, etc are all rotated the same).

EDIT - SOLUTION
See here also for dev side of things: Enable framebuffer console rotation · Issue #1342 · clearlinux/distribution · GitHub


Kernel requirements:
	In Clear Linux these requirements should be met in the 'lts' and 'native' kernels from 5.3.6-849 onwards. If you want to check though, read on.
	The kernel must be compiled with at least this:
		CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
	And may also require these (and possible others) to support the framebuffer rotation capability:
		CONFIG_FRAMEBUFFER_CONSOLE=y
		CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
	You can find your current kernel version using:
		uname -a | cut -d" " -f3
	Then search the kernel build source for the above statements, the source is located here at the time of writing:
		/usr/lib/kernel/config-<YOUR-KERNEL-VERSION}>
	The above smashed into a quick one liner so you can check:
		kver=$(uname -a | cut -d" " -f3) && sudo grep -i framebuffer /usr/lib/kernel/config-$kver
		
Assuming your kernel is good to go, there are two main options, the time/duration for which you want to apply the rotation, and which of the local consoles you want to influence.

Console Options:
	You can  choose to rotate just the active local (i.e. not X-Window) console, or else all local consoles with 'rotate' and 'rotate_all' respectively.
	Read more here:
		https://github.com/spotify/linux/blob/master/Documentation/fb/fbcon.txt
	Or, here:
		https://www.kernel.org/doc/Documentation/fb/fbcon.txt

Time/Duration Options:
	
	Here's some commands so you can immediately try rotating the console in your current session.
	
	Within a session until the end of the session (Temporary):
		Default (landscape)
			sudo bash -c "echo -e '0' > /sys/class/graphics/fbcon/rotate"; sudo bash -c "echo -e '0' > /sys/class/graphics/fbcon/rotate_all"
		90 degrees clockwise (i.e. right, portrait):
			sudo bash -c "echo -e '1' > /sys/class/graphics/fbcon/rotate"
				and/or
			sudo bash -c "echo -e '1' > /sys/class/graphics/fbcon/rotate_all"
		180 degree inversion (i.e. upside down, inverted landscape):
			sudo bash -c "echo -e '2' > /sys/class/graphics/fbcon/rotate"
				and/or
			sudo bash -c "echo -e '2' > /sys/class/graphics/fbcon/rotate_all"
		90 degrees counter clockwise (i.e. left, portrait):
			sudo bash -c "echo -e '3' > /sys/class/graphics/fbcon/rotate"
				and/or
			sudo bash -c "echo -e '3' > /sys/class/graphics/fbcon/rotate_all"
			
	From boot for an entire session until it ends (unless overriden with one of the above) (Temporary):
		Use space bar to bring up the systemd boot manager on start up. Once it is open, select the kernel you wish to boot and press 'e' to edit the command line options for the session. Append one of the choices below to your kernel parameters.
		Default (landscape)
			(append nothing, unless you wish to override a change that was made using the automatically parsed kernel boot parameters with clr-boot-manager; in which case append one or more of the options below)
			fbcon=rotate:0
				and/or
			fbcon=rotate_all:0
		90 degrees clockwise (i.e. right, portrait):
			fbcon=rotate:1
				and/or
			fbcon=rotate_all:1
		180 degree inversion (i.e. upside down, inverted landscape):
			fbcon=rotate:2
				and/or
			fbcon=rotate_all:2
		90 degrees counter clockwise (i.e. left, portrait):
			fbcon=rotate:3
				and/or
			fbcon=rotate_all:3
			
	For all future sessions from boot up (Permanent):
		This relies on using the Clear Linux boot loader. Some quick and dirty steps are below, alternatively read (with your head presumably on a weird angle) the output of man clr-boot-manager. Once in the man page, type the following line to quickly get to the relevant section:
			/CONFIGURATION
		My quick guide:
			If you haven't already created the relevant directory for the Clear linux boot manager to parse for kernel parameters, you will need to do that first and change to the directory:
				sudo mkdir /etc/kernel/cmdline.d
			Create a file named whatever you think is approriate and edit away with your favourite text editor, just make sure the file ends with '.conf'.
			Alternatively, use the line below and just modify the number to match your rotate requirements:
				0 - normal orientation (0 degree)
				1 - clockwise orientation (90 degrees)
				2 - upside down orientation (180 degrees)
				3 - counterclockwise orientation (270 degrees)
					sudo touch /etc/kernel/cmdline.d/fbcon-rotation.conf && sudo bash -c "echo -e 'fbcon=rotate:3' > /etc/kernel/cmdline.d/fbcon-rotation.conf" && sudo clr-boot-manager update
		Overrides:
			Short term, use one of the session based methods outlines earlier.
			Longer term, but without losing your cmdline.d/*.conf commands, either edit the relevant files and comment out the line with #, or use the following:
				/etc/kernel/cmdline-removal.d/*.conf
				   A set of files that will be used to modify the kernel commandline by removing string matches from the final consoli‐
				   dated commandline (removal happens after the content from cmdline and cmdline.d/*.conf files are added). The matches
				   are made on a per line basis so multiple different removals should be placed on their own line or file.

This is my first time working on a native (tty?) rather than virtual CLI (vty?). The machine is connected to a portrait monitor and I’m unable to work out how to rotate the CLI output to match.

Reading around on other Linux distros suggest the answer lies in setting fbcon’s rotate_all value to 3. I tried to do this via sysctl -w, but was unable to find the value. I also tried a bit of a brute force approach using:
sudo bash -c ‘echo 3 > /sys/class/graphics/fbcon/rotate_all’
This appears to work without error, but has no effect.

I’m guessing this fbcon variable needs to be assigned in a kernel boot parameter, but I’m unsure how to achieve that in Clear, can anyone help?

Thanks

man clr-boot-manager describes the process. I don’t know what parameter you would need to add, though!

An easy way to test is to hit the letter “e” after the BIOS post and before Clear Linux starts booting. You can then edit the kernel boot parameters temporarily until you find the one that works. Once you figure it out you can man clr-boot-manager as described above to make the change permanent. Once you figure it out let us know what you did. I’m sure someone else will have the same problem in the future.

Thanks will give it a go.

Is there a list of these ‘on boot’ shortcut keys somewhere? I’ve seen others suggest holding spacebar to get the systemd boot manager, but either that’s the stock standard kernel listing that Clear already presents by default, or I’m doing something wrong, as I saw no change.

Yes, that’s the menu you need to be in. If you’re already there, just highlight the kernel you want to boot and hit ‘e’ to edit the default command line.

Thanks all. I’ve tried implementing the suggestions that I have seen elsewhere (largely Debian/Ubuntu solutions) for rotating the console, which is by adding either of the following to boot parameters:
fbcon=rotate:3
That didn’t seem to have any effect.
fbcon=rotate_all:3
That didn’t seem to have any effect.

I then tried adding the same to /etc/kernel/cmdline.d/test.conf and running sudo clr-boot-manager update.
That didn’t seem to have any effect either, though I can see that the parameters were passed, so that answers that bit.

cat /proc/cmdline
Shows that the parameters were passed using either method.

sudo sysctl -a | grep fbcon
…is drawing a blank though. Perhaps fbcon isn’t used/loaded?

At this stage I’m guessing that either I have the fbcon syntax wrong, or that somehow Clear has nothing to do with fbcon.

The only other thing I have discovered is that whilst everything suggests using:
/sys/class/graphics/fbcon/
That seems to be linked to the following instead in Clear:
/sys/devices/virtual/graphics/fbcon/*

Plot thinks a little as the following returns nothing:
lsmod | grep fbcon

A bit of sleuthing with this though:
lsmod | grep fb
Returns the following:
nvidiafb
vgastate (nvidiafb)
fb_ddc (nvidiafb)

No idea what that is, but it sounds suspiciously like an Nvidia equivalent of fbcon (and this system has a cheapo Nvidia graphics card in it). I might have been barking up the wrong tree with fbcon in the first place…

hmmm, modprobe fbcon falls on it’s face as well, module isn’t even in the lib/modules/xxxxx directory. So no wonders as to why that approach has failed.

I tried blacklisting nvidiafb (which worked, stops that running), but I have no idea which function has taken over managing and displaying the console framebuffer as that’s still working. Maybe it’s native to nouveau?

Right, so about six hours later, I’ve discovered a bunch of random stuff I didn’t know before, but more importantly, I think the answer to this problem lies in:

grep -i framebuffer /usr/lib/kernel/config*

For the particular version I’m running at the moment, part of what this returns is:
# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set.

Based on that, I’m presuming this defaults to being disabled. According to other posts:

For fbcon commands to work, the kernel needs to be compiled with:

CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y

It’s currently a tad beyond me to understand how to recompile my own version of the Clear Linux 5.3.5-847.native kernel, so unless someone can help with that, I think this now stalls as being dependent on the dev team to enable this parameter by default.

Cheers

I submitted Enable framebuffer console rotation · Issue #1342 · clearlinux/distribution · GitHub for you.

1 Like

Excellent, thanks for that. I’m not sure if my notes above are the whole story to make this work, but they certainly seem like a key part of it.

Just an update to say that this has now been resolved thanks to the dev team. I will edit the first post with some pertinent details on how to do this both temporarily and permanently for the native console (i.e. not for an X based console, for that use xrandr or similar).

Thanks to everyone that contributed to getting this resolved so quickly!

2 Likes