2

I am running Oracle VM VirtualBox (Ver: 3.2.8). Inside my VirtualBox, I used to run a Ubuntu OS. Whenever I create a file or folder containing large data (sometimes the size goes up to 1GB) the disk space increases automatically. If I check the file size (the vdi file size which is kept in a separate partition) from Windows XP it shows the incremented size of the vdi file.

If I (permanently) delete any folder of size 1GB, it is not reflected in disk space. This means from Windows, if I get the vdi file properties it does not show the increase in free space even though I have deleted a 1GB folder permanently from Ubuntu OS.

If a issue the command df -h in Ubuntu, it is showing the right thing.

Is the issue related to VirtualBox? Is there a fix?

2 Answers 2

1

The problem you're seeing is because a dynamic disk continues growing even if you erase some files, for example, if you erase a 2Gb file from the virtual machine this space is not being reduced from de disk, you need to erase as you mention the zeroed space and then compact the virtual machine. You can do this to get compacted the size of the vdi file:

How to compact VirtualBox's VDI file size?

0

I've done the same thing and observed the same behavior. I believe that this behavior is by design.

Dynamic expansion is promised

The "Create new disk" wizard states, under the "Fixed-size storage" section:

The creation of a fixed-size storage [sic] may take a long time depending on the storage size and the write performance of your harddisk.

One reason for the dynamically expanding partition is that creating, say, a 32 GB file on the host for the virtual machine takes a long time.

Dynamic expansion is useful

Therefore, pretending that the file is actually 32 GB until it actually needs to be that large is useful; you don't want to wait a long time to create a new machine if you're only going to use the first 2 or 3 GB when you install the OS and start it up.

Dynamic expansion does happen

This works as expected, as you and I have observed.

Dynamic shrinking is not promised

Again, the wizard states:

A dynamically expanding storage initially occupies a very small amount of space on your physical hard disk. It will grow dynamically (up to the size specified) as the Guest OS claims disk space.

Nowhere in this paragraph does the software suggest that the disk will ever shrink.

Dynamic shrinking is not useful

Having a dynamically shrinking partition is less useful. It would not result in a significant space or time savings. When you create a dynamic partition, you're making a contract with the guest OS that the hard drive will expand to the stated maximum size if and when it needs it. Dynamically resizing the drive to be smaller and using the space savings would create a conflict later when the guest OS needs to create a large file, perhaps when building a swap space for hibernation.

Dynamic shrinking does not happen

Again, you and I have both observed that this does not occur.

Conclusion

For these reasons, I conclude that you are getting the correct file size, and it's almost certainly correct. You can create 1 GB files as often as you like, but their removal will not decrease the size of the virtual disk.

You must log in to answer this question.

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