46

I run a guest ubuntu 12.04 on a host ubuntu 12.04, with VirtualBox, and the guest is much, much slower than the host (ALT+TAB takes 4-5 secs). I had a look around and I found contradicting opinions on VirtualBox versus VMware (free); so I thought to keep the former.

Both systems are updated, I installed the additions on the guest and I evenly split memory and video memory (64MB) between guest and host. I am running a Toshiba m200 laptop with 4GB ram and shared video memory. The host bios does not include a configuration option for machine virtualization. I have 2 cpus and I can't give them both to the virtual machine.

Is there anything I overlooked that could solve my problem?

Feel free to ask for more info, and thank you for any help.

EDIT Idling with the system monitor open the (single) guest cpu never gets below 55% and could rise to 80 - 90% just by moving the mouse around. Opening Firefox will cause the system monitor to show cpu usage 100% in the guest, while the host shows that both cpus are evenly working around 60%.

My cpu is Intel® Core™2 Duo CPU T5450 @ 1.66GHz × 2.

If this is not a configuration problem, does it mean my machine is too weak for virtualization?

2
  • even installing unity2d (which helped) and trying different configuration the vm is still too slow for my taste, so I abandoned the idea by now
    – ecoologic
    Sep 19, 2012 at 11:09
  • I think JohnP's answer is the most appropriate here. Mar 25, 2016 at 16:55

5 Answers 5

36

I don't know much about Player, but Vbox defaults are not good for Ubuntu releases that prefer a real GPU.

  • On spinning HDDs, pre-allocate the entire virtual disk. On SSDs, it doesn't matter. VDI / qcow2 sparse allocations do reduce performance, but the reductions involved appear to be less than 10% since 2015. Weigh the performance vs convenience.
  • Allocate only the storage you need. Keep large files elsewhere, outside the vStorage.
  • Never allocate more CPUs or RAM than you should. 1 vCPU is probably enough.
  • Leave 1GB of RAM for the HostOS. Do not over commit RAM.
  • Use the VirtIO drivers for Storage and Networking. Modern Linux guests support this. For Windows guests, use the SATA (storage) and Intel PRO/1000 (network) drivers. It is possible to use virtio drivers under Windows, it is just a little harder.
  • Enable ACPI and AHCI for all guests from 2003, WinXP and later.
  • Desktop VMs should get all 128MB of display vRAM
  • Server VMs should stay with 9MB of vRAM; don't waste it.
  • Avoid 2D and 3D accel settings, until you have everything else working the way you like. I'm serious. Ubuntu does bad things when this is enabled. It can bring a Core i7 to the ground.

For more details: http://blog.jdpfu.com/2012/09/14/solution-for-slow-ubuntu-in-virtualbox

5
  • 2
    how to pre allocate the entire virtual disk?
    – Toskan
    Jul 22, 2015 at 4:10
  • 5
    "Use the VirtIO drivers for Storage" -- Unless I'm missing something obvious, VirtualBox doesn't implement paravirtualized storage. If it does, please tell me where because I'd love to use it.
    – cdhowie
    Jul 24, 2015 at 18:01
  • 1
    Allocate only the storage you need. I disagree with this. You can set up the disk to 50 GB dynamically. You will be in trouble with stability if you allocate too little space in the first place. Dynamically expansible space does not take max all the time but only as much as it needs. Mar 25, 2016 at 16:57
  • The only way I know to preallocate the disk is to use the vboxmanage tool and copy the old VDI file into a new fully-allocated VDI file.
    – JohnP
    Feb 23, 2017 at 19:27
  • Saw that vbox includes virtio drivers recently.
    – JohnP
    Nov 22, 2017 at 2:36
8

A virtual guest with that low of resources will run slowly. For best performance you actually give your host a bit more resources than the guest. Also you will not be able to give both cpu's to your virtual machine since your host machine needs something to run everything.

Think of it this way. Your host machine has to run its' own system plus the container for the guest. The guest gets into a resource fight with the host machine. Try giving the guest less and see how it runs.

For best performance you will want a 64 bit machine with more than 4gb of memory.

8
  • I actually tried several configurations before asking the community, ram shouldn't be a problem at this stage (the most of it is unused), from your answer I get that the problem should rely mainly on the cpu (often at 100%), I taught my laptop was powerful enough, maybe it's here I'm wrong...
    – ecoologic
    Sep 18, 2012 at 20:28
  • A thought may be to watch resource usage in both host and guest and see what is being exhausted where. What type of processor do you have?
    – Nate
    Sep 18, 2012 at 20:31
  • it's not the fastest machine you'll ever see, but it never disappointed me (answer updated).
    – ecoologic
    Sep 18, 2012 at 20:44
  • Yes I would say you machine is not powerful enough for speedy virtualization. You obviously have it running so it is up to you if you want to live with the speed.
    – Nate
    Sep 18, 2012 at 20:49
  • 2
    @ecoologic: Unity2D runs much faster - did you try?
    – Takkat
    Sep 18, 2012 at 20:50
5

I have experienced the same problem

Host: Ubuntu 14.10 (64-bit), Guest: Windows 7 (64-bit)

Even with the virtualization turned on in host BIOS the CPU load was constantly around 40-50% in guest idle state

What helped me was installing Guest Addition with Direct 3D support (you need to do that in safe mode) and turning on the host I/O Cache of the SATA controller

So my current settings are:

System

Base memory: 4096 Mb (8192 Mb total host memory)

Processor: 6 CPUs (of host 6 CPUs)

PAE/NX: Enabled

VT-x/AMD-V: Enabled

Nested Paging: Enabled

Display

Video memory: 128 Mb

3D Acceleration: Enabled

2D Acceleration: Enabled

Works like a charm! Virtual Box Version: 4.3.18_Ubuntu r96516

4

In addition to the previous answers for optimal VirtualBox settings, there is a great blog post by Nam Huy on how to get 3D acceleration to work for an Ubuntu guest. This is especially useful for Ubuntu 13.04, as there is no option to install Unity 2D anymore, leaving a fresh installation without any real workload on 80-100% CPU load due to software rendering, making it practically useless for me.

The basic idea is to install guest additions, load "vboxvideo" into etc/modules, reboot, and then activate 3D acceleration in the VirtualBox Display settings. Note that enabling 3D acceleration has to be the very last step after configuring everything else in the guest.

For me, this brought a massive performance boost, in fullscreen mode I can't even tell the difference between my native OS and the Ubuntu guest.

1
0

Although the initial answer is very detailed I feel the straight to the point answer is honestly that the system/laptop is too slow and underpowered not much can be done unless there is a config issue or bug in your Virtualbox version. You can try to optimize but the host RAM and 2 CPU cores at 1.66Ghz are just not going to cut it. With that CPU utilization it is very likely due to swapping and not having enough RAM.

In short you could try another window manager which is more lightweight and also consider trying other OS's to see if there is maybe a configuration issue with your Virtualbox and update to the latest version.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .