Discussion:
[virt-tools-list] How to: Unattended Windows installs in virt-install
Richard W.M. Jones
2018-09-12 14:37:27 UTC
Permalink
I have worked out how to do (almost) unattended installs of Windows
guests using virt-install. This reveals some issues with
virt-install, although maybe they are not bugs.

The virt-install command and autounattend.xml file are attached. You
will need to:

(1) Put build.sh into a directory.

(2) Create config/ subdirectory.

(3) Put autounattend.xml into the config/ subdirectory. Edit the file
to add your product key.

(4) Download Windows ISO somewhere (modify the path in build.sh).

(5) Run ./build.sh

The result is very large. Windows Server 2012R2 takes 5.3 GB!

- - -

The first problem with virt-install I had was that when you use
multiple CD-ROMs virt-install doesn't choose a sensible boot order.
That's the reason for the ,boot_order=XX attributes. It seems like
this used to work in some old version of virt-install, see:

https://serverfault.com/questions/644437/unattended-installation-of-windows-server-2012-on-kvm

The second problem is that --transient can't be used. This is because
the guest reboots at least once during installation (and after the
first reboot the guest is in a half-installed state which looks
sufficiently like the install worked as far as virt-install is
concerned).

- - -

There are also several problems with the current autounattend file or
Windows itself.

I couldn't get Windows to install virtio drivers even though I
supplied the virtio ISO. I guess some change is needed to the XML
(perhaps: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/add-device-drivers-to-windows-during-windows-setup ).

Windows still asks for the installation language. Apparently using
language='en-US' is incorrect or insufficient to suppress this.

You must supply a valid ProductKey. I couldn't work out how to defer
activation until after installation.

I'm using these as virt-builder templates. However really they need
to be sysprepped (using the Windows tool), so they are not really
templates. For my purposes where I'm not distributing them this is
sort of fine.

Windows is extremely unhelpful if there's a problem with the XML.
However I found you can debug it like so:

(a) On the failure screen, press [Shift] + F10.

(b) cd X:\Windows\Panther\

(c) type setupact.log

(d) Examine the log file to see the real error.


Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
Christophe Fergeau
2018-09-12 15:49:52 UTC
Permalink
Post by Richard W.M. Jones
There are also several problems with the current autounattend file or
Windows itself.
I couldn't get Windows to install virtio drivers even though I
supplied the virtio ISO. I guess some change is needed to the XML
(perhaps: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/add-device-drivers-to-windows-during-windows-setup ).
Windows still asks for the installation language. Apparently using
language='en-US' is incorrect or insufficient to suppress this.
libosinfo generates this:

<component xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" versionScope="nonSxS" publicKeyToken="31bf3856ad364e35" name="Microsoft-Windows-International-Core-WinPE" language="neutral" processorArchitecture="x86">
<SetupUILanguage>
<UILanguage>fr-FR</UILanguage>
</SetupUILanguage>
<SystemLocale>fr-FR</SystemLocale>
<UILanguage>fr-FR</UILanguage>
<UserLocale>fr-FR</UserLocale>
</component>

(though not 100% sure that fr-FR is a correct language ;)
You can check the whole xml file it generates with:
osinfo-install-script windows.iso --config=l10n-language=fr-FR --config=reg-product-key=XXXX

Christophe
Richard W.M. Jones
2018-09-12 16:00:14 UTC
Permalink
Post by Christophe Fergeau
Post by Richard W.M. Jones
There are also several problems with the current autounattend file or
Windows itself.
I couldn't get Windows to install virtio drivers even though I
supplied the virtio ISO. I guess some change is needed to the XML
(perhaps: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/add-device-drivers-to-windows-during-windows-setup ).
Windows still asks for the installation language. Apparently using
language='en-US' is incorrect or insufficient to suppress this.
<component xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" versionScope="nonSxS" publicKeyToken="31bf3856ad364e35" name="Microsoft-Windows-International-Core-WinPE" language="neutral" processorArchitecture="x86">
<SetupUILanguage>
<UILanguage>fr-FR</UILanguage>
</SetupUILanguage>
<SystemLocale>fr-FR</SystemLocale>
<UILanguage>fr-FR</UILanguage>
<UserLocale>fr-FR</UserLocale>
</component>
(though not 100% sure that fr-FR is a correct language ;)
osinfo-install-script windows.iso --config=l10n-language=fr-FR --config=reg-product-key=XXXX
Nice feature I didn't know about. I may try to integrate this with
the script I'm writing to make virt-builder templates.

