Mac – Does a fixed size Virtual Machine file (vmdk, etc..) become fragemented

defragmenthard drivevirtual machine

Just sort of remembered something from OS class about fragmentation and was wondering if anyone knows for sure whether a VM file is liable to become fragmented if you tell it what size the hard drive should be from the outset.

I'm not asking whether the files in the VM can become fragmented, if they're truly a virtual machine then anything that can happen to a physical hard drive can happen to a virtual hard drive.

What I am asking is whether when virtual machines change the state of a particular session, does the big huge file itself get fragmented. I'd imagine that a fragmented virtual machine file can be a big problem because you could be reaching over several platters for data that a regular hard drive would keep right next to each other.

For instance, if I have 30 gigabytes free and I create a 20 gigabyte VM file (fixed size), there may be a good chance that the file is not occupying contiguous space on my hard drive. In a perfect world, defrag might be able to fix that.

But say I've got 150 gig's free, I get add a 20 gig VM (fixed size) then I download all of Star Trek The Next Generation, leaving me with 5 gigabytes of free space. I open and close my virtual machine 900 times. Do I have fragmentation in my VM or does it still occupy the same awesome contiguous hunk?

Best Answer

The if you pre-allocate the entire space, instead of having a grows-as-needed volume, then there should not be any fragmentation.

I don't know for certain, but I would think it would be wise to pre-allocate the entire space, and then defragment the disk, just to be sure.

Related Question