Solved VirtualBox Guest Additions does not resize screen

mr123

New Member


Messages: 12

I am using FreeBSD inside VirtualBox (I downloaded "FreeBSD-12.2-RELEASE-amd64.vhd.xz"). I increased the size of the VirtualBox disk in order to accomodate X.Org, then I installed X.Org using pkg install xorg. After that, I installed VirtualBox Guest Additions: pkg install virtualbox-ose-additions. I followed the instructions in the handbook and added these lines to /etc/rc.conf:

Code:
vboxguest_enable="YES"
vboxservice_enable="YES"
vboxservice_flags="--disable-timesync"

Then I shut down FreeBSD.

In order to make X use the vboxvideo driver, I had to change a display setting through the VirtualBox GUI on the host: I changed the "Graphics Controller" (Left click on the VM list > Settings > Display > Graphics Controller) from "VMSVGA" to "VBoxSVGA" (I ignore "Invalid settings detected" warning that VirtualBox gives about this change).

After configuring all the above, I booted FreeBSD, logged-in, and started X ( startx). However, the screen size is only 800x600 even though View > Auto-size Guest Display is enabled. That is the problem. The screen is not resizing. What did I do wrong?

After starting X, xrandr outputs:

Code:
Screen 0: minimum 64 x 64, current 800 x 600, maximum 32766 x 32766
VGA-0 connected primary 800x600+0+0 0mm x 0mm
   1366x660      60.00 +
   2560x1600     60.00
   2560x1440     60.00
   2048x1536     60.00
   1920x1600     60.00
   1920x1080     60.00
   1600x1200     60.00
   1680x1050     60.00
   1400x1050     60.00
   1280x1024     60.00
   1024x768      60.00
   800x600       60.00*
   640x480       60.00

I have also attached Xorg.0.log and Xorg.1.log to this post.

The host is Ubuntu 20.04 running VirtualBox 6.1.16.

I am new to FreeBSD, and I hope there is a simple solution to this problem. Thank you in advance.
 

Attachments

  • Xorg.0.log.txt
    19.7 KB · Views: 28
  • Xorg.1.log.txt
    20.8 KB · Views: 27
Last edited:

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 11,239
Messages: 37,412

Is the vboxguest.ko kernel module loaded? It might fail to load because the package was built for 12.1.
 
OP
M

mr123

New Member


Messages: 12

Is the vboxguest.ko kernel module loaded? It might fail to load because the package was built for 12.1.
Yes, it is loaded.

kldstat shows:

Code:
Id Refs Address                Size Name
1    9 0xffffffff80200000  227ad00 kernel
2    2 0xffffffff82719000    2eb93 vboxguest.ko
3    1 0xffffffff82748000     2698 intpm.ko
4    1 0xffffffff8274b000      b40 smbus.ko
5    1 0xffffffff8274c000    1fb83 vboxvfs.ko

That is after starting X. Before starting X, the list is the same, except that vboxvfs.ko is absent.
 

Emrion

Aspiring Daemon

Reaction score: 178
Messages: 623

I use vboxadditions on a VM 12-2-RELEASE, all up to date and I have no problem.

Can't you set the resolution with xrandr --size 1280x1024 for instance?
 
OP
M

mr123

New Member


Messages: 12

I use vboxadditions on a VM 12-2-RELEASE, all up to date and I have no problem.

Can't you set the resolution with xrandr --size 1280x1024 for instance?

xrandr --size 1280x1024 does change the size of the screen. Thank you for this tip. But is there no automatic way to do it? I would prefer to have VirtualBox's "Auto-size Guest Display" do what it is supposed to do.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 11,239
Messages: 37,412

Run VBoxClient --display.
 

Emrion

Aspiring Daemon

Reaction score: 178
Messages: 623

Personnaly, I use something like:
/usr/local/etc/X11/xorg.conf.d/screen-resolution.conf

Code:
Section "Screen"
    Identifier "Screen0"
    Device "Card0"
    SubSection "Display"
        Modes "1024x768"
    EndSubSection
EndSection

You have just to create a file ending by .conf in /usr/local/etc/X11/xorg.conf.d/ with this content.
 
OP
M

mr123

New Member


Messages: 12

Run VBoxClient --display.
This appears to solve the problem. Thank you.

To solve the problem "permanently", I added VBoxClient --display somewhere near the end of my ~/.xinitrc. Is that an appropriate solution?
 
Last edited:
OP
M

mr123

New Member


Messages: 12

Personnaly, I use something like:
/usr/local/etc/X11/xorg.conf.d/screen-resolution.conf

Code:
Section "Screen"
    Identifier "Screen0"
    Device "Card0"
    SubSection "Display"
        Modes "1024x768"
    EndSubSection
EndSection

You have just to create a file ending by .conf in /usr/local/etc/X11/xorg.conf.d/ with this content.
Doesn't this solution require you to know the size of the display in advance?

SirDice's solution appears to solve the problem.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 11,239
Messages: 37,412

To solve the problem "permanently", I added VBoxClient --display somewhere near the end of my ~/.xinitrc. It that an appropriate solution?
Yep, I have that too. You may want to add some others too; VBoxClient --clipboard for example. Look at VBoxClient --help.
 

Emrion

Aspiring Daemon

Reaction score: 178
Messages: 623

Yes, in my case I set the resolution to the whole screen and never change it. Glad your problem is solved.
 

Bucky

Member

Reaction score: 10
Messages: 51

Run VBoxClient --display.

Hi. Windows 10 host, VirtualBox 6.1.18 & FreeBSD 12.2 guest. VirtualBox additions installed along with X and whatever else required. Necessary modules loaded. When I type the above command I get:

VBoxClient error: unrecognized option '--display'

When I type VBoxClient --help there is no option '--display' shown.

I'm puzzled since this thread is pretty recent yet my recently installed VM doesn't seem to allow VBoxClient --display. I can manually resize the VM window with xrandr -s <width>x<height> but that doesn't fix the greyed-out "Auto Resize Guest Display" option in View on the VM's window.

Thoughts?
 

Emrion

Aspiring Daemon

Reaction score: 178
Messages: 623

Hi. Windows 10 host, VirtualBox 6.1.18 & FreeBSD 12.2 guest. VirtualBox additions installed along with X and whatever else required. Necessary modules loaded. When I type the above command I get:

VBoxClient error: unrecognized option '--display'

When I type VBoxClient --help there is no option '--display' shown.

I'm puzzled since this thread is pretty recent yet my recently installed VM doesn't seem to allow VBoxClient --display. I can manually resize the VM window with xrandr -s <width>x<height> but that doesn't fix the greyed-out "Auto Resize Guest Display" option in View on the VM's window.

Thoughts?
Let me guess... You have virtualbox-ose-additions-6.1.18.
Actually, there is no more --display option. You had it in the previous version 5.2.44_3 (you can get it by installing virtualbox-ose-additions-legacy).
 

Bucky

Member

Reaction score: 10
Messages: 51

Let me guess... You have virtualbox-ose-additions-6.1.18.
Actually, there is no more --display option. You had it in the previous version 5.2.44_3 (you can get it by installing virtualbox-ose-additions-legacy).
Indeed, I didn't install the legacy version of virtualbox-ose-additions.

Anything wrong with simply using xrandr -s <width>x<height> and adding it to the ~/.xinitrc file? Question was asked above and Sir Dice seems to be good with it. You, too?
 

Bucky

Member

Reaction score: 10
Messages: 51

Answered my own question. Added xrandr -s ... to /usr/local/etc/X11/xinit/xinitrc file, rebooted and the screen autosized for me. Happiness. Thanks!
 
OP
M

mr123

New Member


Messages: 12

Answered my own question. Added xrandr -s ... to /usr/local/etc/X11/xinit/xinitrc file, rebooted and the screen autosized for me. Happiness. Thanks!

But doesn't this require you to hardcode the width and height of your display? Does auto-resize work when using the 'xrandr -s ...' solution?
 

Bucky

Member

Reaction score: 10
Messages: 51

But doesn't this require you to hardcode the width and height of your display? Does auto-resize work when using the 'xrandr -s ...' solution?
Yes. No.

I'm still fritzing with Virtualbox v6.1.18 & the latest ose-additions for FreeBSD. My experimental results are all over the place. When I install some ready-made desktops, the auto-resize works, but those installed desktops revert back to FreeBSD v12.x and an earlier version of the additions. When I try to install by hand into FreeBSD v13.0, the screen is black (unless I ssh into the VM and invoke startx from there, then the screen looks like a normal desktop) and the auto-resize is greyed out. But in some cases, the CPU usage goes to 100% and everything grinds to a halt.

Virtualbox v6.1.18 will not allow me to use any video driver except the VMSVGA. If I try to change it to something else, VBox complains and simply changes it back.

So I'm still scratching my head about what I'm seeing and why. Very slow going... If I solve it, I'll probably post in the "how-to" section of the forum. Don't hold your breath.
 