Thanks,

Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/
Peter Crowther
2018-09-12 16:42:22 UTC
Permalink
Don't do it with multiple CD-ROM drives, use a floppy with the virtio
drivers and the autounattend. I use mtools to build this from a source
floppy image. More when I'm near a real keyboard and a git repo!

Peter
Post by Richard W.M. Jones
I have worked out how to do (almost) unattended installs of Windows
guests using virt-install. This reveals some issues with
virt-install, although maybe they are not bugs.
The virt-install command and autounattend.xml file are attached. You
(1) Put build.sh into a directory.
(2) Create config/ subdirectory.
(3) Put autounattend.xml into the config/ subdirectory. Edit the file
to add your product key.
(4) Download Windows ISO somewhere (modify the path in build.sh).
(5) Run ./build.sh
The result is very large. Windows Server 2012R2 takes 5.3 GB!
- - -
The first problem with virt-install I had was that when you use
multiple CD-ROMs virt-install doesn't choose a sensible boot order.
That's the reason for the ,boot_order=XX attributes. It seems like
https://serverfault.com/questions/644437/unattended-installation-of-windows-server-2012-on-kvm
The second problem is that --transient can't be used. This is because
the guest reboots at least once during installation (and after the
first reboot the guest is in a half-installed state which looks
sufficiently like the install worked as far as virt-install is
concerned).
- - -
There are also several problems with the current autounattend file or
Windows itself.
I couldn't get Windows to install virtio drivers even though I
supplied the virtio ISO. I guess some change is needed to the XML
https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/add-device-drivers-to-windows-during-windows-setup
).
Windows still asks for the installation language. Apparently using
language='en-US' is incorrect or insufficient to suppress this.
You must supply a valid ProductKey. I couldn't work out how to defer
activation until after installation.
I'm using these as virt-builder templates. However really they need
to be sysprepped (using the Windows tool), so they are not really
templates. For my purposes where I'm not distributing them this is
sort of fine.
Windows is extremely unhelpful if there's a problem with the XML.
(a) On the failure screen, press [Shift] + F10.
(b) cd X:\Windows\Panther\
(c) type setupact.log
(d) Examine the log file to see the real error.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
_______________________________________________
virt-tools-list mailing list
https://www.redhat.com/mailman/listinfo/virt-tools-list
Tomáš Golembiovský
2018-09-12 17:23:07 UTC
Permalink
Hi,

we were experimenting with unattended Windows installation in RHV about
a year ago and failed terribly. But that is because our requirement was
to have one XML template and one source of drivers for all Windows
versions. So if you are willing to give up a dream of having one-for-all
solution then it is possible.

More comments below.


On Wed, 12 Sep 2018 15:37:27 +0100
Post by Richard W.M. Jones
I have worked out how to do (almost) unattended installs of Windows
guests using virt-install. This reveals some issues with
virt-install, although maybe they are not bugs.
The virt-install command and autounattend.xml file are attached. You
(1) Put build.sh into a directory.
(2) Create config/ subdirectory.
(3) Put autounattend.xml into the config/ subdirectory. Edit the file
to add your product key.
(4) Download Windows ISO somewhere (modify the path in build.sh).
(5) Run ./build.sh
The result is very large. Windows Server 2012R2 takes 5.3 GB!
- - -
The first problem with virt-install I had was that when you use
multiple CD-ROMs virt-install doesn't choose a sensible boot order.
That's the reason for the ,boot_order=XX attributes. It seems like
https://serverfault.com/questions/644437/unattended-installation-of-windows-server-2012-on-kvm
The second problem is that --transient can't be used. This is because
the guest reboots at least once during installation (and after the
first reboot the guest is in a half-installed state which looks
sufficiently like the install worked as far as virt-install is
concerned).
- - -
There are also several problems with the current autounattend file or
Windows itself.
I couldn't get Windows to install virtio drivers even though I
supplied the virtio ISO. I guess some change is needed to the XML
(perhaps: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/add-device-drivers-to-windows-during-windows-setup ).
There is DriverPaths element for that. See the attached XML.

