Ubuntu – install virtualbox guest addition terminal

command lineguest-additionsvirtualbox

I would like to install Virtualbox guest addition using the terminal. Because that is most easy to reproduce and to document. On the server I have Ubuntu 12.04.2. LTS I have Virtualbox 4.3.16

I have done so successfully in the recent past using :

bash
sudo apt-get update
sudo apt-get install build-essential linux-headers-$(uname -r)
sudo apt-get install virtualbox-guest-x11

Found on How do I install Guest Additions in a VirtualBox VM?

now I repeat doing so. Executing :

modinfo vboxguest

returns :

bernard@bernard-vbox2:~$ modinfo vboxguest
filename:       /lib/modules/3.11.0-22-generic/updates/dkms/vboxguest.ko
version:        4.2.16_Ubuntu
license:        GPL
description:    Oracle VM VirtualBox Guest Additions for Linux Module
author:         Oracle Corporation
srcversion:     A7E3594189A565BBB270EDB
alias:          pci:v000080EEd0000CAFEsv00000000sd00000000bc*sc*i*
depends:        
vermagic:       3.11.0-22-generic SMP mod_unload modversions 
bernard@bernard-vbox2:~$ 

See virtualbox guestaddition version from VM client

All seems to work well, but when reboot I have a login screen and I seem to log in. But the screen change to black, and the system hang. Even the "send shutdown signal" has no effect. Only "power of machine" can stop the VM. Luckely I made a snapshot before installing Virtualbox guest additions. I tried twice, but with the identical result.

In both situation I had the same Ubuntu server version and Virtualbox server version. VM Ubuntu client is now 13.10 I do not not know the (possible different) previous VM ubuntu version.

Followed Sylvain Pineau advise with result :

DKMS: install completed.     
Setting up virtualbox-guest-x11 (4.2.16-dfsg-3ubuntu0.1) ...

Configuration file `/etc/X11/Xsession.d/98vboxadd-xclient'
 ==> File on system created by you or by a script.
 ==> File also in package provided by package maintainer.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.

Best Answer

Try to install the following packages in your VM:

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

Restart the VM and you should avoid the black screen.