joel.bodenmann

Active Member

Reaction score: 35
Messages: 169

I am also dealing with this issue right now:
- Windows 10 host
- VirtualBox 6.1.18
- FreeBSD 13.0-RELEASE guest
- emulators/virtualbox-ose-additions installed on the guest
- VirtualBox configuration:
- Graphics controller: VMSVGA
- 256 MB video memory
- 3D enabled

One of the problems I am running into is that xrandr reports a maximum resolution of 1024x768. I could not figure out how to increase this limit. I could not spot any corresponding setting in the VirtualBox configuration.

dmesg reports:
Code:
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff pnpid PNP0900 on isa0

vboxguest.ko is loaded.
 

Bucky

Member

Reaction score: 10
Messages: 51

How did you get 256MiB of video memory in VirtualBox? Mine only goes to 128MiB.

Buried deep in another thread was a comment that in a FreeBSD guest, xrandr will offer up a lot more screen resolutions to choose from if you install 'xf86-video-vmware'. After doing that I got 30ish some choices.
 

obsigna

Daemon

Reaction score: 843
Messages: 1,244

How did you get 256MiB of video memory in VirtualBox? Mine only goes to 128MiB.
On the command line of the VirtualBox host, you want to submit:
VBoxManage modifyvm FreeBSD --vram 256

This assumes, that the name of the virtual machine is ‚FreeBSD‘, if you named it differently, then use the other name.
 

joel.bodenmann

Active Member

Reaction score: 35
Messages: 169

How did you get 256MiB of video memory in VirtualBox? Mine only goes to 128MiB.
I didn't do anything special. Just installed VirtualBox and it allows me to set the video memory from 0MB to 256MB.
The host machine has an nVidia Quadro P5000 with 16GB dedicated GPU RAM. Not sure whether that is the limiting factor here.

Buried deep in another thread was a comment that in a FreeBSD guest, xrandr will offer up a lot more screen resolutions to choose from if you install 'xf86-video-vmware'. After doing that I got 30ish some choices.
I can confirm that this works on my side too. After installing x11-drivers/xf86-video-vmware running xrandr reports back many more resolutions.

Unfortunately, the auto-resizing is still not working at all.
What I noticed: When running VBoxClient-all (from an X11-session), the system becomes unresponsive (GUI doesn't react anymore).
 

T-Daemon

Daemon

Reaction score: 731
Messages: 1,537

VirtualBox doesn't allow me to use those with 3D enabled (which I need/want).
Are you sure 3D is in the FreeBSD guest available?

On my system (FreeBSD 12.2 host, 13.0 guest, VirtualBox 6.1.18) if the guest's graphics controller is set to VMSVGA xorg doesn't start at all with the vboxvideo driver provided by emulators/virtualbox-ose-additions, version 6.1.18, only with VBoxVGA or VBoxSVGA.

Running a test on my system, if x11-drivers/xf86-video-vmware in the guest is installed, with the default set VMSVGA graphics controller (and 3D), the vmware driver is loaded automatic.

Regarding 3D, inspecting /var/log/Xorg.0.log the driver reports:
Code:
[    24.119] (EE) vmware(0): Failed to open drm.
[    24.119] (WW) vmware(0): Disabling 3D support.
[    24.119] (WW) vmware(0): Disabling Render Acceleration.
[    24.119] (WW) vmware(0): Disabling RandR12+ support.

From vmware(4) driver's manual, 3D acceleration seems to be available on Linux only.

Check the Xorg log. With 3D disabled, you might set as well VBoxSVGA as graphics controller and unset 3D. VBoxClient-all or VBoxClient --vmsvga alone works well to provide auto-resize (also seamless), no system freeze. I suspect the system freezes because of the vmware driver.

The vboxdriver is picked up automatic if the graphics controller is set to VBoxSVGA or VBoxVGA, no additional configuration is necessary.
 

joel.bodenmann

Active Member

Reaction score: 35
Messages: 169

I tried this right now:
Executing xrandr reveals a decent set of resolutions.
Also auto-resizing is working.

However, the resizing process is damn slow. Resizing takes about 15 seconds (no joke!).
This is my first time working with VirtualBox. So far I worked with VMware Workstation and Hyper-V (and of course trusty bhyve on FreeBSD, but that doesn't apply here). I understand that those are proprietary solutions but I can't imagine that VirtualBox resizing with a FreeBSD guest would be that slow. What is the limiting factor here?
 
Top