Making Ubuntu 12.04 not crawl in Virtualbox
Making Ubuntu 12.04 not crawl in Virtualbox
Join the DZone community and get the full member experience.Join For Free
SignalFx is the only real-time cloud monitoring platform for infrastructure, microservices, and applications. The platform collects metrics and traces across every component in your cloud environment, replacing traditional point tools with a single integrated solution that works across the stack.
So I’ve got a new hooptie laptop (a pimped out Sager NP9170). Since I’m pretty much changing everything about my career, I thought I’d stick to one thing staying the same — I’ll stay with a Windows PC (specifically Win 7 x64 sp1). Traditionally when I need to do Linux dev in this kind of environment, I’ve loaded up Ubuntu in VirtualBox. It typically works really well. The number of glitches I have to work through tend to be really few compared to a direct Linux install. Mostly cause I’m not trying to force Linux to run on a bunch of hardware its probably missing support for. I have all the power of Linux and all the device support of Windows, woohoo! And I can easily do Windows dev at the same time, double woohoo! Anywho, a few things have changed since the last time I got this setup working:
1. Ubuntu’s fancy Unity interface. Pretty heavy 3D desktop environment that tends to lurch unless you have the right hardware and right Virtualbox settings
2. Nvidia Optimus. Optimus is a video card power saving technology that I’ll describe below The intersection of these two new things caused my Ubuntu guest to lurch pretty badly after the initial install. The first thing that occured to me was to give the guest enough RAM, processors, and video RAM with 3D acceleration to quench its appetite. Luckily I’ve got quite a bit installed on this new laptop, so the host has plenty to be generous with. In my configuration, I made the following change.
- Allocated 2 logical cores to the Ubuntu guest
- Allocated 4 GB of RAM to the Ubuntu guest
- Maxed out guest’s video memory to 128 MB
- Enabled 3D acceleration That helped a little, but it still wasn’t quite enough. I also did an update to Ubuntu to bring in all the updates since the 12.04 ISO was released. This plus installing the
guest additions got things working pretty well in windowed mode. (It turns out 3D acceleration for the guest is meaningless without the guest additions). Unfortunately, Unity wasn’t happy when I went into full-screen mode. It was terribly slow for some reason. I tried a lot of things to figure out what was going on. I updated my Nvidia drivers. I installed a fresh Ubuntu virtual machine and played with the settings. I attempted to search for people with similar problems. My google-fu failed me. None of these things helped improve the performance of my VirtualBox. Eventually, I stumbled on something suspicious.
On a whim I wanted to see if anything was awry in the host’s video card settings. Right-clicking on the desktop and selecting “screen resolution” and then “Advanced Settings”, I noticed right away that the the graphics adapter was listed as “Intel HD Graphics 4000″. Not the beefy Nvidia 670M I have installed. I thought a return of my laptop to Sager was definitely going to happen. As far as I could tell, for some reason the Nvidia that had come with my Sager was not operating. I attempted to delete the Nvidia from device manager and rebooted, hoping it would “reinstall” correctly. I attempted to delete the integrated graphics card, which was pretty stupid. Thankfully Windows booted in CPU driven graphics mode and saved my butt.
After some research, I was lucky enough to stumble on this SuperUser question with a screenshot that looked eerily familiar. What I learned was that Nvidia’s souped up laptop graphics card had something called “Optimus” built in. Optimus auto-selects between the low-power integrated, Intel graphics card and the fancy-schmancy super accelerated but power-hogging Nvidia card.
I followed this
video to tweak Optimus’s settings on a per-application basis. The trick is to set the graphics card to be used for VirtualBox. You can also set what graphics processor to use in the Nvidia control panel under “3D Settings” -> “Manage 3D settings”. Select the “Program Settings” tab andn hit the “Add” button to add the VirtualBox executable. Then under bullet 2, select the High-performance NVIDIA processor for VirtualBox. Once I did this, I now get great performance with VirtualBox in full screen. To sum up, to get ideal guest OS performance I followed all these steps: Via VirtualBox Manager:
* Allocated 2 logical cores to the Ubuntu guest
* Allocated 4 GB of RAM to the Ubuntu guest
* Maxed out video memory to 128 MB
* Enabled 3D acceleration In Ubuntu Guest:
* Updated all guest software via Ubuntu S/W Center
* Installed Guest Additions on ISO provided with VirtualBox On Host:
- Installed NVIDIA drivers on Host
- Via NVIDIA Control Panel set VirtualBox’s graphic processor to NVIDIA instead of the integrated graphics Voila! You have the latest Ubuntu Unity hawtness working flawlessly as a guest in Windows!
Opinions expressed by DZone contributors are their own.