Troubleshoot "Preparing Automatic Repair" mode

更新时间:
复制 MD 格式

This topic describes why a Windows instance might fail to start and enter "Preparing Automatic Repair" mode, and how to resolve the issue.

Symptoms

When you start a Windows instance, the operating system fails to load and enters repair mode, displaying a "Preparing Automatic Repair" message.

image.png

Causes

This issue has several possible causes. Use the instance health diagnostics tool to identify the specific cause, and then find the corresponding solution in the table below. For more information about how to use the instance health diagnostics tool, see Use the self-service troubleshooting feature to resolve instance issues.

Diagnostic message

Solution

The Windows partition of the instance does not exist or some files are missing, which prevents the operating system from starting.

This issue typically occurs when an instance created from a problematic custom image fails to start. To resolve this, create a new image and use it to replace the operating system of the instance. For more information, see Create a Windows image and replace system disk.

The file system of the Windows partition is not NTFS, which prevents the operating system from starting.

The disk space allocated to the Windows partition is too small (less than 20 GB), which prevents the operating system from starting.

You can extend the disk. For more information, see Extend partitions and file systems for a Windows instance.

The Windows partition of the instance is read-only, which prevents the operating system from starting.

Clear the read-only attribute of the Windows partition

The Windows partition of the instance is hidden, which prevents the operating system from starting.

Clear the hidden attribute of the Windows partition

A critical registry file of the instance is missing, which prevents the operating system from starting.

Repair a corrupted registry file

A critical registry file of the instance is corrupted, which prevents the operating system from starting.

The Boot Configuration Data (BCD) file of the instance is missing, which prevents the operating system from starting.

Configure Windows boot settings

The content of the Boot Configuration Data (BCD) file is corrupted, which prevents the operating system from starting.

The Windows Boot Manager (BootMgr) file is missing, which prevents the operating system from starting.

The content of the Windows Boot Manager (BootMgr) file is corrupted, which prevents the operating system from starting.

The boot device or disk specified in the Windows Boot Manager (BootMgr) configuration does not exist, which prevents the operating system from starting.

The bootloader of the instance is missing, which prevents the operating system from starting.

Clear the read-only attribute of the Windows partition

To clear the read-only attribute of the Windows partition, attach a repair disk to the affected instance and follow these steps:

  1. Connect to the faulty instance.

    On the Diagnostic Result page, click VNC Connection. Then, enter the Administrator username and password provided in the diagnostic report to log on to the ECS instance to which a repair disk is attached. For more information, see Connect using VNC.

  2. Clear the read-only attribute of the Windows partition.

    You can use one of the following methods.

    DiskPart utility

    Assume that the drive letter of the target partition is D. Perform the following steps:

    1. Open the DiskPart window.

      Type diskpart in the search box, or open Windows PowerShell and run the diskpart command.

    2. Select the target volume.

      select volume D
    3. Clear the read-only attribute.

      attribute volume clear readonly

    PowerShell command

    In this example, the disk number is 1 and the target partition number is 1.

    Set-Partition -DiskNumber 1 -PartitionNumber 1 -IsReadOnly $false
  3. On the Instance page, move the pointer over the Fixing state that corresponds to the instance and click Detach Repair Disk.

  4. Restart the instance to allow the preceding configurations to take effect.

    For more information, see Restart an instance.

  5. Connect to the ECS instance. If you can connect to the ECS instance as expected, the preceding issue is resolved.

    For more information, see Connect to Windows.

Clear the hidden attribute of the Windows partition

