VMware Communities
stasra
Contributor
Contributor
Jump to solution

Defragment files

Is there any adverse impact associated with defragmenting files within virtual machines? What about checking disk for errors?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
rcardona2k
Immortal
Immortal
Jump to solution

Checking the disk is a harmless operation (w/ chkdsk, etc). Defragmenting a virtual disk that is a dynamically-allocating virtual drive can inadvertently expand the size way beyond the space allocated depending on the methods your defragmentation utility uses. You can reclaim the space by using VMware Tools Shrink but be aware that Shrink can be disabled by having a running snapshot. For pre-allocated disks, there is no harm in defragmenting as the disk is already occupying all the space it will on the host, however if you have a snapshot on a pre-allocated disk the defragmentation changes are captured in the snapshot, not to the pre-allocated disk itself, this will increase the size of the snapshot file(s), potentially sizeably. Your best best is to discard or revert your snapshot then defragment or defragment and Shrink, if necessary.

View solution in original post

0 Kudos
3 Replies
rcardona2k
Immortal
Immortal
Jump to solution

Checking the disk is a harmless operation (w/ chkdsk, etc). Defragmenting a virtual disk that is a dynamically-allocating virtual drive can inadvertently expand the size way beyond the space allocated depending on the methods your defragmentation utility uses. You can reclaim the space by using VMware Tools Shrink but be aware that Shrink can be disabled by having a running snapshot. For pre-allocated disks, there is no harm in defragmenting as the disk is already occupying all the space it will on the host, however if you have a snapshot on a pre-allocated disk the defragmentation changes are captured in the snapshot, not to the pre-allocated disk itself, this will increase the size of the snapshot file(s), potentially sizeably. Your best best is to discard or revert your snapshot then defragment or defragment and Shrink, if necessary.

0 Kudos
stasra
Contributor
Contributor
Jump to solution

Thanks for your insight. How about fixing discovered errors on a disk?

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

You never stated what OS(es) and as such the tools are different between OSes. Also with file based virtual disks you will not encounter physical disk errors only file system structure relegated type errors and one can attempt to correct it using the appropriate tool base on the OS. In Windows XP as an example you can issue a chkdsk /f c: command and it prompt to be scheduled on reboot. Consult the documentation on the tool you plan to use. Obviously with a Boot Camp partition Virtual Machine Phyical Disk error can be detected however I would opt not to correct it while running the Boot Camp partition as a Virtual Machine. Also checking the Host OS for errors once in a while is a good practice.

I would also like to add that I also never preform disk level operations like repairing or defraging without a current data backup as a precaution against something going wrong as it can and does at times.