Ubuntu – Ubuntu 18.04 in VM: Desktop does not restore window size

18.04gnomevirtualbox

I run Ubuntu as Guest OS in a Windows VirtualBox VM Host. In the existing, up-to-date VB, I have just moved from 17.04 to 18.04 by creating a new VM/.vdi from scratch (including Guest Additions).

Previously, whatever I resized the whole VM/desktop window to was remembered across reboots, which is obviously desirable.

Under 18.04 (which, remember is now using GNOME instead of Unity, if that is relevant) this does not happen. The resizing is fine, but when I reboot it reverts to some small-ish size.

I imagine this is a Guest Ubuntu issue, not a Host VirtualBox one, so I don't think trying to ask the VB people will help any. Obviously I have installed Guest Additions, and do have View > Auto-resize Guest Display enabled.

Is this happening to other VirtualBox+18.04 users? Am I missing some setting to tell Ubuntu/GNOME to restore window/desktop size?

Best Answer

It worked for me (update Vbox 6.0):

  • Ubuntu version: 18.04.1 x64 LTS Bionic Beaver
  • Desktop: Mate Desktop Environment 1.20.1 with Marco (GPU composition with Compton)
  • Kernel version: 4.15.0-42-generic
  • VirtualBox version: v6.0.0.0 r127566 (qt5.9.5)
  • Oracle VM VirtualBox Extensions version: v6.0.0.0 r127566
  • OpenGL version string: 3.0 Mesa 18.2.2

Note: Check OpenGL with command:

glxinfo | grep "OpenGL version"

Make sure you have Mesa installed:

sudo apt-add-repository -y ppa:ubuntu-x-swat/updates && sudo apt dist-upgrade

Recomended before start:

For security reason create new folder (example: myvm) in a partition mounted (not directly in /Home or /root) or into an external disk and save only VM disk (if you have anyone without VM folder)

Important PPA:

Make sure you have the Virtualbox PPA. If you do not have it, open the terminal and execute:

~$ echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
~$ wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -

Bash Script

Save this script in home (example: vboxinstall.sh)

~$ chmod +x vboxinstall.sh

And run (without "sudo")

~$ ./vboxinstall.sh

Content:

#!/bin/bash
while true; do
read -p "Do you want to install Virtualbox? (y/n)" answer
case $answer in
  [Yy]* )
# execute command yes
echo "Virtualbox Pack setup..."
echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
vboxmanage list runningvms | sed -r 's/.*\{(.*)\}/\1/' | xargs -L1 -I {} VBoxManage controlvm {} savestate
sudo killall vboxwebsrv
sudo pkill virtualbox
sudo systemctl stop vboxweb-service.service
export VBOX_VER=`VBoxManage --version|awk -Fr '{print $1}'`
sudo VBoxManage extpack uninstall "Oracle VM VirtualBox Extension Pack"
sudo apt -y autoremove --purge virtualbox*
sudo rm -rf /etc/vbox /opt/VirtualBox /usr/lib/virtualbox ~/.config/VirtualBox
sudo apt update && sudo apt autoclean && sudo apt clean && sudo apt autoremove && sudo apt-get -f -y install && sudo apt-get -y dist-upgrade && sudo apt -y --fix-broken install
sudo apt -y install virtualbox-6.0 bridge-utils
sudo dpkg --configure -a && sudo apt-get -f -y install
wget -c http://download.virtualbox.org/virtualbox/$VBOX_VER/Oracle_VM_VirtualBox_Extension_Pack-$VBOX_VER.vbox-extpack
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-$VBOX_VER.vbox-extpack
# sudo adduser $USER vboxusers
sudo usermod -a -G vboxusers $USER
echo "check groups $USER"
sudo systemctl enable vboxweb-service
sudo systemctl start vboxweb-service
sudo update-grub
sudo vboxconfig
sudo usermod -aG vboxsf ($whoami) &> /dev/null
echo "Done"
    break;;
        [Nn]* )
    # execute command no
        break;;
    * ) echo; echo "Select: YES (y) or NO (n)";;
  esac
done

Note: This script removes the previous virtualbox (and its folders), and installs it again

Create a new vm with your vm-disk (previously saved)

Do not select:

  • Extended Feactures (Enable PAE/NX)
  • Enable EFI (special OSes only)
  • Hardware Clock in UTC Time
  • Enable 3D Acceleration
  • Enable 2D Video Aceleration

Select:

  • Video memory 128 Mb
  • Shared Clipboard and Dra'nDrop Bidirectional
  • Chipset: PIIX3
  • Pointing Device: USB Tablet
  • Enable USB Controller: USB 2.0 (EHCI) Controller

Note: To select USB3.0 (xHCI) Controller you must have Intel USB 3.0 Drivers

Run VM:

  1. You must run vm for the first time with option: "Detachable Start" enter image description here

Note: Only for Mate Desktop Environment 1.20.1 (check with command: ~$ mate-about), if when running the VM your desktop bar is blocked (you can not access the menu and other functions), ignore it. When restarting the PC it will be fixed. However, if you need urgent access to your application menu, open the terminal and execute:

~$ killall mate-panel
  1. Install Virtualbox Guest Additions in VM (without 3D) and restart the vm
  2. Restart PC/Laptop and now you can run your VM with "Normal Start" or another option.

Important:

For PC/laptop/server with Intel Chipset or Graphic Card, read HERE

For previous versions of Ubuntu 18.04.x with Intel Graphic Card, see HERE

See discussion on this problem HERE