I've encountered this exact problem myself.
First, in most of the guides, you usually do the following:
Specify a monitor resolution, then provide it to gtf:
gtf 1024 768 60
(get the Modeline information for 1024x768 resolution at 60Hz).
In my case, it yields:
#1024x768 @ 60.00 Hz (GTF) hsync: 47.70 kHz; pclk: 64.11 MHz
Modeline "1024x768_60.00" 64.11 1024 1080 1184 1344 768 769 772 795 -HSync +Vsync
Create the new mode:
xrandr --newmode "1024x768_60.00" 64.11 1024 1080 1184 1344 768 769 772 795
(DO NOT include the trailing -HSync +Vsync
. Some guides tell you to do this, but it will break the configuration for some reason).
Now you should be able to add the mode to a new display:
xrandr --addmode VBOX0 1024x768_60.00
Set the new mode for the device:
xrandr --output VBOX0 --mode 1024x768_60.00
If step 3 failed still (these steps work for my laptop screen which is 1680x1050, but for some reason not for my external monitor which supports 1600x1200. These steps do work for resolutions up to 1280x1024 for my external monitor though. Weird), you can still try letting xrandr use auto
mode. In my case, it allowed me to have my laptop screen and external monitor working perfectly. The script I use is attached below:
#!/bin/bash
# Script to automatically resize virtual monitors in VirtualBox
# Start the server
sudo killall VBoxService
sleep 1
sudo VBoxService
sleep 1
# Start the client service
VBoxClient-all
# Get the modeline information we want for the following resolutions:
# 1680x1050@60.00Hz (Laptop display)
RES0="1680 1050 60"
# 1280x1024@60Hz (External monitor)
RES1="1280 1024 60"
# Setup mappings for physical to virtual monitors
MAP0="VBOX0"
MAP1="VBOX1"
# Generate settings
SETTINGS0=$( gtf $RES0 | grep Modeline | cut -d ' ' -f4-16 )
SETTINGS1=$( gtf $RES1 | grep Modeline | cut -d ' ' -f4-16 )
# Get name of modelines from settings
NAME0=$( echo $SETTINGS0 | cut -d ' ' -f1 )
NAME1=$( echo $SETTINGS1 | cut -d ' ' -f1 )
# Echo settings
echo "Modeline for Display 0 ($NAME0): $SETTINGS0"
echo "Modeline for Display 1 ($NAME1): $SETTINGS1"
# Create the new modelines via xrandr
xrandr --newmode $SETTINGS0
xrandr --newmode $SETTINGS1
# Add the newly created modelines to devices
xrandr --addmode $MAP0 $NAME0
xrandr --addmode $MAP1 $NAME1
# Finally, enable the new modes
xrandr --output $MAP0 --mode $NAME0
xrandr --output $MAP1 --mode $NAME1
# Extra: Attempt to run "auto" mode on the external monitor
# This is out last-ditch effort (which worked in this case) to get it running at
# 1600x1200 instead of 1280x1024 :)
xrandr --output $MAP1 --auto --above $MAP0
3xrandr --addmode VBOX0 "1600x900_60.00" gives me following error: Failed to get size of gamma for output default. cannot find output "VBOX0" – stiv – 2015-03-31T10:51:21.153
I get
xrandr --newmode $SETTINGS0 X Error of failed request: BadRequest (invalid request code or no such operation) Major opcode of failed request: 149 (RANDR) Minor opcode of failed request: 25 (RRGetScreenResourcesCurrent) Serial number of failed request: 11 Current serial number in output stream: 11
– moodboom – 2017-08-01T19:16:14.640