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.

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:

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

  1. Mike Douglas

    Great! Thanks man, you helped me so much! Thank you very much!

    Reply
    1. Sergey Tkachenko Post author

      I am happy to read this. You are welcome!

      Reply
  2. Talon

    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

    Reply
  3. Will V

    I’m sorry… Do you know WHERE I can find the manage tool where I input these commands?

    Reply
    1. Sergey Tkachenko Post author

      it is in the installation folder of the app.
      c:\program files\oracle\virtualbox

      Reply
  4. mauro

    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

    Reply
  5. Carsten

    Wow, worked for me finial! Even on OS X they have been the same cmd’s, so thanks!

    Reply
  6. Roger Femali

    Is there a way to do this for just the 2nd display in a 2 monitor set up?

    Reply
    1. Sergey Tkachenko Post author

      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
      Reply
      1. Michael Bell

        What does mean? I do not understand what they want.

        Reply
      2. Michael Bell

        what do they want for display?

        Reply
        1. Sergey Tkachenko Post author

          Who?

          Reply
  7. John

    —> 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!!!!!

    Reply
  8. boy

    did absolutely nothing. changed nothing.

    Reply
  9. pacc

    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…

    Reply
    1. pacc

      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.

      Reply
  10. LimaNL

    Excellent article. Your info helped me a lot!

    Thank you so much!!

    Reply
  11. Michael Bell

    what is the display field mean? I do not understand what they want.

    Reply
    1. Sergey Tkachenko Post author

      The X server can handle multiple displays. Each has its own number/

      Reply
  12. Muamer

    Thank you!

    Reply
  13. Flynn

    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.

    Reply
    1. Flynn

      Also, adding on to that, can’t have two custom display resolutions at the same time. Kinda a problem.

      Reply

Leave a Reply

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