Zeroing out disk fills RAM of host (linux only)

Discussions related to using VirtualBox on Linux hosts.
Post Reply
alans
Posts: 1
Joined: 19. Feb 2016, 23:04

Zeroing out disk fills RAM of host (linux only)

Post by alans »

Using virtualbox 5.0.14 I am currently zero filling a vm in order to compact the artifact's disk size. It looks like this:

Code: Select all

dd if=/dev/zero of=/EMPTY bs=1M
rm -f /EMPTY
This works great on my mac. Doing the exact same thing on a linux host causes the RAM to fill up on the host machine and the box getting OOM killed. The guest machine seems to be writing directly to the host's memory. There is a 1:1 ratio for zeros written in GB to GB of ram taken up.

So far I have tried to use sync to write data out to disk:

Code: Select all

i=0
while [ $? -eq 0 ]; do
  i=$(($i + 1))
  echo "writing EMPTY-$i..."
  sudo dd if=/dev/zero of=/EMPTY-$i bs=1M count=1000
  sync
done
I have also tried to turn hostiocache off:

Code: Select all

VBoxManage storagectl <vmname> --name "IDE Controller" --hostiocache off
What am I missing here? Is there anything else I can tweak so I am not caching disk writes on the host's memory?
Post Reply