Thursday, June 1, 2017

Lazy sysprep without answer file

Background:

  There exist many ways to sysprep a system under a KVM system, but I only need a minimum set of configurations (like to Start Menu items, show all known file types by default and a default user account. There is a very simple way (without using an unattended.xml answer file) to do this.
This method is tested on a Windows 10 Enterprise Edition. It will sysprep the operating system but will skip the user account creation process during next First-Time installation wizard, so that the account you used during the installation process is still valid. I tried using Windows Server 2016 but no settings (including account information, start menu items and default views) were preserved after the initialization.

Procedures:

  First install the operating system as usual, then run the below command on an evaluated command prompt. Note the "/quit" switch different from most of the other guidelines on the web. We need to edit the registry so we still need the system up and running after sysprep.
sysprep /generalize /oobe /mode:vm /quit
Following the completion of the sysprep task, run "regedit" and add the below DWORD (32 bit) value. Set it to 1.
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\OOBE\UnattendCreatedUser
I am using KVM as the hypervisor, so after the guest is shut down I just copy the qcow2 disk file and dumpxml as the template xml. The creation of template can be done using:
virt-clone --original-xml /template/xml/path --name name_of_new_vm --file /new/qcow2/image/name

No comments:

Post a Comment