Set exact display resolution in VirtualBox virtual machine

VirtualBox is my virtualization software of choice. It is free and feature-rich, so all my virtual machines are created in VirtualBox.

Sometimes you need to set the exact display resolution which is not listed in the guest OS settings. While you can achieve this by resizing the VM's window, it is a waste of time. Here is how you can do it quickly.

Advertisement


Let's say I want to set the display resolution in my Windows 10 VM to 1366x768. As you can see, it is not listed in available display modes in my setup:

VM display modes To bypass this limitation, you need to use the VBoxManage tool, which is a console application to tweak virtual machines on the fly and offline. Our readers might be familiar with this tool from the article How to resize a VirtualBox HDD image (VDI).

You need to execute the following commands:

VBoxManage setextradata global GUI/MaxGuestResolution any
VBoxManage setextradata "Machine Name" "CustomVideoMode1" "Width x Height x Bpp"
VBoxManage controlvm "Machine Name" setvideomodehint Width Height Bpp

The first command unlocks all possible display resolutions for virtual machines.
The second command defines a custom video mode for the specific virtual machine with name "Machine Name".
Finally, the third command sets this custom video mode for your virtual machine.

You must run these commands after the virtual machine has been started, when the guest operating system is ready to use and its Guest Additions are installed properly and loaded.

In my case, I need to execute the following commands:

VBoxManage setextradata global GUI/MaxGuestResolution any
VBoxManage setextradata "Windows 10 build 14352" "CustomVideoMode1" "1366x768x32"
VBoxManage controlvm "Windows 10 build 14352" setvideomodehint 1366 768 32

Under Linux, VBoxManage is accessible from any opened terminal/console.
Under Windows, you need to open a new command prompt window in the folder C:\Program Files\Oracle\VirtualBox. See the following article: All ways to open the command prompt in Windows 10, and the part "Run the command prompt directly from Explorer".

Once you execute these commands, the result will be as follows:virtualbox set exact display resolution

That's it.

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Advertisment

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer from Russia who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

22 thoughts on “Set exact display resolution in VirtualBox virtual machine”

  1. VBoxManage.exe: error: Code E_FAIL (0x80004005) – Unspecified error (extended info not available)
    VBoxManage.exe: error: Context: “LockMachine(a->session, LockType_Shared)” at line 812 of file VBoxManageMisc.cpp

  2. much usefull for me too, thank you Sergey!
    I’d like to highlight the following: if I try to set the commands when the guest machine is opened, then I receive an error message similar to the one indicated by Talon, think because a running machine has its settings locked. I can do it only if the guest machine is down

    1. Try providing the display number. This is from its help:

      setvideomodehint <xres> <yres> <bpp> [<display>] [<enabled:yes|no> | [<xorigin> <yorigin>]]] |

      Like this

      VBoxManage controlvm "Windows 10 build 14352" setvideomodehint 1366 768 32 1
  3. —> THIS <— This worked!!!!! I could set the grub boot screen size, and the size inside KDE, but it would always change to like 640×480 for the login screen, between those two. It was driving me crazy. I noticed it was doing it right around the time that dbus and guest additions were being loaded. I couldn't tell which one. This worked, so obviously it was guest additions messing with the resolution. Now I have consistent screen size from grub menu all the way through to KDE desktop. Awesome! Thanks!!!!!

  4. This works to set a resolution,
    but when you try to restore the VM you will get VERR_VGA_INVALID_CUSTOM_MODE

    Don’t ever save machine state with one of these resolutions…

    1. Removing the resolution before starting works:
      VBoxManage setextradata “Machine Name” “CustomVideoMode1” “”

      But I’m not sure if this allows you to restore a machine from suspension from file.

  5. Does resize however the display resolution doesn’t save once I turn back on auto-resize guest display and I can’t find it in the display properties then.

Leave a Reply

Your email address will not be published. Required fields are marked *