I have decided to get to grips with linux by installing Ubuntu on a VM on my machine using VirtualBox. Setting up VirtualBox was pretty straight forward, but I had a minor issue I needed to solve. You see, since I was going to be mainly programming on it I wanted to give it a portrait resolution for my second monitor, but when I tried to set that up it rotated the screen 90 degrees in the VirtualBox window!
I tried looking for a way to stop it from rotating but all I found were snarky forum posts from people who didn’t seem to quite understand what the issue is. In the end, I had to figure out a way to set a custom resolution for a “landscape” mode where the width and length were appropriate for my portrait screen. Here are the step to do so.
First of all, you need to create the resolution term to add. To do it you use the following code. In my case, I wanted 1200*1700 with a refresh of 75Hz.
$ cvt 1200 1700 75 # 1200x1700 74.95 Hz (CVT) hsync: 133.19 kHz; pclk: 219.50 MHz Modeline "1200x1700_75.00" 219.50 1200 1296 1424 1648 1700 1703 1713 1777 -hsync +vsync
Once this is done you want to add it as a resolution mode using the output from above. You copy everything after “Modeline” and paste after a
sudo xrandr --newmode command like so:
$ sudo xrandr --newmode "1200x1700_75.00" 219.50 1200 1296 1424 1648 1700 1703 1713 1777 -hsync +vsync
The next step is to find the name of the display device. To do that you run the command below, in my case the device was named Virtual1
$ xrandr | grep -e " connected [^(]" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/" Virtual1 (plus some other stuff here not important)
After that you need to add and enable the mode you created above as an option for the device. The part in between the quotation marks is the name of the mode, in my case it is “1200x1700_75.00”
$ sudo xrandr --addmode Virtual1 1200x1700_75.00 $ xrandr --output Virtual1 --mode "1200x1700_75.00"
When you run the code above the display will change. It will also be added as an option to the display settings window, as shown below.