Forcing monitor resolution in VirtualBox VM on Linux Guest
I am working in a VirtualBox 4 VM running Slackware-current. I have added an external monitor, and am attempting to set up both of them to run in their native resolutions, but am having no luck.
I am following the instructions set out at on this page.
But I cannot get past the step where I add a new monitor mode, ie:
xrandr --addmode VBOX1 1600x1200_60.00
When I run that, I get an error message:
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 151 (RANDR)
Minor opcode of failed request: 18 (RRAddOutputMode)
Serial number of failed request: 20
Current serial number in output stream: 21
I have gone through a number of forums, installed the latest version of VirtualBox4, and installed the Guest OS Runtime utilities.
I have also made sure that my virtual display can handle this, ie:
xrandr | grep -i maximum
yields:
minimum 64 x 64, current 800 x 600, maximum 32000 x 32000
Has anyone else encountered something similar?
Solution 1:
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:
# [email protected] (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
Solution 2:
I had the same problem when running Arch on virtualbox. Allocating more Video Memory seems to resolve this issue for me.