Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vkz/a07cc595aa90f8813d260611e0e98424 to your computer and use it in GitHub Desktop.
Save vkz/a07cc595aa90f8813d260611e0e98424 to your computer and use it in GitHub Desktop.
Windows 10 Pro Image for SmartOS Bhyve

Windows 10 Pro

Windows 10 Pro ISO

Create a fresh Windows 10 Pro ISO file with Microsofts Media Creation Tool. (I created a Windows 10 Pro 64 bit German ISO image)

Save the created image on your SmartOS global zone.

cp ... /zones/Windows10_64de.iso

Virtio driver

Download latest stable Virtio driver ISO from https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/ and save it in the global zone.

# cd /zones
# wget --no-check-certificate https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.185-2/virtio-win-0.1.185.iso

Create a new filesystem to install Windows

All virtual machines created from this image will have this size. Choose a size that fits your needs.

# zfs create -V 80G zones/windows

Install Windows 10 Pro

# export WINDOWS_INSTALL_CD=/zones/Windows10_64de.iso
# export VIRTIO_DRIVER_CD=/zones/virtio-win-0.1.185.iso

# pfexec /usr/sbin/bhyve -c 1 -m 3G -H \
    -l com1,stdio \
    -l bootrom,/usr/share/bhyve/uefi-rom.bin \
    -s 2,ahci-cd,$WINDOWS_INSTALL_CD \
    -s 3,virtio-blk,/dev/zvol/rdsk/zones/windows \
    -s 4,ahci-cd,$VIRTIO_DRIVER_CD \
    -s 28,fbuf,vga=off,tcp=0.0.0.0:5900,w=1024,h=768,wait \
    -s 29,xhci,tablet \
    -s 31,lpc \
    windows

Bhyve will wait until you connect with VNC to port 5900 of your global zone. After you connect you have a few seconds to press any key to boot from CD.

Select the install now option and answer that you don't have a product key (license). Pick the Windows version you want to create the image for (Windows 10 Pro).

When asked where to install it to, load the Virtio SCSI driver from this location E:\amd64\w10\viostor.inf.

Whenever Windows wants to reboot the bhyve command terminates. Run the same ommand again but don't press any key. These times we want to boot from the hard disk.

Repeat this until Windows starts to ask you questions. Press Ctrl + Shift + F3 to reboot to audit mode (run the same bhyve command again). Audit mode logs you automatically into the Administrator account. (This takes forever, twice, to log you in. Just be patient.) Keep the window from sysprep open, do not click OK as this will reboot out of audit mode.

Run E:\virtio-win-gt-x64.msi and install all the Virtio drivers - or at least the networking one.

Click OK in the window from the sysprep tool and wait for the system to automatically shut down.

Create the image

# zfs send zones/windows | tee /zones/windows.zvol | digest -a sha1
5989a20371dbb29ab7e04d32f124eccfe5749a4b
# zfs destroy zones/windows
# /usr/sbin/bhyvectl --destroy --vm=windows
# ls -l /zones/windows.zvol
-rw-r--r--   1 root     root     10891713416 Jan 16 14:25 /zones/windows.zvol

Generate a random GUID with uuidgen(1) and create the windows.imgmanifest file.

{
    "v": 2,
    "uuid": "47e05f5c-a9c3-4779-b01a-a94d16f3a404",
    "name": "win-10-pro-de",
    "version": "0.0.1",
    "type": "zvol",
    "os": "windows",
    "files": [ {
        "sha1": "5989a20371dbb29ab7e04d32f124eccfe5749a4b",
        "size": 10891713416,
        "compression": "none"
    } ]
}

Import the image.

# imgadm install -m /zones/windows.imgmanifest -f /zones/windows.zvol

We're done, you can now create virtual machines from this image.

Create a Windows 10 Pro VM

The vcpus option from bhyve creates that number of CPUs, not cores. Unfortunately, Windows 10 Pro doesn't support more than 2 CPUs. That's why we only define a single vcpus but add multiple cores and threads with the bhyve_extra_opts option.

The nics options should be adjusted to match your needs. The example works with an external DHCP server to automatically configure networking.

{
  "alias": "wintest",
  "brand": "bhyve",
  "vcpus": 1,
  "bhyve_extra_opts": "-c sockets=1,cores=4,threads=2",
  "autoboot": false,
  "ram": 8192,
  "bootrom": "uefi",
  "disks": [ {
    "boot": true,
    "model": "virtio",
    "image_uuid": "47e05f5c-a9c3-4779-b01a-a94d16f3a404",
    "image_size": 15360
  } ],
  "nics": [
    {
      "nic_tag": "admin",
      "vlan_id": 150,
      "ip": "dhcp",
      "primary": "true",
      "model": "virtio"
    }
  ]
}

Now we create and start the VM.

# vmadm create -f wintest.json
Successfully created VM 3f23f273-f4dc-4cab-bd8d-8aeac66fe79e
# vmadm start 3f23f273-f4dc-4cab-bd8d-8aeac66fe79e
# vmadm info 3f23f273-f4dc-4cab-bd8d-8aeac66fe79e vnc

Connect with VNC and answer the questions.

Tip: When you create an offline account, don't set a password. You can set the password after you log in the first time. That way you don't have to answer the 3 idiotic recovery questions.

After you've set the password, enable the remote desktop and have fun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment