Table of Contents
VirtualBox
VirtualBox is an advanced, cross-platform x86 virtualization software. It enables you to run additional Guest operating systems on your Host operating system.
Until VirtualBox version 4.0, there were two different versions of VirtualBox:
- The “Personal Use and Evaluation License (PUEL)” edition. More features but not Open Source but free for personal/academic use and evaluation.
- The “Open-Source-Edition (OSE)” with less features but released under the GPL.
This has changed with VirtualBox 4.0. The differentiation between “Personal Use and Evaluation License (PUEL)” and “Open-Source-Edition (OSE)” was abolished and an extension interface was introduced instead.
The basic VirtualBox 4 package is completely Open Source and you can add missing (and eventually unfree) features by installing extensions. E.g. to get the features of the former PUEL-edition you have to install the “Oracle VM VirtualBox Extension Pack”.
Installation
Ubuntu
You may have a look at dkms before installing VirtualBox.
10.04 Lucid and above
Simply add the repository Oracle provides for the PUEL edition:
deb http://download.virtualbox.org/virtualbox/debian codename contrib
Replace codename
with the lowercase codename of the release you are using (e.g. “karmic”, “jaunty”, “maverick”…).
You need the following key to authenticate the new repository:
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 98AB5139
Update your sources:
sudo apt-get update
Now you can install the following package(s):
virtualbox-4.0
– for VirtualBox 4.0.x
Every user who has to be able to work with VirtualBox has to be a member of the vboxusers
group. You may use
sudo adduser "$USER" vboxusers
to add the currently logged in user to the group. You need to log off and in again for the changes to take effect.
You have to install the “Oracle VM VirtualBox Extension Pack” if you need support for USB 2.0 devices, VirtualBox RDP and PXE boot for Intel cards.. To install the Oracle_VM_VirtualBox_Extension_Pack-<version>.vbox-extpack
extension package, download the file and double-click on it afterwards. The VirtualBox Manager will guide you through the required steps.
Windows
XP and above
Simply download the Windows installer and execute it with administrator privileges.
You have to install the “Oracle VM VirtualBox Extension Pack” if you need support for USB 2.0 devices, VirtualBox RDP and PXE boot for Intel cards.. To install the Oracle_VM_VirtualBox_Extension_Pack-<version>.vbox-extpack
extension package, download the file and double-click on it afterwards. The VirtualBox Manager will guide you through the required steps.
Update
Ubuntu
If you are using the repository, you will get all security and other updates for your used major release automatically (→ 3.1.0 will be updated to 3.1.x but not to 3.2.0 or 4.0). If there is a new major release and you want to use it, you have to remove your installed VirtualBox first and install the new version afterwards. To do so, simply remove your currently used package via sudo apt-get remove virtualbox-<version>
(this works without loosing data because apt-get remove
preserves your config without the --purge
parameter):
virtualbox-3.2
– for VirtualBox 3.2.x PUELvirtualbox-3.1
– for VirtualBox 3.1.x PUELvirtualbox-3.0
– for VirtualBox 3.0.x PUELvirtualbox-2.1
– for VirtualBox 2.1.x PUELvirtualbox
– for VirtualBox 1.6.x PUELvirtualbox-ose
– for VirtualBox Open Source Edition (OSE). You may also want to remove the optional packagesvirtualbox-ose-dkms
andvirtualbox-ose-guest-dkms
if installed
The VirtualBox repository has been moved from non-free
to contrib
with 4.0, so please adjust your repository settings. Example: replace deb http://download.virtualbox.org/virtualbox/debian maverick non-free
with deb http://download.virtualbox.org/virtualbox/debian maverick contrib
on Ubuntu 10.10.
Windows
Simply download the actual Windows installer and execute it with administrator privileges. The installer is intelligent enough to detect and update your existing installation.
Installation, Guest Additions
Debian 5.0 Lenny Guest
- Check if you may want to install Dynamic Kernel Module Support (DKMS) before going on.
- Update your system:
su apt-get update apt-get upgrade
- Make sure you got everything to compile kernel modules:
apt-get install build-essential module-assistant
- Perpare system to create kernel modules:
m-a
Choose “PREPARE” within the config dialogue.
- Choose “Devices→Install Guest Additions…” at the VM window. This mounts the Guest Additions Installation ISO.
- Install Guest Additions:
sh /media/cdrom/VBoxLinuxAdditions-<architektur>.run
Tips and trick
VirtualBox provides command line tools
The commands VBoxManage
and VBoxHeadless
may be very useful if you have to automatize some task, e.g.:
VBoxManage list vms
VBoxManage list runningvms
VBoxManage controlvm "VM Name" acpipowerbutton
VBoxHeadless -s "VM Name" &
Have a look at their man pages, it is really worth it.
All about VDIs (resize, performance etc.)
…can be found at http://forums.virtualbox.org/viewtopic.php?p=29276
Access "locahost" of the host from the guest
The guest OS is able to reach the host's localhost
using the IP 10.0.2.2
Shrink/clean up a dynamic hard disk
After using the system for a while, most dynamic hard disks are much larger than they have to be. The reason is simple: the guest marks deleted files as deleted to deallocate the space they used, but it does not overwrite the real data. You have to reset/zeroize the free disk space to be able to shrink the .vdi
afterwards:
- On a MS Windows guest: defrag your filesystem and use the MS tool SDelete afterwards:
sdelete -c <drive>
- On a Linux guest: Use a tool like
zerofree
.
After cleaning up, shut down the guest system and use
VBoxManage modifyvdi <target-file>.vdi
to shrink the dynamic hard disk.
Use a Shared Folder to exchange files between host and guest
- In general, make sure that the name of the Shared Folder doesn't contain white spaces and non-ASCII chars. Keep the name as simple as possible to prevent compatibility problems. And have a look at the Virtuapedia article about Shared Folders if you need more information than provided here.
- On a MS Windows guest, make sure you installed the Guest Additions properly. Open the VM Settings and go to Shared Folders to create a Shared Folder, the GUI should be self-explanatory, I use
host-guest-share
as example. The guest is able to access the folder via network using\\vboxsvr
as SMB host. You should be able to browse the directory via Windows Explorer. If some networking services are disabled or you want to create a persistent network drive, usenet use z: "\\vboxsvr\host-guest-share" /persistent:yes
- On a Linux guest, make sure you installed the Guest Additions properly. Open the VM Settings and go to Shared Folders to create a Shared Folder, the GUI should be self-explanatory, I use
host-guest-share
as example. Create a mount-point, e.g.~/vmshare
and mount your shared folder:sudo mount.vboxsf "host-guest-share" "/home/$USER/vmshare"
Troubleshooting
After Kernel update: VirtualBox does not start anymore (Ubuntu Host)
VirtualBox is not able to start after upgrading your kernel on the host OS because the needed kernel module is missing. Simply run
sudo /etc/init.d/vboxdrv setup
to solve this problem. You may install dkms on the host to prevent this problem in the future.
After Kernel update: guest additions do not work anymore (Ubuntu Guest)
After upgrading your kernel on the guest OS, the guest additions do not work anymore (you have to catch the mouse again etc.) because the needed kernel module is missing. Simply re-run the guest addtions install script, it is intelligent enough to detect what to do. You may install dkms on the guest to prevent this problem in the future.
Shared Folders: "/sbin/mount.vboxsf: mounting failed with the error: Protocol error" (Linux Guest)
If you get the error “/sbin/mount.vboxsf: mounting failed with the error: Protocol error
”, try “mount.vboxsf […]
” instead of “mount -t vboxsf […]
”.1)
When installing or using Oracle VM VirtualBox Extension Pack: "Failed to locate the main module ('VBoxPuelMain')" (Linux)
This is properly a file permission issue (may happen if you run e.g. a 0077
umask). Try the following:
- If open close the VirtualBox GUI and stop all machines. Wait a few seconds afterwards.
- Open a terminal and run
sudo chmod -R a+rx /usr/lib/virtualbox/ExtensionPacks/
If this does not help:
- Close everything and start VirtualBox as root:
sudo VirtualBox
- Remove the extension via “File→Global Settings…” and re-install by “right click→Add…” using the menu.
- Close VirtualBox, open a terminal and run
sudo chmod -R a+rx /usr/lib/virtualbox/ExtensionPacks/
See also
Further reading
Weblinks
General
Other