Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a Virtualbox on my Ubuntu (host) that serves few Windows guest OS.
Sometimes the running Windows virtual machine starts massive access to the disk which blocks me in my host environment. I would like to limit the read/write of data access to the physical harddisk.

How can I do it?

share|improve this question
    
Sounds very much like a bug. What sort of activity caused the problem ? Are you running out of RAM (how much swap space are you using ? ) –  bodhi.zazen Mar 26 '12 at 13:32
    
There might be many reasons for massive access and you are right about one of them. However, my question is a generic one about limiting a VM so that even when it wants to the host won't allow it to use some portion of the bandwidth. –  yossile Mar 26 '12 at 13:53
    
@bodhi.zazen I want to limit access (reads/writes) to the hard disk. RAM and CPU can be limited from the VM image settings but if an guest is doing heavy reading/writing to the disk (virtual disk of course) then there is no limit on that. –  yossile Mar 26 '12 at 14:18

1 Answer 1

up vote 7 down vote accepted

Starting from version 4.0 we are able to limit Virtual Box bandwith for acess to disk images (see Virtual Box Manual for details)

We need to create a bandwith group first (in the example below named "Limit" for 20 MB/s):

VBoxManage bandwidthctl "VM name" --name Limit --add disk --limit 20
VBoxManage storageattach "VM name" --storagectl "SATA" --port 0 --device 0 --type hdd
                                   --medium disk1.vdi --bandwidthgroup Limit
VBoxManage storageattach "VM name" --storagectl "SATA" --port 1 --device 0 --type hdd
                                   --medium disk2.vdi --bandwidthgroup Limit

Note: From versions >= 4.2 these commands changed to:

VBoxManage bandwidthctl "VM name" add Limit --type disk --limit 20M
VBoxManage storageattach "VM name" --controller "SATA" --port 0 --device 0 --type hdd
                                   --medium disk1.vdi --bandwidthgroup Limit
VBoxManage storageattach "VM name" --controller "SATA" --port 1 --device 0 --type hdd
                                   --medium disk2.vdi --bandwidthgroup Limit

We need to give the details of our personal setup above.

To further limit disk access to 10 MB/s we can then issue

VBoxManage bandwidthctl "VM name" --name Limit --limit 10 # version 4.0
VBoxManage bandwidthctl "VM name" set Limit --limit 10M   # >= 4.2

This can even be done during runtime.

share|improve this answer
1  
--controller is no longer the correct command. It should now be --storagectl "SATA Controller Name" To limit access while the VM is running the command is VBOXManage bandwidthctrl "VMName" --name Limit --limit 10 –  user77793 Jul 18 '12 at 15:13
    
@Lee: thank you, edited answer. –  Takkat Jul 18 '12 at 21:29
    
Nice answer. But the command here in Virtual Box 4.2.12 was VBoxManage bandwidthctl "VM Name" add "Limit" --type disk --limit 10 and VBoxManage storageattach "VM Name" --storagectl "SATA" --port 0 --device 0 --type hdd --medium "Disk Name.vdi" --bandwidthgroup "Limit". –  ErickPetru Apr 25 '13 at 19:40
    
@ErickPetru: thanks for the notice - edited answer for the new command sets. –  Takkat Apr 25 '13 at 19:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.