There is a host machine with Windows 7 x64 running VirtualBox 5.0.12 , in which the Linux Mint 17.3 x64 virtual machine is deployed. At one point, the screen resolution of the guest OS stops adjusting. Changing the screen resolution via GUI and
xrandr works, but automatic (when resizing the window or switching to full screen mode) does not.
Interestingly, when the window is stretched for a split second, the wallpaper is duplicated, i.e. it seems like the system is trying to change the permission, but it immediately comes back.
Reinstallation helps for a while. At some point, the behavior deteriorates again. The version of the add-ons does not matter – on the latest version and on the version from the repository (5.0.4), the behavior is identical. Everything works fine when booting from LiveDVD. Virtualka with Windows 7 also works fine.
What could be the problem and how to overcome it?
Experimentally, it turned out that auto-adjusting the resolution stops working if you set something standard in the display properties through the GUI (1024×768, 1920×1080, etc.) and click Apply . If you save non-standard (like 1854×812) – it works.
xrandr do not break anything.
It turned out that the GUI was creating a file
and writes the set screen resolution to it. If this file is not present or there is a resolution in it, which something considers to be incorrect, then everything works. But it is worth registering the standard there and autoresize immediately gets lost.
So, the research led to the following result.
The graphical display configurator – the Display / Monitor applet, when saving the settings (pressing Apply), creates a file
in which, among other things, the saved screen resolution is registered. When an attempt is made to change the resolution by external means, this file is re-read and returned to the values set in it. If this file is deleted, changing the screen resolution of the guest OS when resizing the virtual machine window starts working correctly.
When rereading, the saved permission is checked. As far as I understand,
xrandr used to set the resolution, which asks the video card for a list of supported modes. If the mode is in the list,
xrandr changes the resolution, if not, it does nothing. Therefore, when installing non-standard resolutions, everything worked – the virtual video card holds almost any resolution, but the VM displays only a small list of them.
The obvious solution to the problem is to prevent the creation or modification of the
monitors.xml file. Oddly enough, changing the owner to
root and setting "empty" rights did not affect anything – the file was still overwritten. I had to act more cruelly – create an empty file and execute the command
sudo chattr +i ~/.config/monitors.xml
After that, the file stopped being overwritten, but the applet also stopped changing the screen resolution, cursing about the impossibility to rename the file.
However, this decision suited me. Now this file does not interfere, you cannot accidentally change it, and you can change the VM screen resolution using VirtualBox itself – either by dragging the corners / sides of the window, or using the menu:
Вид -> Виртуальный экран N -> Запросить разрешение в XxY
The permission changed in this way when the VM is restarted is saved, since the VBox stores it in the VM settings.
I would like, of course, to force Linux to ignore
monitors.xml when resizing the window, but I could not do this.