3

Is there a way to push all available resources to the program(VirtualBox) when running Ubuntu?

1 Answer 1

6

You can give a process more CPU time relational to other processes by re-nice-ing it. For example, run

pgrep VirtualBox

to get the PID of VirtualBox. If more than one number pops up, you should run top to see which one is using all the CPU - this is likely to be the one you want to fiddle with. The PID is the first column.

Then you can do:

renice -5 PID

would give PID a nice value of -5. This gives it more CPU time than other processes competing for it.

"Niceness" ranges from -19 to 20; -19 is least-nice, meaning gets the most CPU time. 0 is the default. renice must be run as root, i.e., with sudo, to change "niceness" to anything below 0.

The changed niceness only lasts as long as the process runs; it will no longer be in effect after quitting VirtualBox, for next time you run it. (So you'll have to do it again each time.)

I don't think you can change the amount of RAM given to a VirtualBox guest at runtime. This would need to be done before booting it, in the virtual machine configuration.

6
  • Wow Great thanks! Are these the CMD commands for windows?
    – Chaos
    Nov 22, 2011 at 22:51
  • 1
    No, that's Ubuntu, this being an Ubuntu site ;) If you're running in a Windows host then you'll need to use Task Manager to change the priority but that's offtopic for Ask Ubuntu.
    – Caesium
    Nov 23, 2011 at 0:28
  • @Caesium nice does not change the priority of a running process--it runs a process with a (possibly) non-default priority. For a running process, you need to use renice. I'm editing your answer to reflect this. Nov 23, 2011 at 22:07
  • @Caesium I've edited, but I'm still not sure the post is correct with respect to the task at hand for VirtualBox. Most virtualization software uses multiple processes and you have to renice the correct one (the one that corresponds specifically to the particular virtual machine you want to get more CPU time). +It would be good to edit the post to give specific details about how to change a VM's RAM in VirtualBox, and how to change its number if CPU's. +Are you sure VirtualBox is the right executable name? It's not listed at packages.ubuntu.com/oneiric/i386/virtualbox/filelist. Nov 23, 2011 at 22:21
  • @Eliah, good point about renice. VirtualBox is the right binary, see the virtualbox-qt package. You are correct, there could be several running, but sadly it starts them with a --startvm <hexstring> which isn't easy to see in the QT interface.
    – Caesium
    Nov 24, 2011 at 10:55

You must log in to answer this question.

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