How To: Fix (Workaround, really) VirtualBox High CPU Load with Ubuntu 9.10 Host

Updated to Karmic the other day, and all is well and good with the world, but VirtualBox is determined to use a heap of CPU time even when the guest OS is idling. This sucks, and from what I’ve read is related to CPU affinity.

I tried changing the affinity from 3 down to 1 with sudo taskset -p 1 31540 from the terminal, where 31540 was the PID (Process ID) of VirtualBox at the time – and did it work? Um, no…

After some further reading I found a quirky, but totally working fix workaround:
– Create a new virtual machine, call it “Dummy” or something
– Assign it as little resources as you can, like 4MB RAM, use a 10MB HD image etc
– Start this dummy virtual machine, skipping any virtual hard drive formatting
– That’s it! Just leave the dummy machine running at the screen saying “FATAL: No bootable medium found! System halted”

With the dummy machine running, VirtualBox sorts out its own processor affinity properly, and the CPU usage of your actual VM guest drops waaaaaaay down and becomes snappy & responsive again.

The joyz…

Update: This problem’s been recurring for me (as you can see in the comments below), but I think I’ve cracked it: With an XP guest running on a single core of a Core 2 Duo, if I run the following command in bash I can get the CPU usage down to negligible levels:

sudo su
echo 2 > /proc/sys/kernel/perf_counter_paranoid

If this works for you and you want it to be applied at every boot, just edit the file /etc/sysctl.conf and add the line kernel.perf_counter_paranoid = 2 at the bottom.

Additional Information: Although perf_counter_paranoid 2 seems to work reasonably well – we can still do a bit better. With an XP guest, once you’ve set XP to use multiple processors, it’s going to keep trying to use multiple processors, even if you’ve told VB to only allow it access to a single CPU. To fix this you can grab yourself a copy of of HALu and change your XP CPU setup from ACPI Multiprocessor PC to ACPI Uniprocessor PC. With that in place, CPU usage for your linux host drops down a little further, and doesn’t ramp back up too far under minimal guest load. Or you could just use the dummy VM… FFFFFFUUUUUUUUUUUUUUUUUUU…. =P

11 thoughts on “How To: Fix (Workaround, really) VirtualBox High CPU Load with Ubuntu 9.10 Host”

  1. Had a bunch of problems after upgrading to Karmic and also this annoying problem with

    But the above “fix”/workaround actually works so thanks!


  2. Hi,

    At least using virtualbox 3.1 and ubuntu 9.10, I was able to fix the high CPU load by matching the “virtual CPUs” with the actual CPU (I have 2-core laptop). Which I think beats running another VBOX.



    1. Hey nickg,

      The current version of VB in the Karmic repo’s is 3.0.12 – and if I go grab the freshest build I’ll have to manually install each update so I’m holding off for now (laziness, I know ;) ) but I’ll definitely give your tip a whirl when the next version hits, as I’ve got my vboxen running on a single CPU out of the 2 physical ones on the core 2 duo to avoid them hogging resources…

      Cheers for your input!


      1. Finally bit the bullet and installed a non-repo version from the Sun website (3.1.2) – and as promised, setting the virtual box to use both physical CPUs has it running with low CPU usage. Good stuff.

        No good, no dice, no joy… CPU usage is still really high. Have dropped back to using a single CPU for my main XP guest and running the dummy box to keep CPU hogging down.

        I’ve tried disabling virtual memory in the XP guest, I’ve moved the virtual hard-disk over from IDE to SATA controllers (which I’ll post about soon) to try to improve the speed and lower CPU usage, I’ve lowered my linux host swappiness to 0 as with VirtualBox running linux was getting really swap-happy (think 500MB+) when I still had about a GB of RAM free…

        I’m installing another version of XP now to see if something’s just got mangled on the guest or if VB really is acting up. Will post results as I get ’em…

        1. Created a new virtual XP guest in VirtualBox 3.12, disabled all swapfile and indexing in the guest, minimised the number of running services, and set the virtual Hard Disk to run from a physically different disk in SATA mode (guide here) – then with the guest using a single CPU of the 2 available, the guest cpu usage ticks over between 1-2%, so no need for the dummy guest anymore. Nice :)

          Not tried using both CPUs yet – don’t really need to..

          Update: Noticed the CPU usage was waaaay up again when the XP guest was idling, tried letting the guest use both CPUs (and rebooting twice to be sure) – result was even higher CPU usage. Back to a single CPU and using the dummy machine gets CPU as low as I’m able, but it’s by no means perfect. This is starting to irk me. It’s irksome.

  3. Great tip. Complete opposite scenario – Windows 7 64 bit host, Windows XP guest, with CPU running up at 60% while the guest was idle. Created an ’empty’ virtual machine, and immediately on starting it the CPU was down to 5%.

    Thanks for the tip :)

  4. I know this is an older issue, but I just ran into the same problem running SuSe 12.1 with an AMD dual core cpu. I was able to get the idle time usage way down by limiting the number of CPU’s in XP to just one.

    1)Click start menu-> Run
    2) Type in msconfig
    3) go to boot.ini tab
    4) Click advanced options
    5) check /NumProc= and input 1 as the value.
    5) Restart your computer and Windows will only use 1 core on your core2duo

    CPU is still high on start up, but after XP finishes all its start up junk, CPU consumption is very low on idle and WinXP runs OK. I also removed as many un needed background processes as I could find.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.