I had the same problem and solved it by
Purging Virtualbox:
sudo apt-get purge virtualbox virtualbox-dkms virtualbox-ose-qt virtualbox-qt
I then reinstalled;
sudo apt-get install virtualbox virtualbox-dkms virtualbox-ose virtualbox
and noticed:
dependency problems prevent configuration of virtualbox-ose:
virtualbox-ose depends on virtualbox; however:
Package virtualbox is not configured yet.
Package virtualbox-4.0 which provides virtualbox is not installed.
so I tried installing virtualbox-4.0;
sudo apt-get install virtualbox-4.0
That worked and pulled in the correct VirtualBox DKMS kernel modules.
I then had to download and install the correct version of the extension pack Oracle_VM_VirtualBox_Extension_Pack-4.0.16-75491.vbox-extpack
.
That worked, and I now have a fully functioning Virtualbox instance.
The way to do this is to write a script to start your VM, wait until it terminates, and then issue the shut-down command.
Create a folder bin
in your home folder (if it does not exist already).
Now create a file with the following contents. Let's call it win7vmshutdown
, and save it in your bin
folder.
#!/bin/bash
VBoxManage startvm 'Win7' # Start the VM.
sleep 10s # Give it time to start up.
while pgrep VirtualBox >/dev/null # As long as the VM is running...
do
sleep 5s # Wait a bit before trying again.
done
gnome-session-quit --power-off # Issue the command to shut down.
Make the script executable; enter the following in a Terminal.
chmod +x ~/bin/win7vmshutdown
In your Startup Applications, remove the VBoxManage ...
command and replace it with win7vmshutdown
.
The shutdown command will prompt you for shutdown; if you don't answer, it will shut down in 60 seconds. This gives you time to interrupt the shutdown in case of unexpected problems.
Reboot your computer to test.
You said:
Also, when virtual box starts up automatically, Ubuntu's desktop should not be visible.
To do that, you want to run your VM in full-screen. Install the Guest Additions in your VM, reboot it, and run it full-screen.
Best Answer
In case you really need to shutdown while a virtual machine in Virtual Box is running you could define your own script for a manual shutdown where you place a command to save the machine state before the shutdown process starts:
Alternatively you could also generate a script that always runs at shutdown.