Storagepipe Is Now Thrive

GridWay Is Now Thrive

Tips & Tricks

Troubleshooting Windows Server Sysprep Issues with Cloudbase-Init

Troubleshooting Windows Server Sysprep Issues with Cloudbase-Init

Have you had issues deploying a VM template with CloudBase-Init? Perhaps it works sometimes when you deploy the template but most of the time it fails with this error during the startup process like the screenshot below. Thrive utilizes a tool from our partner Abiquo that we use to provision virtual machines for our customers in a secure and repeatable way. Our tools utilize CloudInit for Linux and Cloudbase-Init for Windows to inject bootstrap information to automate the initial configuration.

The computer restarted unexpectedly or encountered an unexpected error. Windows installation cannot proceed. To install Windows. click “OK’ to restart the computer. and then restart the installation

The work around for the boot issue is a quick registry edit: While at the above screen don’t click okay – instead hit Shift+F10, type registry.exe in the command box that comes up and change the value of HKLM/SYSTEM/Setup/Status/ChildCompletion/setup.exe to 3 then reboot. However, we wouldn’t want to do that with every single templated machine that we deploy.

The problem comes down to a race condition of the specialize phase during sysprep and the way Cloudbase-Init was installed on this template. When installing CBI its common to not use the option at the end of the installer to immediately perform a sysprep operation but that skips some of the logic that it does. To work around that we need to edit the Unattend.xml file as well as change the cloudbase-init service.

  1. After the Cloudbase-init installation is complete, run the following in an elevated command command prompt or use services.msc to disable automatic startup of the Windows service
    1.    sc config cloudbase-init start= disabled
  1. Edit the unattend.xml in C:\Program Files\Cloudbase Solutions\ file to enable automatic startup mode of the cloudbase-init Windows service. This command _must_ be set as <Order>1</Order> and the existing unattended cloudbase-init node set to <Order>2</Order> so that the re-enable command runs prior to the unattended instance of cloudbase-init, which requires a reboot.

<RunSynchronousCommand wcm:action=”add”>


<Path>sc config cloudbase-init start= auto</Path>

<Description>Re-enable auto start of cloudbase-init</Description>



  1. Perform any remaining customization steps and application installs you need to do. For example we change the cloudbase-init config files to run particular plugins
  2. Assuming you use the default install directories then create a batch file in C:\Program Files \Cloudbase Solutions\Cloudbase-Init\conf with the following”
    1. Cd C:\Program Files \Cloudbase Solutions\Cloudbase-Init\conf
    2. Ipconfig /release
    3. c:\windows\system32\sysprep\sysprep.exe /generalize /oobe /mode:vm /shutdown /unattend:unattend.xml
    1. Now is a good time to snapshot your VM
    2. Launch an admin command prompt. Navigate to ‘C:\Program Files \Cloudbase Solutions\Cloudbase-Init\conf’ and execute the batch file to sysprep and shutdown your template
  1. Clone this VM and convert to a template or ingest it to whatever tool you’re using. That will leave you with the base VM you can quickly apply Windows patches to in the future and just run the batch script to sysprep next time without having to rearm it.

Note: If you are using dissimilar hardware between where you built the template and when its eventually deployed you may also need to remove the following from the Unattend.xml file <PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>

Here is an example modified unattend.xml

We hope this helps you in your journey to automating the cloud!

Reference Links: specifically the post from Curt Moore (jcmoore) on 2015-03-08