Windows fails to start and generates the following error:
Info: The operating system couldn't be loaded because the kernel is missing or contains errors.
This issue occurs if the file system is corrupted.
How to fix
To fix the issue, follow these steps.
- Delete the virtual machine (VM). Make sure that you select the Keep the disks option when you do this.
- Attach the OS disk as a data disk to another VM (a troubleshooting VM). For more information, see How to attach a data disk to a Windows VM in the Azure portal.
- Connect to the troubleshooting VM, and then open Computer management > Disk management. Make sure that the OS disk is online and that its partitions have drive letters assigned.
- Use the WinRE image located in every Windows installation (Recover console image) as a repository to try to fix the corruption. Volume G is the drive of the broken OS disk:
Dism /image:g:\ /cleanup-image /restorehealth /source:wim:g:\recovery\windowsRE\winre.wim:1
- If the command line states there's corruption but the required file cannot be found, download an ISO for the Windows version of that disk to the troubleshooting machine.
- Extract the media ISO, and then locate the WIM file inside and use that as the repository:
Dism /image:g:\ /cleanup-image /restorehealth /source:wim:<WIM FILE FROM ISO>:1
- Recreate the VM.
If the VM still doesn't boot, go to step 2.
- Run DISM. On the sample line below, G is the drive of the broken OS disk:
dism.exe /image:g:\ /cleanup-image /restorehealth
- Run System File Checker (SFC). On the sample line below, G is the drive of the broken OS disk:
sfc /scannow /offbootdir=g:\ /offwindir=g:\windows
- If SFC detects corruption but cannot fix it, go to step 3.
- If SFC states that the corruption is fixed, detach the OS disk from the troubleshooting VM, and wait until Azure updates the disk lease (3 minutes at most).
- Recreate the VM.