Ubuntu 20.04 guest freeze at resize

Discussions about using Linux guests in VirtualBox.
Post Reply
myroad
Posts: 4
Joined: 7. May 2021, 11:44

Ubuntu 20.04 guest freeze at resize

Post by myroad »

Hi,

Here is my environment:
Host:
Windows 10 2004 "Version 10.0.19041 Build 19041"
Processor Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz, 2208 Mhz, 6 Core(s), 12 Logical Processor(s)
Installed Physical Memory (RAM) 16.0 GB
No dedicated GPU
Vagrant 2.2.16 (latest)
* vagrant-persistent-storage (0.0.49, global) (latest)
* vagrant-vbguest (0.29.0, global) (latest)
Virtualbox 6.1.20

Guest:
Ubuntu 20.04 LTS with default ubuntu-desktop package
Guest Additions 6.1.20
VMSVGA 3D acceleration enabled
Any other details in joined Vagrantfile

Symptoms:
With VMSVGA, I can start and see the desktop environment. glxinfo shows direct rendering true. But the moment I resize, nothing change, it freezes. I can only see the mouse cursor moving but no click possible. I think this is related to ticket 19496.

Because I cannot add the Vagrantfile (form says "The extension is not allowed."), here is the content:

Code: Select all

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/focal64"
  config.vm.box_version = "20210503.0.0"

  config.vm.box_check_update = false

  config.vm.provision "bootstrap", type: "shell" do |s|
    s.inline= <<-'SHELL'
    set -x -e
    cd /root

    aptInstall() {
        echo "$(date --iso-8601=s) Installing " "$@" | sudo tee -a /var/log/vagrant_apt.log
        ( time sudo DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt install "$@" -y 2>&1 | sudo tee -a /var/log/vagrant_apt.log ) >/dev/null
    }

    installDesktop() {
        if ! ( dpkg -l ubuntu-desktop ) &>/dev/null ; then
            sudo apt update -y
            # Doing install with no install recommends leads to black screen at start with a flickering cursor.
            #aptInstall --no-install-recommends ubuntu-desktop
            aptInstall ubuntu-desktop
            #aptInstall lubuntu-desktop
            # Warning: enable autologin leads to black screen in Virtualbox.
            #if ! grep --regex "^AutomaticLogin" /etc/gdm3/custom.conf >/dev/null ; then
                #sudo sed /etc/gdm3/custom.conf -i -e 's,\[daemon\],\[daemon\]\nAutomaticLoginEnable=True\nAutomaticLogin=vagrant,g'
            #fi
            if ! grep --regex "^WaylandEnable" /etc/gdm3/custom.conf >/dev/null ; then
                sudo sed /etc/gdm3/custom.conf -i -e 's,\[daemon\],\[daemon\]\nWaylandEnable=false,g'
                # See ticket 19496#comment:47
                echo 'export XDG_SESSION_TYPE="x11"'>/etc/profile.d/50-xdgx11.sh
            fi
        fi
        # For terminal AZERTY.
        sudo localectl --no-convert set-x11-keymap fr
        sudo loadkeys fr
    }

    fixMultipathd() {
        if ! grep VBOX /etc/multipath.conf >/dev/null ; then
            cat <<EOF | sudo tee -a /etc/multipath.conf
blacklist {
  device {
    vendor "VBOX"
    product "HARDDISK"
  }
}
EOF
            sudo systemctl restart multipathd.service
        fi
    }

    fixMultipathd
    installDesktop

    sudo usermod -a -G sudo,vboxsf vagrant

    sudo apt-get autoremove -y

    echo "[INFO] $0 $(id -nu): End of bootstrap shell $(date --iso-8601=s)."

    if test -f /var/run/reboot-required ; then
      echo "Restart needed: /var/run/reboot-required exist."
      sudo cat /var/run/reboot-required
      sudo reboot
    fi
  SHELL
  end

  config.vbguest.auto_update = true

  config.vm.provider "virtualbox" do |v|
    v.gui = false
    v.memory = 4096
    v.cpus = 4
    # Set the video memory to 128Mb, seems to be necessary to avoid black screen.
    v.customize ["modifyvm", :id, "--vram", "128"]
    v.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]
    v.customize ["modifyvm", :id, "--accelerate3d", "on"]
  end
