VMware ESXi Check Disk for Errors and Repair (VMKFSTOOLS)

Wonder how to check ESXi disk failures from command line, and how to fix it? Find answers in this post.

Delia

By Delia / Updated on March 8, 2023

Share this: instagram reddit

VMware ESXi: How to check disk for errors

A VMDK file, as its full name "Virtual Machine Disk" suggests, is a virtual disk that contains all the information about a VM and is commonly used in cloud and virtual computing. For VMware ESXi, a VMDK file mainly consists of a virtual disk descriptor diskname.vmdk and a virtual disk extent diskname-flat.vmdk which holds the raw files.

The importance of the VMDK file is undeniable, but when you manage a large number of VMs, it is possible that one or more VMDK files get corrupted or lost for various reasons (such as unexpected file termination, forced system shutdown, virus, etc.), and you may fail to power on the virtual machine as a result.

If any of your .vmdk files are broken, you can use the VMKFSTOOLS to perform different storage operations, such as checking and repairing a faulty VMDK file.

VMware ESXi

How to check ESXi disk failures from Command Line

VMKFSTOOLS is the ESXi Shell commands used to manage VMFS volumes, storage devices, and virtual disks. You can use it to perform many operations for VMFS volumes and virtual disks. For example, create and manage VMFS datasets on physical partitions, manipulate virtual disk files, check or repair VMDK files, etc.

ESXi check disk for errors using VMKFSTOOLS:

✍Note: SSH is disabled by default. Before using vmkfstools commands, please enable SSH and connect to ESXi host as root via SSH. On Windows, you can use PuTTY as an SSH client for running ESXi shell commands remotely.

To check the integrity of the virtual disk, use -x and the check option (replace the datastore and disk name or yours):

vmkfstools -x check /vmfs/volumes/my_datastore/my_disk.vmdk

If no error detected, VMKFSTOOLS will return “disk is error free”. If there’s indeed something wrong, you can use the following command to repair the corrupted virtual disk:

vmkfstools -x repair /vmfs/volumes/my_datastore/my_disk.vmdk

vmkfstools

After you make a change using VMKFSTOOLS, the vSphere Client might not be updated immediately. You can use a refresh operation from the client.

Can you run chkdsk on a virtual machine?

Some users have this question: Is it OK to run chkdsk on a virtual machine for troubleshooting, or does it make sense to do so?

Since a virtual machine simulates the full functionality of a hardware system through software, anything that can be done in a physical computer can be done in a virtual machine. So can running chkdsk inside the guest OS of a VM have the same effect as in a physical machine?

CHKDSK

Some people don't recommend this for security reasons, arguing that chkdsk will try to check the entire storage area. Actually, if you start chkdsk on a virtual machine, it will only scan the virtual disk it is on, not the entire physical drive. It is generally not possible to go beyond the vdisk allocated within the VM.

The main use of chkdsk is to detect and repair corrupted file systems, for which it doesn't matter if it is on a physical hard disk, or a virtual hard disk. Running chkdsk helps file system consistency, and it is essential especially if you need to backup virtual machines continuously.

Note: VMKFSTOOLS cannot fix all the ESXi disk errors

Although VMKFTOOLS is the most common means to check ESXi disk for errors, it often happens that the VMDK cannot be repaired by it normally, just as physical disk problems cannot always be repaired by chkdsk. If your virtual machines are hosting some really important data or business, it's best not to count on repairing it after something goes wrong.

When the virtual machine goes wrong and cannot be fixed normally, you can consider opening VMDK file to copy necessary contents from it. But to truly prevent such problems, VM backup is a simple yet effective means. With ESXi VMs backed up regularly, you can always restore them to a usable state when needed.

Here I will introduce a reliable VMware backup software - AOMEI Cyber Backup as an example. It works with VMware ESXi 6.0 and above versions (free ESXi is also supported). You can easily add ESXi host or vCenter to a web console for automated virtual machine backup & restore.

If any of your VMs goes down, you can easily perform a recovery, or even restore the VM to another host (as well as datastore, vCenter) as you need.

Download the 30-day free trial by simply hitting on the button below:

Download Free TrialVMware ESXi & Hyper-V
Secure Download

*You can choose to install this VM backup software on either Windows or Linux system.

Easy-to-use: Centralized web console and intuitive user interface to achieve any operation with simple clicks.

Select virtual machines vCenter

Automation: Create schedules to automate VM backup, and enable retention policy to auto delete old backups.

Schedule vm backup

Flexible recovery: When you want to recover or migrate a virtual machine to another location, select any backup version you want, and choose either Restore to original location or Restore to new location.

With the second option, you can perform an out-of-place recovery to create an identical VM from the backup to the same or datastore/host/vCenter (optional), without reinstalling or configuration the new VMs.

Restore to new location

Conclusion

In practical use, it’s possible that your VMDK files get corrupted and the virtual machine can’t even start. Thus, you may wonder how to check ESXi disk failures from command line.

In the above article, I introduced the way to check ESXi disk for errors using VMKFSTOOLS, it can detect some virtual disk issues and try to repair it. However, not all the errors can be fixed in this way. To minimize the possible loss, it’s best to adopt an efficient VMware backup solution and make backups regularly.

Delia
Delia · Editor
Delia owns extensive experience in writing technology-related blog posts, and has been a part of AOMEI since 2020 to provide expertise in data security and disaster recovery. She works with Windows operating systems, SQL databases, and virtualization platforms such as VMware and Hyper-V, specializing in troubleshooting and advising on data protection and migration.