PC Cert Student - Hyper-v VM not booting into OS - how to run SFC or DISM on VM that won't boot

Wonder Woman 116 Reputation points
2021-07-04T01:01:30.003+00:00

Hello,

I am in computer certification school during the CCP virus to upgrade my skills. The school has us building servers on various VM platforms and I am using Hyper-v on my laptop. I have run into a problem; I think my lab VM which is based on Win Server 2016 with AD installed might have become corrupted. I have already done a significant portion of lab work on this VM and would like to try to salvage my work instead of jumping right to starting from scratch. I cannot boot into the OS to run powershell I can only boot into the ISO installer because I get this error:

111530-vm-boot-error-ad-server-a.jpg

I am weak on my command line and powershell scripting/commands because I have a major failing with my skills. I am spoiled to GUI because I started (I am 54) on a Mac (Performa 400 - home equivalent of an LCII) back on System 7 (yup, long time ago in a galaxy far far away) and then transferred myself over to Win 3.1.1 totally skipping over DOS and command line; in other words spoiled to what I call "ya want it, ya see it, ya click it" so I am extremely weak on my command line and powershell and Linux skills.

The above statement does not mean I can't do it if I am told what to do. This is def something that the books don't cover.

Can someone please advise me how I can use tools like SFC or DISM or scandsk or anything else to try to correct the issue? I found reference online that Microsoft has a VM Repair Tool to fix corrupted VMs but I cannot find the link anywhere - just a reference to it being available. Does anyone know anything about that tool or have a link to it? If no, does anyone have any recommendations on tools to fix corrupted VM files?

Thank you in advance.........

Sincerely,

Wonder Woman

Windows Server 2016
Windows Server 2016
A Microsoft server operating system that supports enterprise-level management updated to data storage.
2,368 questions
Hyper-V
Hyper-V
A Windows technology providing a hypervisor-based virtualization solution enabling customers to consolidate workloads onto a single server.
2,533 questions
{count} votes

2 answers

Sort by: Most helpful
  1. JiayaoZhu 3,911 Reputation points
    2021-07-05T03:33:58.663+00:00

    Hi,

    Thanks for posting on our forum!

    Based on your condition, the reason why you cannot start your VM and got such an error message is that your boot disk (vhd or vhdx file) is not available or is corrupted. Since you can run your VM before, I think the issue cause may be the latter one, but we still need to check if your vhd(x) file is corrupted or not.

    You have two ways to troubleshoot if your issue is related to a corrupted vhd(x) file:

    1. Open your PowerShell by type PowerShell in the box at the left bottom corner of your screen, and right-click, choose Run as Administrator. When you enter into the console, type and run command:
      Dism /Online /Clean-Image /CheckHealth
      ——This command will help you to completely scan the VHD file for corruption.
      Dism /Online /Cleanup-Image /ScanHealth
      ——This command will tell you whether the VHD file is corrupted or not and it will also tell that is it possible to fix the VHD file.
      Dism /Online /Clean-Image /RestoreHealth
      ——This command will repair the VHD file.
    2. Create a new virtual machine, and during the creation process, choose "use existing virtual hardware disk". In this way, you can create a new VM with the problematic vhd(x) file. If this action is successful, then your vhd file should be fine. Besides, choose Gen1 when you create your new VM.

    If your vhd file is corrupted, you can also use PowerShell command to fix your corrupted vhd file.
    Run the PowerShell commands given below (change your details as per requirement):
    #First we choose what VHD we want mounted
    $VHDName = "V:\serverx.vhd"
    #Get the MSVM_ImageManagementService
    $VHDService = get-wmiobject -class "Msvm_ImageManagementService" -namespace "root\virtualization" -computername "."
    #Now we mount the VHD
    $Result = $VHDService.Mount($VHDName)
    #Now you can run a CHKDSK on this VHD file: chkdsk /f

    In addition, if you are not confident with PowerShell, there are a couple of other methods for you to try to fix your vhd file. Here are two methods:
    1) Create Virtual Server
    By creating a virtual server a corrupt VHD could be fixed. You have to follow the below steps to achieve the task: Create a new Virtual server and attach a new Hard Disk Drive to the server. Go to settings and attach the Hard disk. Browse for the VHD file in connected Hard drive. Now, select Virtual Disk Wizard and choose a Compact (Check-box states as convert it to a fixed size virtual hard disk). Now, you can save the VHD file at the selected location.
    2) Use third-party vhd recovery tools
    After my research, Windows VHD tool may be out-of-date and that's why you can hardly find the link any more. However, our Microsoft suggests Top 5 third-party tools (which are our partners) you can use, here is the link:
    https://www.microsoftpartnercommunity.com/t5/Partner-Best-practices/Top-5-VHD-File-Recovery-Tools-Seamless-Recovery-Solutions/m-p/5919

    Other approaches to fixing corrupted vhd files can be seen in this article (please focus on Method #5: Fix Hyper V VHDX Files With Inbuilt Utility):
    https://www.rescuedigitalmedia.com/fix-a-corrupted-hyper-v-vhdx-files
    (Please note: Information posted in the given link is hosted by a third party. Microsoft does not guarantee the accuracy and effectiveness of information.)

    And in this Docs, we also discuss the methods:
    https://learn.microsoft.com/en-us/archive/blogs/tonyso/how-to-fix-a-corrupted-hyper-v-vhd-file

    If your issue is not related with corrupted vhd file, give me the feedback and we can consider the unavailability of your boot disk.

    Thanks for your support!

    BR,
    Joan


    If the Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. JiayaoZhu 3,911 Reputation points
    2021-07-06T02:32:43.443+00:00

    Hi,

    Thanks for your reply!

    In my answer, I have stated:

    Run the PowerShell commands given below (change your details as per requirement):

    First we choose what VHD we want mounted

    $VHDName = "V:\serverx.vhd"

    Get the MSVM_ImageManagementService

    $VHDService = get-wmiobject -class "Msvm_ImageManagementService" -namespace "root\virtualization" -computername "."

    Now we mount the VHD

    $Result = $VHDService.Mount($VHDName)

    You have to firstly mount your vhd because you are going to troubleshoot your disk from your physical computer rather than from your virtual machine.

    SSD is physical hardware disk, the commands like DISM, SFC, CHKDSK are all used to fix softwares, such as operation system, except for that chkdsk /r can be used to troubleshoot bad sectors in physical hardware disk.

    In addition, you may not necessarily need to use DISM, for one thing, this command, as well as SFC are used to troubleshoot and fix the whole windows operation system. It is recommended to run SFC first. Then, run DISM /Online /Cleanup-image /RestoreHealth. SFC checks for Windows file integrity violations and tries to fix them. However, DISM is more effective at fixing corrupt Windows Operating System files. For another, DISM command is used in CMD rather than in PowerShell. Because DISM is used to test the whole system, then it does not matter whether you run the command on VM or on physical computer.

    Above all, we recommend you to use chkdsk on PowerShell. Firstly, you need to make sure you have backup your data on your Virtual machine. Then, just follow the steps I have suggested you: mount your target vhd and then use chkdsk C: (C: is where I stored my vhd files, you just need to replace it with the drive letter of the drive where you stored your problematic vhd file). Then, if there is any errors in your vhd, you can continue to run chkdsk C: /f to fix the errors.

    Thanks for your support! Hope to hear your good news! : )

    BR,
    Joan


    If the Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments