Recently we had an issue where one of our remote sites had frequent power failures.
Upon closer investigation it was found that the 3kVa UPS was overloaded (with 3.4kVa) instead of a healthy 2.2kVa.
This caused the servers to yoyo down and up, which’s Not A Good Thing.
On this site we had a cluster setup (two blades, server2016 and a 2k16 NAS). One of the iSCSI virtual drives got corrupted (vhdx virtual disk)
The easiest (and quickest) way out of this mess was to start up diskpart, attach the corrupted VHDX image and run CHKDSK on it, and we were home free.
- Create a backup of the affected VHDX file.
- Open an elevated command prompt.
- Type in diskpart and press enter.
- Before mounting or unmounting virtual disk, you need to specify the location of your vhd/vhdx file. Type the following command and hit Enter.
select vdisk file="[location of vhd]"
- Once that is done, type in attach vdisk
The disk should show up in Drive Manager or Windows Explorer. You can then run a regular chkdsk /f on it.
To unmount it, either right-click on it and eject it, or type in detach vdisk and press Enter.
You can also use PowerShell to do the same job, but you’ll need Hyper-V installed for this to work (which I could not do as it was on the NAS and the NAS does not need Hyper-V installed) :
- Open PowerShell as Administrator.
- When the command-line window opens, you can run the Mount-VHD cmdlet to mount your vhd/vhdx file.
Mount-VHD –Path “[location of vhd]”
To unmount your virtual hard disk, just run the Dismount-VHD cmdlet instead.
Dismount-VHD –Path “[location of vhd]”
If you get the error message like “Mount-VHD is not recognized as the name of a cmdlet“, you need to add a feature named “Hyper-V Module for Windows PowerShell” to your server.
Gratuitiously copied from https://www.top-password.com/blog/mount-and-unmount-vhd-vhdx-from-command-line/ without permission.