This is more to keep a record of what I had to do to fix the display setting on my Ubuntu 12.04 VM under Virtualbox 4.2
To be sure to use native resolutions, do a guest addition install. Â Doing the install fixed my issues, however, when I rebooted the machine a bit later after doing all the software updates, I ran into resolution issues again. This time, my laptop’s recommended resolution (1366 x 768) was not in the list. Â A bit of research and I found out that there’s this X Window System extension called X Resize, Rotate and Reflect Extension (xRandR)Â that allows clients to dynamically change X screens. Â Here’s a log of the commands I ran and their respective outputs:
amit@amit-VirtualBox:~$ xrandr Screen 0: minimum 64 x 64, current 1440 x 1050, maximum 32000 x 32000 VBOX0 connected 1440x1050+0+0 0mm x 0mm 1024x768 60.0 + 60.0 1600x1200 60.0 1440x1050 60.0* 1280x960 60.0 800x600 60.0 640x480 60.0
As one can see, it does detect several resolutions, but not the one I want (1366×768)
amit@amit-VirtualBox:~$ sudo cvt 1366 768 60 [sudo] password for amit: # 1368x768 59.88 Hz (CVT) hsync: 47.79 kHz; pclk: 85.25 MHz Modeline "1368x768_60.00" 85.25 1368 1440 1576 1784 768 771 781 798 -hsync +vsync
so running cvt with the resolution in question gets us the “Modeline” for the resolution we want. Â Let’s add this “modeline” but without the keyword modeline to xrandr
amit@amit-VirtualBox:~$ sudo xrandr --newmode "1368x768_60.00" 85.25 1368 1440 1576 1784 768 771 781 798 -hsync +vsync
Now we need to add this new mode that we have created to our output, but before that, we should know our output name.
amit@amit-VirtualBox:~$ sudo xrandr -q Screen 0: minimum 64 x 64, current 1440 x 1050, maximum 32000 x 32000 VBOX0 connected 1440x1050+0+0 0mm x 0mm 1024x768 60.0 + 60.0 1600x1200 60.0 1440x1050 60.0* 1280x960 60.0 800x600 60.0 640x480 60.0 1368x768_60.00 (0x15a) 85.2MHz h: width 1368 start 1440 end 1576 total 1784 skew 0 clock 47.8KHz v: height 768 start 771 end 781 total 798 clock 59.9Hz
As visible here, our display screen is called VBOX0 and the name shows on the second line of the output above. Â Our newly added resolution mode is also present now in this output. Â Let’s add this mode:
amit@amit-VirtualBox:~$ sudo xrandr --addmode VBOX0 1368x768_60.00
And done, you should now be able to switch to this resolution.
However, when you will reboot your computer, you will get an error as the one in the image below (“Could not apply the stored configuration for monitors”) unless you do some permanent modifications. Â You see, the xrandr command line modifications we did are only applicable to the current session. Â SO let’s get cracking with making the monitor file in the xorg.conf.d directory.
Now the configuration for xorg is stored in /usr/share/X11/xorg.conf.d/ so let’s create a file there called 10-monitor.conf (use your favorite text editor or vi like I do)
amit@amit-VirtualBox:~$ cd /usr/share/X11/xorg.conf.d/ amit@amit-VirtualBox:~$ sudo vi 10-monitor.conf
Section "Monitor" Identifier "Monitor0" #Place your modeline output given by "cvt 1366 768 60" command Modeline "1368x768_60.00" 85.25 1368 1440 1576 1784 768 771 781 798 -hsync +vsync Option "PreferredMode" "1368x768_60.00" EndSection Section "Screen" Identifier "Screen0" #Collapse Monitor and Device section to Screen section Device "VBOX0" Monitor "Monitor0" DefaultDepth 24 #Choose the depth (16||24) SubSection "Display" Depth 24 Modes "1368x768_60.00" #Choose the resolution EndSubSection EndSection
If the above doesn’t work after you have rebooted your comp, make sure there’s no typo. Â An example of typo is this: “1368X768_60.00” vs “1368x768_60.00” …. a capital X made me waste an hour or so in troubleshooting as to why my 10-monitor.conf was not giving me the 1368×768 resolution.
In addition, there are other solutions out there that use the xrandr commands I listed above and turn them into a shell script executed with lightdm (look here and here). Remember, ctrl+alt+F1 will take you to a terminal and help you troubleshoot.
 References:
- https://wiki.archlinux.org/index.php/Xrandr
- https://wiki.ubuntu.com/X/Config/Resolution/#Adding_undetected_resolutions
- https://wiki.archlinux.org/index.php/Xorg#Monitor_settings
- http://samuelmartin.wordpress.com/2012/05/29/enabling-resolutions-in-ubuntu-12-04-lubuntu-12-04/