Ubuntu guest in VirtualBox loses network access after Windows host hibernate

Problem

I have a Windows host system which is running an Ubuntu guest inside VirtualBox. While the Ubuntu guest is running, I hibernate the Windows host. Later, after the Windows host is resumed, I find that network connectivity is lost in the Ubuntu guest. The LAN network interface is present and shows as connected. However, no domain name can be resolved or pinged.

Solution

I found that this bug in VirtualBox is reported here. Disconnecting the network interface and connecting back did not work. But, turning off networking and turning it back on worked!

Tried with: Ubuntu 14.04, VirtualBox 4.3.20 and Windows 7 Professional 64-bit

Advertisements

How to change resolution of virtual console

On many systems, I find that the virtual console in Ubuntu is limited to 80x40. That is, it only displays 80 columns and 40 lines of text. The resolution of my display is much higher than this and I would like to render more lines and columns in the virtual consoles.

To do that:

  • Open the file /etc/default/grub in an editor:
$ sudoedit /etc/default/grub
  • We add two lines to the file. If these lines are already there, edit or comment them out. The first line provides the pixel resolution (say 1920x1200) of your display:
GRUB_GFXMODE=1920x1200x32
GRUB_GFXPAYLOAD_LINUX=keep
  • Update GRUB:
$ sudo update-grub
  • Restart Ubuntu. The virtual console should have a resolution that matches your display resolution.

Note: This also works for virtual console of Ubuntu running inside a VirtualBox virtual machine. Since the VirtualBox window can be resized (and the virtual console cannot), I provide a smaller resolution to GRUB there. For example: 1024x768.

Tried with: Ubuntu 14.04

Guest Additions install fail on VirtualBox

Problem

You have a Ubuntu guest virtual machine running on VirtualBox that is running on a Ubuntu host OS. You try to install Guest Additions and it fails.

The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.

Building the main Guest Additions module ...fail!
(Look at /var/log/vboxadd-install.log to find out what went wrong)

Solution

Though the error looks like it has something to do with the kernel, the actual solution turned out to be quite basic. My Ubuntu host OS was 12.04 and it was running VirtualBox 4.1.2. Now the guest OS was Ubuntu 13.10, which is much newer. The problem turned out to be that the Guest Additions, which comes from VirtualBox, was much older than the guest OS. I uninstalled the old Virtual Box and installed the latest VirtualBox 4.3.8 from the web and Guest Additions worked fine!

Not found in mesa table OpenGL error with VirtualBox

Problem

I have a setup where I am running Ubuntu under VirtualBox on top of Windows. Inside Ubuntu, I ran a program that uses OpenGL and it threw up many lines of errors of this type:

OpenGL Warning: glVertexArrayRangeNV not found in mesa table

And the program ended in a segmentation fault (SIGSEGV).

Solution

This problem is supposedly caused only when you have 3D acceleration turned on for the Ubuntu virtual machine. VirtualBox does not support OpenGL 3.0 and later. So, programs that expect those OpenGL extensions might crash.

Surprisingly, the solution is to shutdown the virtual machine, turn off 3D acceleration, start it and try the OpenGL program again. After I did that, the program threw up warnings like this:

OpenGL Warning: Failed to connect to host. Make sure 3D acceleration is enabled for this VM.
libGL error: failed to load driver: vboxvideo
libGL error: Try again with LIBGL_DEBUG=verbose for more details.

Thankfully, the program executed fine despite these warnings.

Tried with: Ubuntu 12.04 LTS, VirtualBox 4.3.6 and Windows 7 x64

How to install Ubuntu from ISO file to VirtualBox on Ubuntu

It is sometimes useful to have one or more VMs of Ubuntu running on your native Ubuntu installation. For example, this can be useful for testing your code under certain software environments. One of the easiest ways to run VMs on Ubuntu is using VirtualBox.

It is pretty straightforward to setup a Ubuntu VM in VirtualBox. The only problem is to install Ubuntu from its ISO file into the VM. To do this, VirtualBox has to see the ISO file as a DVD disk that has been mounted from a (virtual) DVD drive. To do this:

1. Right-click on your VM and choose Settings > Storage > IDE Controller > Add CD/DVD Device.

2. Click on Choose disk and point it to your Ubuntu ISO file.

3. Now start the VM. it will boot from your ISO file and you can proceed with your Ubuntu installation on your VirtualBox.