end

scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Ubuntu 20.04 guest freeze at resize

Post by scottgus1 »

We don't grok Vagrant here, you could ask them to help, or you could get the VM running directly in Virtualbox without using Vagrant, then see what happens. If the VM does the same problem when running without being controlled by Vagrant, then do this:

Start the VM from full power off, not save-state. Run until you see the problem happen, then shut down the VM from within the VM OS if possible. If not possible, close the Virtualbox window for the VM with the Power Off option set.

Please right-click the VM in the main Virtualbox window's VM list, choose Show Log. Save the far left tab's log, zip the log file, and post the zip file, using the forum's Upload Attachment tab.
myroad
Posts: 4
Joined: 7. May 2021, 11:44

Re: Ubuntu 20.04 guest freeze at resize

Post by myroad »

scottgus1 wrote:We don't grok Vagrant here, you could ask them to help, or you could get the VM running directly in Virtualbox without using Vagrant, then see what happens. If the VM does the same problem when running without being controlled by Vagrant, then do this:
Yes it does. Vagrant also allows everyone to reproduce the same issue easily.
scottgus1 wrote: Start the VM from full power off, not save-state. Run until you see the problem happen, then shut down the VM from within the VM OS if possible. If not possible, close the Virtualbox window for the VM with the Power Off option set.

Please right-click the VM in the main Virtualbox window's VM list, choose Show Log. Save the far left tab's log, zip the log file, and post the zip file, using the forum's Upload Attachment tab.
Done. I had to shutdown gracefully by ssh.

Code: Select all

vagrant@ubuntu-focal:~$ lsmod | grep vboxguest
vboxguest             348160  6 vboxsf
vagrant@ubuntu-focal:~$ ls /opt
VBoxGuestAdditions-6.1.22
Attachments
UbuntuResizeError2_default_1620412505852_98454-2021-05-07-21-08-37.zip
(33.62 KiB) Downloaded 13 times
myroad
Posts: 4
Joined: 7. May 2021, 11:44

Re: Ubuntu 20.04 guest freeze at resize

Post by myroad »

Found the root cause and fix. Created a bug in Ubuntu Vagrant box: https://bugs.launchpad.net/cloud-images/+bug/1928563
Recommended solution:
1. either install missing drivers:
sudo apt install linux-image-generic
2. or move from Canonical official Ubuntu boxes to better Bento official boxes (recommended by Vagrant). Eg: https://app.vagrantup.com/bento/boxes/u ... 02012.23.0

This topic is solved.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Ubuntu 20.04 guest freeze at resize

Post by scottgus1 »

Glad you found a solution! I forgot about coming back to this one, sorry about that.

One thing I noticed in the log:
00:00:00.541723 Executable: C:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe
With a 'headless' VM there is no Virtualbox window to resize, unless you 'Show' the VM afterward. Were you resizing by the VM OS's display size controls?

Your VM does have Guest Additions installed, which ought to have supported resizing the VM window. The presence of GAs was what I was looking for in the log.
myroad
Posts: 4
Joined: 7. May 2021, 11:44

Re: Ubuntu 20.04 guest freeze at resize

Post by myroad »

scottgus1 wrote:Glad you found a solution! I forgot about coming back to this one, sorry about that.

One thing I noticed in the log:
00:00:00.541723 Executable: C:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe
With a 'headless' VM there is no Virtualbox window to resize, unless you 'Show' the VM afterward. Were you resizing by the VM OS's display size controls?
I like to be able to hide and display my VM window when I want. I tested both with and without headless, and the resize both with the menu and with the mouse, multiple times to reproduce.
Your VM does have Guest Additions installed, which ought to have supported resizing the VM window. The presence of GAs was what I was looking for in the log.
Yes, as I said before, lots of module was missing (voluntarily I guess) from the Canonical Ubuntu image, thus guest additions was not enough.
Post Reply