I’m experiencing a Windows10 VM on OpenStack that automatically restarts on successful autologon. Struggling with this for a while and hours spent in search of this topic on google went in vain. Followed the below step-by-step procedure to find the root cause and stop Windows10 VM on OpenStack from automatically restarting!
Wondered why Windows restarts automatically? Thankfully, Windows tracks the events and records in the system log. With the built-in Windows Event Viewer, you can monitor the activities that occur on your computer before, during, and after it shuts down or restarts. This article helped me to view the system logs in Windows10 that triggered the automatic restart.
View Shutdown and Restart log from Event Viewer
Open Event Viewer app
Navigate to Windows Logs -> System
on the left pane. Wait until all the logs are loaded. Click on Filter Current Log
on the right pane. Type 41, 1074, 6006, 6008 into the textbox under includes/Excludes Event IDs and then click OK to filter the event logs.
From the filtered logs, found a suspicious log stating Cloudbase-Init has initiated the restart of the computer as below:
This provided a hint to research further and found a bug reported in launchpad related to cloudbase-init. Below is my understanding of why the automatic restart was happening:
From our cloudbase-init unattend.xml
file (C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\unattend.xml
) you can notice that cloudbase-init tries to set the hostname in the specialize settings. This causes a SetComputerName function to run during the specialize step, which changes the computer name to DESKTOP-<random string>
. A known issue in Windows10 is that a change to the computer name requires a restart.
How to stop Windows10 VM on OpenStack from automatically restarting!
Thanks to Curt Moore for his quick solution. The same I have tried to explain in detail below:
Step 1: Install Cloudbase-init using the MSI as normal, except DO NOT have it perform an automatic sysprep during the autoinstallation.
Step 2: After the Cloudbse-init installation is complete, run the following command from the command prompt (Run as administrator) to disable the automatic startup of the Windows service version of cloudbase-init.
sc config cloudbase-init start= disabled
Step 3: Edit the unattend.xml file and add another RunSynchronousC
node to re-enable the automatic start 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. The idea is that if we re-enable the cloudbase-init service (but do not restart it at this time) upon the reboot required by the unattended cloudbase-init, the Windows service instance will start as desired and will not be in contention with the unattended instance since it will have already executed. Below is the modified unattend.xml
file:
Step 4: After editing the unattend.xml
file, manually run sysprep command from the command prompt (Run as administrator) and reference the modified XML.
C:\Windows\system32>"%SYSTEMROOT%\system32\ sysprep\ sysprep. exe" /generalize /oobe /quit /unattend:C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\unattend.xml
Step 5: Release the Windows IP configuration after the sysprep and then immediately shutdown the VM.
ipconfig /release shutdown /s /f /t 1
Now upload the Windows VM to OpenStack and boot an instance. Voila! the Windows10 VM autologged in and didn’t restart!