Open Source

How to install Windows 10 in a VM on a Linux machine

Learn how to install Windows 10 on your Linux machine using the bundled license key on preassembled systems, and get tips on how to reduce the amount of system resources Windows uses.

Image: iStockphoto/Pannawat

For Linux users, making a clean break from the Microsoft ecosystem is often a rather challenging task. Even in 2016, the possibility of needing Windows to perform some task still exists—perhaps as part of an employer requirement, a dependency on legacy technology such as ActiveX, or to interact with legacy hardware which has no Linux driver.

The long arm of Microsoft's embrace is similarly difficult to escape. While it is simple to build your own PC (or simply use an Intel NUC), laptops and all-in-one systems are typically impossible to build in the same way. As such, unless you are buying a System76 computer, or a Dell developer laptop, you are already paying the "Windows Tax" for your device.

SEE: Best laptops for work and play (July 2016 edition) (ZDNet)

Considering that the license has already been paid for, it is likely a worthwhile endeavor to install Windows 10 in a virtual machine, rather than dual booting. After all, this is Windows—using a fresh ISO direct from Microsoft eliminates OEM-bundled bloatware which typically accompanies a new computer. Additionally, using a VM for Windows also prevents any future Windows update from interfering with your computer's boot partition, which may render either or both operating systems unbootable.

Getting the installation ISO from Microsoft

Microsoft provides installation images for Windows 10, saving users from having to resort to file sharing networks which likely have malware slipstreamed into the OS image. Unfortunately, it would be too convenient if they provided a direct ISO download—the utility is an EXE which requires an already functioning Windows system to work. (The utility appears to not work under WINE.) If you do not have access to a Windows system, the Insider Preview is available as an ISO, though this is beta software. (You can opt to stop receiving insider preview builds after installation.)

Although the utility offers the ability to make a bootable USB drive, it is easier to install in a virtual machine using an ISO. As this process involves mounting the ISO file for installation (rather than burning the ISO to a disc), there is no speed benefit for using a USB drive.

Extracting your Windows license key

Prior to Windows 8, the Windows license key could be found on a sticker on the back or bottom of a computer. Now, the license key is rather unhelpfully embedded in the computer. Perhaps more unhelpfully, there is no option to view the key in the BIOS on most computers, including the Lenovo ThinkPad W550s used for this article. As such, the key must be manually extracted from the ACPI table in which it is stored. Fortunately, there is an open source tool to do so.

In order to do this, the acpica-tools package must be installed via the command line. On Fedora, this is:

sudo dnf install acpica-tools

With this installed, the acpidump command can be used to view the table. Dumping the contents of all ACPI tables would produce a lot of extraneous data, so to select only the license key, use the following command:

sudo acpidump -n MSDM

This will return data that looks like this:

MSDM @ 0x0000000000000000
  0000: 4D 53 44 4D 55 00 00 00 03 B1 4C 45 4E 4F 56 4F  MSDMU.....LENOVO
  0010: 54 50 2D 4E 31 31 20 20 40 11 00 00 50 54 45 43  TP-N11  @...PTEC
  0020: 02 00 00 00 01 00 00 00 00 00 00 00 01 00 00 00  ................
  0030: 00 00 00 00 1D 00 00 00 46 43 4B 47 57 2D 52 48  ........FCKGW-RH
  0040: 51 51 32 2D 59 58 52 4B 54 2D 38 54 47 36 57 2D  QQ2-YXRKT-8TG6W-
  0050: 32 42 37 51 38                                   2B7Q8

The five sets of five characters separated by dashes at the end is the license key. In this example, this is FCKGW-RHQQ2-YXRKT-8TG6W-2B7Q8.

Selecting a virtual machine and installing Windows

In Linux, using KVM/QEMU is the most pain-free virtualization option, as it is built into the kernel and there are no kernel extensions to configure. The Boxes app provides a very easy to use GUI for this, though if you need extensive configuration options, virt-manager is intended for power users.

SEE: Windows 10: The smart person's guide

For comparison, support for 3D-accelerated graphics (DirectX) is comparatively poor in VirtualBox. An experimental driver for that exists, though it is somewhat inconsistent in certain situations, particularly involving HiDPI displays. VMWare Player has a better 3D acceleration driver, and is free for noncommercial use, though is not recommended for this purpose unless you already have it installed.

For 64-bit installations of Windows 10, the minimum system requirements include 20 GB of disk space and 2 GB RAM. Windows is more pleasant with more RAM. The laptop I used includes 16 GB RAM, so I can spare 4 GB for Windows. Under KVM/QEMU, it is possible to increase the disk space later, but not decrease it. As such, it might be best to start with 20 GB as default—the space available to the VM is only allocated on the host disk as it is used.

Compressing the Windows 10 OS image

This next step is entirely optional, and perhaps of questionable real benefit, as consumer grade SSDs are substantively cheaper than even one year ago, and the install size of Windows 10 is the smallest since Windows XP, due to some clever engineering by Microsoft. (Despite this, it is still about four times the size of a fresh Fedora 24 installation.)

You can compress the installation size of Windows 10 by entering the following command in a command prompt (as an administrator):

COMPACT.EXE /CompactOS:always

This was principally intended for use with netbooks, which often have a relatively paltry amount of flash storage. In a fresh installation of 64-bit Windows 10 (build 1511), this reduced the installation size by 1.06 GB, to 9.14 GB. However, because of the file operations involved to compress Windows files, this actually resulted in an increase of the virtual disk file in Fedora by several gigabytes. This is a temporary issue—as more programs are installed and used, the space freed by this operation will be used before more space is allocated on the host file system.

What's your view?

Do you prefer your Windows confined to containers? Is there a particular program or task which you still rely on Windows for, despite preferring Linux? Share your thoughts in the comments.

Also see

About James Sanders

James Sanders is a Java programmer specializing in software as a service and thin client design, and virtualizing legacy programs for modern hardware.

Editor's Picks

Free Newsletters, In your Inbox