Specifying the path is tricky. Every Windows version has different bugs
and behavior.

You can either have a general path (like "A:\amd64") but then you need
to supply only drivers suitable for the Windows version you are
installing. And by suitable I mean not newer and not (too) older. That's
because some versions pick the wrong drivers and BSOD.

Maybe easier solution is to specify complete path (e.g.
"A:\amd64\w2008\"). But then you should make sure you have all the
necessary drivers there. I'm not sure about virtio-win ISO, but IIRC the
floppy image relies on the fact that some windows versions use same
driver to save space and not all drivers are in all directories. If you
now think "heck, how can this work" and that I'm contradicting the
previous paragraph then... surprise, surprise... the detection of
compatible drivers works when you do that in GUI.

Another complication here is drive letters in paths. You can either have
derivers on a floppy (and you know it is A). Or you can have drivers on
CD or (read-only!) USB but then you have to know number of your disks
and the expected drive letter it will get assigned. Specifying all paths
with all possible drive letters in the XML generally does not work.
Again, some version can deal with that, some versions don't.
Post by Richard W.M. Jones
Windows still asks for the installation language. Apparently using
language='en-US' is incorrect or insufficient to suppress this.
I don't recall if I ever needed this.
Post by Richard W.M. Jones
You must supply a valid ProductKey. I couldn't work out how to defer
activation until after installation.
You can use generic license keys [1] for that. They last for 30 days after
which you need to activate the OS. Although now that I think of it, it's
probably inconvenient for your use case. You will need to regenerate the
templates regularly.

Hope this helps,

Tomas

[1] https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/jj612867(v=ws.11)
Post by Richard W.M. Jones
I'm using these as virt-builder templates. However really they need
to be sysprepped (using the Windows tool), so they are not really
templates. For my purposes where I'm not distributing them this is
sort of fine.
Windows is extremely unhelpful if there's a problem with the XML.
(a) On the failure screen, press [Shift] + F10.
(b) cd X:\Windows\Panther\
(c) type setupact.log
(d) Examine the log file to see the real error.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
--
Tomáš GolembiovskÜ <***@redhat.com>
Cole Robinson
2018-10-13 15:26:05 UTC
Permalink
Post by Richard W.M. Jones
I have worked out how to do (almost) unattended installs of Windows
guests using virt-install. This reveals some issues with
virt-install, although maybe they are not bugs.
The virt-install command and autounattend.xml file are attached. You
(1) Put build.sh into a directory.
(2) Create config/ subdirectory.
(3) Put autounattend.xml into the config/ subdirectory. Edit the file
to add your product key.
(4) Download Windows ISO somewhere (modify the path in build.sh).
(5) Run ./build.sh
The result is very large. Windows Server 2012R2 takes 5.3 GB!
- - -
The first problem with virt-install I had was that when you use
multiple CD-ROMs virt-install doesn't choose a sensible boot order.
That's the reason for the ,boot_order=XX attributes. It seems like
https://serverfault.com/questions/644437/unattended-installation-of-windows-server-2012-on-kvm
FYI I fixed this issue upstream now:

commit 41d0f8fdf1905612ef389cb7b58c5377394f855b (HEAD -> master,
origin/master, origin/HEAD)
Author: Cole Robinson <***@redhat.com>
Date: Sat Oct 13 10:23:00 2018 -0400

installer: Order install CDROM before any manual CDROMs

So you should be able to drop the bootorder bits, it should work
correctly using --cdrom $windowsmedia --disk $virtiowin,device=cdrom ...

- Cole

Loading...