To clear the hidden attribute of the Windows partition, attach a repair disk to the affected instance and follow these steps:

  1. Connect to the faulty instance.

    On the Diagnostic Result page, click VNC Connection. Then, enter the Administrator username and password provided in the diagnostic report to log on to the ECS instance to which a repair disk is attached. For more information, see Connect using VNC.

  2. Clear the hidden attribute of the Windows partition. In this example, the disk number of the affected system disk is 0, and the hidden partition number is 1.

    You can use one of the following methods.

    DiskPart utility

    1. Open the DiskPart window.

      Type diskpart in the search box, or open Windows PowerShell and run the diskpart command.

    2. Select the target disk.

      select disk 0
    3. Select the hidden partition.

      select partition 1
    4. Clear the hidden attribute.

      attribute volume clear hidden

    PowerShell command

    Run the following command in Windows PowerShell:

    Set-Partition -DiskNumber 0 -PartitionNumber 1 -IsHidden $false
  3. On the Instance page, move the pointer over the Fixing state that corresponds to the instance and click Detach Repair Disk.

  4. Restart the instance to allow the preceding configurations to take effect.

    For more information, see Restart an instance.

  5. Connect to the ECS instance. If you can connect to the ECS instance as expected, the preceding issue is resolved.

    For more information, see Connect to Windows.

Repair a corrupted registry file

Method 1: Repair in repair mode

  1. When the instance enters repair mode, click Startup Repair to fix the startup failure.

    image.png

  2. Choose a repair method based on whether a registry backup exists.

    • If a registry backup exists, use the backup to replace the corrupted registry file.

      Note

      By default, registry backups are stored in C:\Windows\System32\config\regback.

    • If no registry backup is available, use one of the following methods to attempt a repair:

      • Run the dism /Image:D: /Cleanup-image /Restorehealth command.

      • Run the sfc /scannow /offbootdir=D:\ /offwindir=D:\Windows /offlogfile=C:\sfclog.txt command.

  3. Connect to the ECS instance. If you can connect to the ECS instance as expected, the preceding issue is resolved.

    For more information, see Connect to Windows.

Method 2: Use a repair disk

To repair the corrupted registry file, attach a repair disk to the affected instance and follow these steps. This example assumes the mounted disk is drive D.

  1. Connect to the faulty instance.

    On the Diagnostic Result page, click VNC Connection. Then, enter the Administrator username and password provided in the diagnostic report to log on to the ECS instance to which a repair disk is attached. For more information, see Connect using VNC.

  2. Choose a repair method based on whether a registry backup exists.

      • If a registry backup exists, use the backup to replace the corrupted registry file.

        Note

        By default, registry backups are stored in D:\Windows\System32\config\regback.

      • If no registry backup is available, use one of the following methods to attempt a repair:

        • Run the dism /Image:D: /Cleanup-image /Restorehealth command.

        • Run the sfc /scannow /offbootdir=D:\ /offwindir=D:\Windows /offlogfile=C:\sfclog.txt command.

  3. Connect to the ECS instance. If you can connect to the ECS instance as expected, the preceding issue is resolved.

    For more information, see Connect to Windows.

Configure Windows boot settings

If the instance fails to start due to an incorrect boot configuration, attach a repair disk to the instance to reconfigure the boot settings.

  1. Connect to the faulty instance.

    On the Diagnostic Result page, click VNC Connection. Then, enter the Administrator username and password provided in the diagnostic report to log on to the ECS instance to which a repair disk is attached. For more information, see Connect using VNC.

  2. Run Command Prompt as an administrator.

  3. Use the BCDboot tool to reconfigure the boot settings.

    The command varies based on the boot mode. Assume that the drive letter of the system partition is S and the drive letter of the Windows partition is C. The commands are as follows:

    • BIOS boot mode: bcdboot C:\Windows /s S:

    • UEFI boot mode: bcdboot C:\Windows /s S: /f UEFI

      Note

      If a bootable Windows system is available on drive D in addition to drive C, you can configure multiple boot entries. Use the following commands:

      • BIOS boot mode: bcdboot D:\Windows /s S: /d /p /addlast

      • UEFI boot mode: bcdboot D:\Windows /s S: /d /p /addlast /f UEFI

  4. After the configuration is complete, use the following command to view the boot entries.

    • BIOS boot mode: bcdedit /store S:\Boot\BCD

    • UEFI boot mode: bcdedit /store S:\EFI\Microsoft\Boot\BCD

      A message similar to the one in the following figure indicates that the boot entries were configured successfully.

      image.png

  5. On the Instance page, move the pointer over the Fixing state that corresponds to the instance and click Detach Repair Disk.

  6. Start the ECS instance.

    For more information, see Start an instance.