Tried with: VirtualBox 4.1.12 and Ubuntu 12.04 LTS

Ubuntu switches to old display resolution in VirtualBox

Problem

I had increased the display resolution of Ubuntu in VirtualBox using Guest Additions, as explained here. Today it switched back magically to a small 800×600 resolution after a reboot! And also the resolution would not increase or change to match its window size.

Solution

Ubuntu had updated itself before this happened. Apparently, it overwrites the display resolution settings or drivers that were enabled by Guest Additions. Once I suspected this, I installed Guest Additions again, as explained here. A reboot later, Ubuntu was in high resolution matching whatever size I dragged its window to.

Tried with: Ubuntu 12.04, VirtualBox 4.2.4 and Windows 7 Professional x64

Increase resolution of Ubuntu in VirtualBox

Problem

No matter how much video memory you give Ubuntu running in VirtualBox, it runs with a pitifully small resolution like 800×600 or something like that.

Solution

To enable Ubuntu to use larger resolutions, you need to install Guest Additions to it. The instructions to do that are here. After installation, reboot Ubuntu and you will see that Ubuntu resolution will match the window size. To increase the resolution just increase or change the VirtualBox window size by dragging its corner.

Tried with: Ubuntu 12.04, VirtualBox 4.2.4 and Windows 7 Enterprise

VT-x is not available for VirtualBox

VirtualBox error

Problem

A virtual machine running Ubuntu in VirtualBox which was working fine threw up an error when I tried to restore it. The error read:

Failed to open a session for the virtual machine Ubuntu-12.04-LTS-x64.

VT-x is not available. (VERR_VMX_NO_VMX).

Result Code: E_FAIL (0x80004005)
Component: Console
Interface: IConsole {db7ab4ca-2a3f-4183-9243-c1208da92392}

This happened even though I had not changed any settings in VirtualBox.

Solution

VT-x is hardware visualization which the Intel Core i3 M330 processor I have does support. It was strange that the hardware visualization feature suddenly was not available to VirtualBox.

Then I remembered that I had enabled Hyper-V earlier in the day. Windows 8 ships with Hyper-V and I had turned it on to try it out. It turns out that Hyper-V grabs hardware visualization and VirtualBox is left stranded not being able to access it.

I disabled Hyper-V and my VM in VirtualBox booted up without any errors.

Tried with: VirtualBox 4.2.4 and Windows 8 Pro

The strange case of the incorrect side-by-side configuration

Side-by-side configuration error

A week ago VirtualBox informed that a new version was available and that I should update to it. I proceeded to get the latest version using Chrome, which downloaded as the file VirtualBox-4.2.4-81684-Win.exe. On executing the file, I got this error:

The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.

This error was a bit troubling to me because I have not seen any DLL or SxS problems with Windows 7 and recent versions of software. Those happen mostly with older versions of Windows and older software.

Searching online for this error leads to suggestions that one should install a particular version of the Visual C++ Redistributable package. None of those solved the problem however.

I finally suspected the file itself. File downloads rarely get corrupted these days, but it can still happen. So, I downloaded the file again and it installed without any complaint! 🙂

Just to confirm I opened up the two files in WinMerge and found that there were a few bytes at the end of the second file missing from the first downloaded file.

Tried with: VirtualBox 4.2.4 and Windows 7 Enterprise

How to share folder from Windows to Ubuntu in VirtualBox

On Windows, I sometimes run Ubuntu inside a VirtualBox virtual machine. I find that sharing a folder from Windows to Ubuntu is a convenient method of sharing files between the host and guest OS. Doing this is easy:

  • Install Guest Additions on the Ubuntu virtual machine.

  • Add your user to the group vboxsf in the Ubuntu VM:

$ sudo adduser yourusername vboxsf 
  • Power down the Ubuntu virtual machine.

  • In VirtualBox, right-click on the Ubuntu virtual machine and choose Settings → Shared Folders.

  • Choose Add Share. Choose the Folder Path to the directory you want to share. Note down the Folder Name displayed. This name will be used inside Ubuntu, so change it if you want. Check the Auto-mount option to have Ubuntu mount this directory whenever it starts up.

  • Power up the Ubuntu virtual machine. Your foo shared folder will be accessible in /media/sf_foo directory.

Tried with: Ubuntu 12.04 x64, Windows 7 Enterprise x64 and VirtualBox 4.2.0