clalancette / oz

Automated installation for guest images
GNU Lesser General Public License v2.1
310 stars 129 forks source link

Inject drivers and other files into Windows iso image #135

Closed harmw closed 11 years ago

harmw commented 11 years ago

Hi,

In order to install Windows 2012 with virtio one needs to mount the driver disc from http://alt.fedoraproject.org/pub/alt/virtio-win/. It'd be great if oz could inject these (any) drivers into the installation iso image primarily to support virtio installations.

Furthermore, to support a more cloudy setup oz should be able to inject a setupcomplete.cmd file into a freshly installed system, allowing final customization when setup has finished.

Thanks.

luisfdez commented 11 years ago

Hi @harmw,

I sent a PR a few months ago related with this (#54). It allows you to add content to the ISO image before starting the installation, you can place the virtio drivers there and point from you unattend installation to that folder.

You can also use it for adding the old $OEM$ folder if you want, and using it properly you can place your setupcomplet.cmd that will be automatically copied to the filesystem.

Cheers, Luis

clalancette commented 11 years ago

Yep, exactly as Luis says. In theory there is also the mechanism which allows you to copy files into the guest during the customization phase, but that doesn't work with Windows. So for now you'll have to go with using the $OEM$ folder.

luisfdez commented 11 years ago

@harmw, does the answer help you?

What @clalancette said also reminds me that I have a pending patch to support <file> section of the template on Windows. It's basically a clone of https://github.com/clalancette/oz/blob/master/oz/OpenSUSE.py#L381. @clalancette do you think it's a good option for a PR?

Anyway, having <file> section wouldn't help you with the SetupComplete.cmd scenario as the customization stage runs after the installation, and for SetupComplete.cmd you should have it in the filesystem before finishing the installation, that's why the $OEM$ folder structure in the ISO will help you.

If it helps you, part of my TDL files look like.

      <extras>
         <directory source="file:///path/private/isos/common"
                    destination="sources/$OEM$"/>
         <directory source="file:///path/virtio/0.1-52/WIN8/AMD64"
                    destination="sources/$OEM$/$1/Drivers/virtio"/>
      </extras>

For the virtio case (in the example copied to C:\Drivers\virtio), while writing your unattend files, you have to point the driver path to the installation media, as the hd filesystem itself depends on the driver, so I use something like this in the xml:

            <DriverPaths>
                <PathAndCredentials wcm:keyValue="cd2de24e" 
                                    wcm:action="add">
                    <Path>D:\sources\$OEM$\$1\Drivers\virtio</Path>
                </PathAndCredentials>
            </DriverPaths>
harmw commented 11 years ago

Hi guys, looks like i've missed this in the man pages. The above works as expected, as far as the tdl is concerned. In which settings pass and component should I put the DriverPaths code in the unattended.xml?

Using component Microsoft-Windows-PnpCustomizationsWinPE in settings pass="windowsPE" didn't install anything.

luisfdez commented 11 years ago

You're right, this functionality needs more documentation...

For me, it works in windowsPE settings. You can also check in the modified ISO image if everything is ok (in my example, inside the virtio folder there are no subfolders).

<settings pass="windowsPE">
...
..
...
....
        <component name="Microsoft-Windows-PnpCustomizationsWinPE" 
                   processorArchitecture="amd64"
                   publicKeyToken="31bf3856ad364e35"
                   language="neutral"
                   versionScope="nonSxS"
                   xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <DriverPaths>
                <PathAndCredentials wcm:keyValue="cd2de24e" 
                                    wcm:action="add">
                    <Path>D:\sources\$OEM$\$1\Drivers\virtio</Path>
                </PathAndCredentials>
            </DriverPaths>
        </component>
harmw commented 11 years ago

Are you installing with virtio as will (oz-install -b virtio)? I'm still without succes on this, setup complains about the disks layout which is most likely because of missing virtio drivers. I've added the block above at the top of my windows2012.auto file, as the first item within the element.

luisfdez commented 11 years ago

Yes, I'm specifying -b virtio for disk and -n virtio for network. Could you paste the TDL part where you point to the virtio folder?

harmw commented 11 years ago

Nevermind, I noticed my oz-install command was missing the -a parameter so it didn't use my custom unattended xml. Perhaps the documentation on this can be extended?

It works like a charm now, though I'm mostly using the cloudbase xml from https://raw.github.com/cloudbase/windows-openstack-imaging-tools/master/Autounattend.xml. I also suffered from https://bugzilla.redhat.com/show_bug.cgi?id=966861, so using 0.52 virtio drivers helped as well.

On to including cloud-init stuff :)

Thanks you both.

shake commented 10 years ago

Hi harmw

whether can share more detail how to use Oz install windows 2012 image, that can include cloud init?