VirtualBox - Ubuntu: Questions and Answers (2014)

Ubuntu: Questions and Answers (2014)

VirtualBox

Skip to questions, Wiki by user takkat

VirtualBox

VirtualBox provides a virtual machine for a variety of guest operating systems. Detailed installation instructions can be found in the VirtualBox User Manual. For USB and RDP support a non-open source (PUEL) extension pack needs to be installed.

Recent versions of VirtualBox for Linux can be found on the products download page. The software is currently owned by Oracle.

Alternatives

· VMware Player vmware-player

· VMware Workstation vmware

· Kernel-based Virtual Machine (KVM) see kvm

Notable questions

· How do I install Guest Additions in a VirtualBox VM?

· How to set up USB for Virtualbox?


Questions

Q: How do I install Guest Additions in a VirtualBox VM?

Tags: virtualbox (Next Q)

I've recently installed Ubuntu on Oracle's Virtualbox. Now I want to install the guest additions.

I started up my Ubuntu guest OS, clicked "Devices" and chose "Install Guest Additions". Nothing happened, and I don't see the CD icon on my desktop.

How can I make this work?

Tags: virtualbox (Next Q)

User: snakile


Answer by takkat

If you have trouble installing Ubuntu in a VirtualBox VM, because the installer window does not fit the low resolution screen size, you can move the window with Alt+F7.

Installing Guest additions from the repositories

In case we have installed the OSE edition of Virtual Box from the repositories we can add the guest additions from the repositories.

Install the package virtualbox-guest-additions-iso Install virtualbox-guest-additions-isoin the host Ubuntu. The .iso file with an image of the OSE edition of the guest additions CD will install in the host directory /usr/share/virtualbox/VBoxGuestAdditions.iso. Mount this .iso file as a CD in your virtual machine's settings. In the guest you will then have access to a CD-ROM with the installer.

Installing Guest Additions from Virtual Box Manager

In case the Guest Additions fail to build we may have to install the Linux kernel headers (see How do I install kernel header files?) or build-essential Install build-essentialtools in addition. It is also recommended to have dkms Install dkmsinstalled (see below - Note 4).

Selecting Devices -> Install Guest Additions (or press Host+D from the Virtual Box Manager) the Guest Additions CD .iso will be loaded but not installed in your guest OS. To install we need to run the installer script VBoxLinuxAdditions.run as root or from the Autorun Prompt (see below),


GNOME classic

To install the Guest Additions we will have a CD icon on our desktop as soon as the virtual drive is mounted:

alt text

Next step is to run the autorun.sh script (as root) on this mounted CD either by opening the drive or by choosing "Open With Autorun Prompt" from the right-click context menu as depicted above. This will build and install the vbox kernel modules needed.


Unity

The guest additions is mounted as a virtual CD visible on the launcher:

enter image description here

In case the system is set up to autorun a CD it should just open the following autorun dialogue (if not select the CD symbol, choose open, then choose Open Autorun Prompt)

enter image description here

After having entered your credentials for root access the guest additions will build as seen from the terminal output:

enter image description here

Press Return to close the terminal.


Note 1
Guest Additions need a reboot of your guest OS to take effect.

Note 2
In some systems the Virtual Box Guest Additions CD icon may not be shown on the desktop, but will be accessible from the Places menu. If the CD still was not there you may have to manually add the VBoxGuestAdditions.iso as a CD-ROM in the Virtual Box Manager Storage menu. In an Ubuntu host the disk image is in /usr/share/virtualbox/VBoxGuestAdditions.iso.

Note 3
In some systems (e.g. when running Xubuntu guests) we may not have an Autorun Prompt for the mounted CD. Then we can install the guest additions by opening a terminal on the mounted guest additions .iso to run sudo ./VBoxLinuxAdditions.run. In Lubuntu guests we additionally need to install the GNU C compiler (gcc Install gcc) and the make Install makeutility in the guest system to be able to compile the guest additions.

Note 4
Running DKMS in the guest OS will keep Guest Additions installed after a guest kernel update. It is not a prerequisite for Guest Additions but if used it should be installed before we install the Guest Additions.


Installing Guest Additions from a Terminal

In case Guest Additions are not installed properly we may not be able to boot to the GUI. In this case we need to boot holding the Shift key to access the Grub menu where we access a root shell as depicted in the following question (we do need to mount the filesystem read/write to proceed):

· How do I boot into a root shell?

The Guest Additions .iso file needs to be installed on /dev/cdrom from the Virtual Box Manager (see above). We then may install Guest Additions by typing the following commands:

mount /dev/cdrom /mnt # or any other mountpoint

cd /mnt

./VBoxLinuxAdditions.run

reboot


Remove Guest Additions

In case something went wrong with installing the guest additions, or the guest OS can not boot after installing we may have to remove the additions. This can be done by running an uninstallation script located in the guest /optdirectory.

cd /opt/<VirtualBoxAdditions-x.x.xx>/

sudo ./uninstall.sh

Replace x.x.xx with your current version of guest additions.


Answer by aaron-newton

You could also try the following (this worked for me after I had to reinstall the Guest Addtitions after Update Manager killed them). Solution found here:

http://www.unixmen.com/install-guest-addition-in-ubuntu-1010-maverick-meerkat-fix/

In summary:

sudo apt-get update

sudo apt-get install build-essential linux-headers-$(uname -r)

sudo apt-get install virtualbox-ose-guest-x11

This found and updated the correct version of the VirtualBox Guest Additions and my system seems to work properly again, and I'm assuming this will also work if Guest Additions are failing to install from the menu item.

One other thing of note. I originally tried to run this under the fish shell - make sure you're using bash (i.e. type "bash" into the terminal before you start).


Note on more recent systems, the command has been changed to

sudo apt-get install virtualbox-guest-x11


Tags: virtualbox (Next Q)


Q: How can I access Apache (on VirtualBox guest) from host?

Tags: virtualbox (Next Q), apache2 (Next Q)

I installed Apache on an Ubuntu VM. When I go into the guest and load up Firefox I can see that Apache is working fine when I browse to localhost.

I would like to access this same page through the host. I've tried using the IP address of the guest but nothing comes up.

Ideally I would love to set up my Windows 7 (host) to request http://guestserver.com of the Apache server on the guest. How can I do this?

Tags: virtualbox (Next Q), apache2 (Next Q)

User: drtanz


Answer by lekensteyn

If you other machines in your physical network must be able to reach your VM (or if the VM needs Internet access), use bridged networking. Otherwise, stick to host-only networking.

1. Stop your VM and open its settings in the VirtualBox (OSE) Manager

2. Go to the Network tab

3. Select the network mode at your choice (bridged networking or host-only) (in the below example, I'm using host-only)

If you want to use bridged networking, you've to select the right network adapter at Name. For wired connections, you'd select something named like eth0. Wireless connections are usually named wlan0 (the numbers may vary)

4. Save the settings

5. Start the Ubuntu VM

6. When up, you can gather the IP address by running:

7. ifconfig | grep addr

In the below output, 192.168.56.101 is the IP address that can be used in your Win7 host system to access your VM:

eth0 Link encap:Ethernet HWaddr 08:00:27:70:27:fe

inet addr:192.168.56.101 Bcast:192.168.56.255 Mask:255.255.255.0

inet6 addr: fe80::a00:27ff:fe7b:25fe/64 Scope:Link

inet addr:127.0.0.1 Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

7. In your windows host system, edit C:\Windows\drivers\etc\hosts as administrator and add a line:

8. 192.168.56.101 guestserver.com

If you've a Ubuntu host system, edit /etc/hosts using sudo nano /etc/hosts

8. Profit!


Tags: virtualbox (Next Q), apache2 (Next Q)


Q: Higher screen resolution for VirtualBox?

Tags: virtualbox (Next Q), xorg (Next Q)

I have been trying this for a while but no luck. I installed ubuntu-11.10-desktop-i386 twice. Also installed guest additions. However I always get maximum screen resolution as, 1024 x 768.

Do I need to change anything in /etc/X11/xorg.conf file (example)? Presently there is no such file in that path. Also, would you be able to advise me what the contents of the file for 11.10 version should be?

Tags: virtualbox (Next Q), xorg (Next Q)

User: iammilind


Answer by wfudge

This worked for me and I am running VirtualBox 4.1.8 and Ubuntu 11.10.

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

Found it on this site under a slightly different question Higher screen resolution in VirtualBox?


Answer by sai-puli

I was able to reproduce this issue repeatedly on Windows 7 host with Ubuntu 11.10 guest. Installing ubuntu from an iso image.

This issue happens when the either the Guest Additions are not installed or installed from ubuntu sources.

To fix this install guest additions from the virtual machine's Devices > Install Guest Additions option and running the autoprompt. If you already have the guest additions installed from a different source it will prompt you about removing the existing one and installing new guest additions, just say 'yes'. This will remove the guest additions if they are already installed from ubuntu sources and build from sources that came with your virtualBox installation.

This should fix the issue.


Answer by lowresolutiononubuntu12.04

I just installed Ubuntu 12.04 on VirtualBox 4.1.4, but couldn't get it to work on higher resolution, even after installing and reinstalling the VBOXAdditions. Desperate, I installed the VBOX 4.1.14 and reinstalled many times the VBOXAdditions, but without any success. Finally, the solution that solved the problem, was to increase the video memory (in VBOX setting for Ubuntu) from starting 12 MB, to 48 MB (which still did not enable resolution 1366x768), and than to 128 MB. After restarting Ubuntu everything works perfect, 1366x768 is my default resolution. I hope this will help in your problems. Cheers!


Tags: virtualbox (Next Q), xorg (Next Q)


Q: How do I increase the hard disk size of the virtual machine?

Tags: virtualbox (Next Q)

enter image description here

I have run out of space on my WinXP virtual machine, which I only gave 10 GB space for when I created it. Is there an easy way to increase it to, say, 20 GB? I can't see any obvious option in VirtualBox settings.


The suggestion below gives this error

wim@wim-ubuntu:/media/data/winxp_vm$ VBoxManage modifyhd wim.vdi --resize 20000

VBoxManage: error: Cannot register the hard disk '/media/data/winxp_vm/wim.vdi' {46284957-2c09-4e70-8a49-bfbe0f7f681d} because a hard disk '/home/wim/VirtualBox VMs/winxp_vm/wim.vdi'with UUID {46284957-2c09-4e70-8a49-bfbe0f7f681d} already exists

VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBox, interface IVirtualBox, callee nsISupports

Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, AccessMode_ReadWrite, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 210 of file VBoxManageDisk.cpp


Removing the .vdi from VirtualBox before calling VBoxManage command, then adding it back in, was successful. But now I can't boot the virtual machine, I get this worrying screen:

enter image description here

By the way, it says FATAL: Could not read from the boot medium! System halted.


The vdi must be reattached to the VM after VBoxManage command. Further, the partition will need to be resized from WITHIN windows, because you will have this empty space:

enter image description here

I was able to resize the partition easily using a bit of freeware called EASEUS Partition Master 9.1.0 Home Edition.

Tags: virtualbox (Next Q)

User: wim


Answer by tom-brossman

Open a terminal and navigate to the folder with the VirtualBox disk image, then use the following command:

VBoxManage modifyhd YOUR_HARD_DISK.vdi --resize SIZE_IN_MB

replacing YOUR_HARD_DISK and SIZE_IN_MB with your image name and desired size. This answer and a fuller explanation are here, on webupd8. Credit to Andrew there for posting this answer.


Answer by tiempjuuh

Wim, I think you'll need to unregister it from Vbox first. File, Media Manager, Click on you hdd, and unregister it. Then try it again.


Tags: virtualbox (Next Q)


Q: VirtualBox '/etc/init.d/vboxdrv setup' issue

Tags: virtualbox (Next Q), virtualization (Next Q)

I have installed VirtualBox through the software centre, but when I try to start a VM, I get the following error:

Kernel driver not installed (rc=-1908)

The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Please reinstall the kernel module by executing

'/etc/init.d/vboxdrv setup'

as root. If it is available in your distribution, you should install the DKMS package first. This package keeps track of Linux kernel changes and recompiles the vboxdrv kernel module if necessary.

I already updated my dkms and installed linux-headers, but this /etc/init.d/vboxdrv doesn't exist.

I have been googling but I can't find an answer.

Tags: virtualbox (Next Q), virtualization (Next Q)

User: dr_bunsen


Answer by jason-zhu

I also encountered this issue several times once I upgrade my linux kernel.

What I did:

sudo apt-get install linux-headers-`uname -r`

Reconfigure dkms and load module:

sudo dpkg-reconfigure virtualbox-dkms

sudo modprobe vboxdrv

Then VirtualBox works. No computer reboot needed.


Answer by hankhendrix

Here's EXACTLY how to do it on 12.10:

Make sure there are no traces of dkms, (virtualbox/ virtualbox-4.2), linux generic headers (..17):

***Replace virtualbox-4.2 with the version you have already installed. If you haven't installed it yet then proceed to step 2.

1. sudo apt-get purge virtualbox-4.2 dkms linux-headers-$(uname -r)

2. sudo apt-get install linux-headers-$(uname -r)

3. sudo apt-get install virtualbox-4.2

You MUST install the linux headers BEFORE virtualbox otherwise the VBox installation will error when trying to set up the vboxdrv section because the linux headers aren't installed.


Tags: virtualbox (Next Q), virtualization (Next Q)


Q: Why does a Ubuntu guest in VirtualBox run very, very slowly?

Tags: virtualbox

I'm using currently Ubuntu 12.04 LTS as a host machine, and I've virtualized three machines:

· a Xubuntu 12.04 guest

· a Windows 7 guest

· a Ubuntu 12.10 guest

All the guests have the same VirtualBox default settings, but Ubuntu 12.10 is slower!

The installation took 1h 40 min! (Normally, it takes 40 minutes.) Now it is impossible to use it, and all operations are very, very slow.

I'm using VirtualBox version 4.2.4.

Any ideas?

Why is it slow? And how can I make it faster?

Tags: virtualbox

User: giorgio


Answer by bret

I have heard it has something to do with the fact they removed Unity 2D, or somehow the switch to 3D Unity only slows down the VM performance due to the heavy reliance on the CPU handling more that it used to have to. The Linux Outlaws podcast talked about it a bit, but I forget the episode.

Update: The problem is with Virtualbox Guest Additions not providing 3D acceleration in 12.10. See Ubuntu 12.10 unable to use 3D acceleration. Fails to build DRM.


Answer by flimm

Ubuntu 12.10 no longer includes Unity 2D, which was implemented for platforms that can't provide 3D acceleration. Instead, Ubuntu 12.10 has Unity run under LLVM, making code intended for the GPU run on the CPU. It is much slower than using the GPU.

To check if your Ubuntu 12.10 guest is using 3D acceleration, run this command:

Skip code block

$ /usr/lib/nux/unity_support_test -p

Not software rendered: no

Not blacklisted: yes

GLX fbconfig: yes

GLX texture from pixmap: yes

GL npot or rect textures: yes

GL vertex program: yes

GL fragment program: yes

GL vertex buffer object: yes

GL framebuffer object: yes

GL version is 1.4+: yes

Unity 3D supported: no

As you can see, "Not software rendered" and "Unity 3D supported" both return "no" in this example, which means Unity is using slow LLVMpipe.

How to enable 3D acceleration (VirtualBox 4.2.x only)

These instructions are intended for VirtualBox 4.2.4 or 4.2.6, installed from VirtualBox's website, not from Ubuntu's repo. Future versions of VirtualBox may fix this problem automatically, or may need a different workaround.

1. Install VirtualBox Oracle VM VirtualBox Extension Pack.

2. Create a VirtualBox instance and install Ubuntu 12.10 on it.

3. Install some required packages for the guest additions:

4. sudo apt-get install linux-headers-$(uname -r) build-essential

4. Install the guest additions by clicking Devices, Install Guest Additions and running this command from the CD-ROM's directory:

5. sudo ./VBoxLinuxAdditions.run

5. Add the vboxvideo driver to the instance by running:

6. sudo bash -c 'echo vboxvideo >> /etc/modules'

6. Shutdown the VirtualBox instance.

7. Open the settings of the Virtualbox instance, navigate to "Display", and tick "Enable 3D acceleration".

8. Boot your Ubuntu 12.10 guest, and check that 3D acceleration is working by running:

9. /usr/lib/nux/unity_support_test -p

If windows seem to disppear, install CompizConfig Settings Manager and disable Framebuffer Object (FBO) in the OpenGL section:

1. Install the CompizConfig Settings Manager:

2. sudo apt-get install compizconfig-settings-manager

2. Run the CompizConfig Settings Manager:

3. ccsm

3. Select the OpenGL section and then untick the Framebuffer Object option. If this fixes the issue it should be immediately visible. No reboot is required.


Answer by andrew-b

It looks like the VirtualBox software developers are working on a solution, but it's not ready yet - see forum post Discuss the 4.2.4 release.

There is a thread discussing this in fourm post Ubuntu 12.10 "virtually" unusable


Tags: virtualbox


Q: How do I install Guest Additions in a VirtualBox VM?


Q: How can I access Apache (on VirtualBox guest) from host?


Q: Higher screen resolution for VirtualBox?


Q: How do I increase the hard disk size of the virtual machine?


Q: How to install Internet Explorer (multiple versions)?


Q: VirtualBox '/etc/init.d/vboxdrv setup' issue


Q: Why does a Ubuntu guest in VirtualBox run very, very slowly?