Installing a Windows guest with virtio in a single step (Debian)
Prepare a template VM, modify it with a tool like snf-image-creator to install the virtio drivers and sysprep, and clone it:
sudo snf-mkimage -f --print-metadata --disable-sysprep=shrink --print-syspreps --install-virtio=/mnt/loop/win8/amd64 -o win2012-out.img win2012-template.img
If you want to create each image from scratch, you can slipstream the drivers into your windows ISO, so that they are available during setup.
Here's a rather lenghty howto for Windows 2012 (taken from http://joshrestivo.com/?p=17, redacted some ranty comments by the author), it should be easily adaptable for Windows 7.
Prep
You’ll need:
- a Windows box to do this on
- Windows 2012 Server install ISO
- The latest signed virtio drivers for windows from RedHat. As of the time of writing, these are contained within virtio-win-0.1-59.iso
- ImgBurn or any other tool capable of manipulting ISO images.
Details
For ease of explanation, I’ve created the following:
c:\iso
c:\iso\ms-iso
c:\iso\ms-mount
c:\iso\virtio-iso
Go ahead and put the windows and virtio iso images in c:\iso.
Using ImgBurn or the tool of your choice, extract the contents of the windows install iso to c:\iso\ms-iso.
Extract the contents of the virtio iso into c:\iso\virtio-iso. Alternatively, you could just mount the iso and reference the appropriate path when you reach step #5.
-
Next, we’ll use dism to mount the wim image. Run this from an elevated command prompt:
dism /mount-image /imagefile:c:\iso\ms-iso\sources\install.wim /index:1 /mountdir:c:\iso\ms-mount
-
Time to insert the drivers.
dism /image:c:\iso\ms-mount /add-driver /driver:c:\iso\virtio-iso\WIN8\AMD64 /recurse
-
If all went well, 5 of 5 drivers will have successfully ‘installed’. Now we seal the deal:
dism /unmount-wim /mountdir:c:\iso\ms-mount /commit
-
Now we have to run through the same process but this time we’re updating boot.wim so that we can see the virtual drive during the install process.
dism /mount-image /imagefile:c:\iso\ms-iso\sources\boot.wim /index:1 /mountdir:c:\iso\ms-mount dism /image:c:\iso\ms-mount /add-driver /driver:c:\iso\virtio-iso\WIN8\AMD64 /recurse dism /unmount-wim /mountdir:c:\iso\ms-mount /commit
-
Now all that’s left is to glue the iso back together. In ImgBurn this accomplished by:
A. Mode -> Build
B. In the ‘Source’ section, click the ‘Browse for a folder’ icon. Select c:\iso\ms-iso.
C. In the ‘Destination’ section, click the ‘Browse for a file’ icon. Give your iso a name and put it where you’d like.
D. Under the Options tab on the right, set ‘File System’ to ‘UDF’ and ensure that ‘Recurse Subdirectories’ is checked.
E. Under the Labels tab, set an appropriate label (eg., ‘win2012-virtio’) in the UDF field.
F. Under the Advanced -> Bootable Disc tab:
I. Check the ‘Make Image Bootable’ checkbox
II. Emulation Type: None (Custom)
III. Boot Image: c:\iso\ms-iso\boot\etfsboot.com
IV. Platform ID: 80×86
V. Developer ID: Microsoft Corporation
VI. Load Segment: 07C0
VII. Sectors to Load: 8 (for Vista and earlier, this would be 4)
VIII. Patch Information Table: Unchecked
G. Finally, click the ‘Build Image’ button on the bottom left.
Related videos on Youtube
malat
Updated on September 18, 2022Comments
-
malat almost 2 years
I am trying to create a
Windows 7 (32bits)
withvirtio
disk and network in a single step using virt-manager.I've been trying to follow the step-by-step procedure here.
However there is no such thing as the following on
Debian
:# yum install virtio-win
After a quick search on internet this package seems to only be available to RHN subscriber, as per link.
The virtio-win package can be found here in RHN: https://rhn.redhat.com/rhn/software/packages/details/Overview.do?pid=602010. It requires access to one of the following channels: RHEL Client Supplementary (v. 6) RHEL Server Supplementary (v. 6) RHEL Workstation Supplementary (v. 6)
So I am left with what is free out there. Obviously I cannot simply download the *.iso file and mount it as if it was "Floppy Disk". I actually tried and Windows told me that I need to format my drive !
I've also tried adding a secondary CD-ROM and mount
virtio-win-0.1-81.iso
, but then Windows installer would refuse to even boot. Seems like kvm/qemu gets confused when system has more than one CD-ROM drive.So in the end, I am left with a two steps process where I need to mount the Windows iso, install on regular disk, then shutdown and do the virtio stuff as described here, or here.
Isn't there a simplier process (single step) for the non-subscriber of RHN ? I am using a Debian/Jessie amd64 system (Linux has mount/umount).
BONUS POINT: no need to use an intermediate windows system to prepare the ISO file.
-
Michael Hampton over 9 yearsI don't think this is really a big deal. On a physical Windows machine you would have had a similar step to install drivers while you prepare the image anyway. So I never bothered to look for a way to do this all at once.
-
malat over 9 years@MichaelHampton that's the whole point this is not a physical machine, those are virtual machines with very repetitive installations.
-
fuero over 9 years@malat I've updated my answer.
-
Michael Hampton over 7 years
-
David Corsalini over 7 yearsIf this is so repetitive, why not install a single VM in two steps, seal it with sysprep and then spawn VMs using copies or snapshots of the image?
-
-
malat over 9 yearsneat tool, I've requested it to be added to Debian: bugs.debian.org/777213