Ubuntu – How to avoid the reinstallation of VirtualBox Guest Additions on every kernel upgrade of guest Ubuntu to have clipboard and draganddrop

18.04clipboardkernelvirtualboxvirtualization

I'm running Ubuntu 16.04 LTS host with VirtualBox 5.1.38 from Oracle's repository.

I have Ubuntu 18.04.1 LTS guest on this host.
Inside the guest I have installed all needed packages to get Guest Additions (GA) installed successfully – build-essential, dkms, linux-headers-generic.
Then I insert VBoxGuestAdditions_5.1.38.iso to virtual VM drive and successfully installed it with its autorun prompt.
Then after reboot I see that all GA functionality work as expected, so I have all necessary processes:

$ uname -r
4.15.0-32-generic

$ sudo ps ax | grep -i vbox
  442 ?        I<     0:00 [iprt-VBoxWQueue]
  822 ?        Sl     0:00 /usr/sbin/VBoxService --pidfile /var/run/vboxadd-service.sh
 1393 ?        S      0:00 /usr/bin/VBoxClient --clipboard
 1394 ?        Sl     0:00 /usr/bin/VBoxClient --clipboard
 1398 ?        S      0:00 /usr/bin/VBoxClient --checkhostversion
 1399 ?        S      0:00 /usr/bin/VBoxClient --checkhostversion
 1404 ?        S      0:00 /usr/bin/VBoxClient --display
 1405 ?        S      0:00 /usr/bin/VBoxClient --display
 1412 ?        S      0:00 /usr/bin/VBoxClient --seamless
 1413 ?        Sl     0:00 /usr/bin/VBoxClient --seamless
 1420 ?        S      0:00 /usr/bin/VBoxClient --draganddrop
 1421 ?        Sl     0:00 /usr/bin/VBoxClient --draganddrop

But after next kernel upgrade (as simple as sudo apt update && sudo apt dist-upgrade) I get the following logs

$ cat /var/log/syslog | grep -i vboxadd
Jan  9 12:01:45 bionic vboxadd.sh: Building the VirtualBox Guest Additions kernel modules.
Jan  9 12:01:45 bionic vboxadd.sh: Building the main Guest Additions module.
Jan  9 12:02:17 bionic vboxadd.sh: .
Jan  9 12:02:17 bionic vboxadd.sh: Building the shared folder support module.
Jan  9 12:02:24 bionic vboxadd.sh: .
Jan  9 12:02:24 bionic vboxadd.sh: Building the graphics driver module.
Jan  9 12:02:32 bionic vboxadd.sh: .
Jan  9 12:02:32 bionic vboxadd.sh: Doing non-kernel setup of the Guest Additions.

and after reboot I see that clipboard and dragandrop are switched off:

$ uname -r
4.15.0-43-generic

$ sudo ps ax | grep -i vbox
  428 ?        I<     0:00 [iprt-VBoxWQueue]
 1404 ?        S      0:00 /usr/bin/VBoxClient --checkhostversion
 1405 ?        S      0:00 /usr/bin/VBoxClient --checkhostversion
 1409 ?        S      0:00 /usr/bin/VBoxClient --display
 1410 ?        S      0:00 /usr/bin/VBoxClient --display
 1419 ?        S      0:00 /usr/bin/VBoxClient --seamless
 1912 ?        S      0:00 /usr/bin/VBoxClient --seamless

Why does this happen? How to avoid GA re-installation from iso file?

I understand that this problem may be a bit complex, but Ubuntu newbies may expect that it works on VirtualBox without issues, so please do not close this question as off-topic. Kernel updates are released very often so it may become a bit annoying.

Best Answer

Try to remove Guest Additions, installed using the ISO file provided by the host with

sudo /opt/VBoxGuestAdditions-5.1.38/uninstall.sh

and then install the following deb-packages directly available in your guest Ubuntu

sudo apt install virtualbox-guest-x11 virtualbox-guest-utils

This should give you the same features than installing manually the guest addition.

Related Question