{"id":3322,"date":"2017-05-24T10:09:42","date_gmt":"2017-05-24T17:09:42","guid":{"rendered":"http:\/\/kmwoley.com\/blog\/?p=3322"},"modified":"2017-05-24T10:14:42","modified_gmt":"2017-05-24T17:14:42","slug":"convert-a-windows-installation-into-a-unraid-kvm-virtual-machine","status":"publish","type":"post","link":"https:\/\/kmwoley.com\/blog\/convert-a-windows-installation-into-a-unraid-kvm-virtual-machine\/","title":{"rendered":"Convert a Windows Installation into a unRAID (KVM) Virtual Machine"},"content":{"rendered":"<p>Because I was turning my Windows 10 Pro server into an Linux (unRAID) machine I already had a Windows installation running on the bare metal that I had spent a fair bit of time setting up. I didn&#8217;t want to lose that installation and the work put into it. So, rather than starting over with a fresh Windows installation I took the operating system that was already installed, copied it, and started running it as a virtual machine (VM). Here are the steps I took to convert that Windows installation into a functioning VM.<\/p>\n<p>Most of these steps come from the well-written <a href=\"https:\/\/wiki.lime-technology.com\/UnRAID_Manual_6#Physical_to_Virtual_Machine_Conversion_Process\">unRAID Manual on Physical to Virtual Machine Conversion<\/a> &#8211; the main thing I add in here are the Windows-specific steps for reducing the size of the virtual machine image.<\/p>\n<p>They&#8217;re also useful for anyone running KVM as\u00a0a hypervisor &#8211; not just specific to unRAID.<\/p>\n<h2>Before you begin<\/h2>\n<ul>\n<li>Makes sure you have access to your Windows license. If you upgraded from Windows 7 or 8 to Windows 10 for free this is really important. If you haven&#8217;t already, follow the steps <a href=\"https:\/\/kmwoley.com\/blog\/how-to-migrate-from-windows-raid-to-unraid\/\">here\u00a0in &#8220;Before you shutdown Windows&#8221;<\/a>.<\/li>\n<li>Your hardware must be capable of processor virtualization (Intel VT-x or AMD-V), and it must be enabled in your BIOS. Depending on what you plan to do with your VM, you may need to meet <a href=\"https:\/\/lime-technology.com\/hardware-requirements\/\">other hardware requirements<\/a>.<\/li>\n<li>unRAID must have VMs enabled and configured. An important step here is to download the VirtIO Drivers ISO<\/li>\n<li>unRAID needs to have User Shares created to hold the virtual machine images; by default, these are created for you by a new installation at <em>\/mnt\/user\/domains\/<\/em><\/li>\n<li>Check to make sure that your User Share (above) has enough room for the full size of your Windows Operating System hard drive. You&#8217;re going to copy the entire hard drive including the empty space.<\/li>\n<\/ul>\n<p>By default, most of these things were done already on my machine, but it&#8217;s good to check them before proceeding.<\/p>\n<p><a href=\"https:\/\/wiki.lime-technology.com\/UnRAID_Manual_6#System_Preparation\">If you&#8217;re unfamiliar with unRAID and how to take those steps, they\u00a0are described in the &#8220;System Preparation&#8221; section of the unRAID manual quite well<\/a>.<\/p>\n<h2>Add a new Virtual Machine<\/h2>\n<p>From your unRAID web UI (e.g. http:\/\/tower), perform the following steps.<\/p>\n<ol>\n<li>On the\u00a0<em>VMs\u00a0<\/em>tab, click the\u00a0<em>Windows 10\u00a0<\/em>template (or template for your version of Windows).<\/li>\n<li>Click on the switch for the\u00a0<em>Basic View\u00a0<\/em>to toggle it to the\u00a0<em>Advanced View\u00a0<\/em>(in the upper-right corner of the screen) if it isn&#8217;t already set.<\/li>\n<li>Configure the VM with the following settings:\n<ol>\n<li>Name your VM whatever you wish: For this example, I&#8217;m using &#8220;Windows 10&#8221;<\/li>\n<li><em>CPU Mode:<\/em> Host Passthrough<\/li>\n<li><em>Logical CPUs:<\/em>\u00a0However many you wish (at least one)<\/li>\n<li><em>Initial Memory \/ Max Memory:<\/em> at least 2GB is recommended<\/li>\n<li><em>Machine:\u00a0<\/em>i440fx-* (whatever the newest is)<\/li>\n<li><em>BIOS:\u00a0<\/em>SeaBIOS<\/li>\n<li><em>Hyper-V:\u00a0<\/em>Yes<\/li>\n<li><em>OS Install ISO: <\/em>Leave\u00a0empty<\/li>\n<li><em>VirtIO Drivers ISO:<\/em> Select the virtio-win*.iso that (should have been) downloaded as part of enabling VMs on unRAID.<\/li>\n<li><em>VirtIO Drivers CDRom Bus:<\/em>\u00a0IDE<\/li>\n<li><em>Primary vDisk Location:\u00a0<\/em>Auto<\/li>\n<li><em>Primary vDisk Bus:<\/em> IDE<\/li>\n<li><em>Primary vDisk Type:<\/em> raw<\/li>\n<li><em>Primary vDisk Size:<\/em> 0G (You&#8217;ll be overwriting this file in the next step)<\/li>\n<li><em>Graphics Card:<\/em> VNC<\/li>\n<li><em>VNC Video Driver:<\/em> QXL<\/li>\n<li><em>VNC Password:<\/em> Set it if you&#8217;d like &#8211; this is how you&#8217;ll access the &#8216;screen&#8217; of the running VM<\/li>\n<li><em>VNC Keyboard:<\/em> Set to the right language for your OS<\/li>\n<li><em>Sound Card:<\/em> None (or select one if your device supports passthrough)<\/li>\n<li><em>Network MAC:<\/em> this is set randomly, though you can change it.<\/li>\n<li><em>Network Bridge:<\/em> br0<\/li>\n<li><em>USB Devices:<\/em> I recommend leaving all unchecked for now.<\/li>\n<li><em>USB Mode:<\/em> 2.0 (EHCI) is what I found worked for me.<\/li>\n<li><em>Other PCI Devices:<\/em> I recommend leaving all unassigned until you confirm the VM launches correctly.<\/li>\n<li>Uncheck <em>Start VM after creation<\/em><\/li>\n<\/ol>\n<\/li>\n<li>Hit\u00a0<em>Create.<\/em><\/li>\n<\/ol>\n<p><a href=\"https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_settings_create.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3324\" src=\"https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_settings_create.png\" alt=\"\" width=\"691\" height=\"1024\" srcset=\"https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_settings_create.png 691w, https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_settings_create-202x300.png 202w\" sizes=\"auto, (max-width: 691px) 100vw, 691px\" \/><\/a><\/p>\n<h2>Copy the OS Drive to an image<\/h2>\n<p>Next up, you need to copy the data from your OS drive to an virtual disk image that the VM can boot off of.<\/p>\n<ol>\n<li>Identify the disk that contains your Windows Operating System. You can find it by looking in the unRAID web UI in the\u00a0<em>Main\u00a0<\/em>tab under\u00a0<em>Unassigned Devices<\/em>. Look for the drive that you booted windows off of before you installed unRAID. Make note of the disk id (e.g. sdb, sdc, sde, etc.)<\/li>\n<li>SSH into your unRAID system as root. By default unRAID doesn&#8217;t have a root password, but you should have set a strong one by now&#8230; right?<\/li>\n<li>Enter the following command to convert the physical disk\n<pre>qemu-img convert -p -O raw \/dev\/<strong>sdX<\/strong> \/mnt\/user\/domains\/<strong>Windows\\ 10<\/strong>\/vdisk1.img<\/pre>\n<ol>\n<li>Replace\u00a0<strong>sdX<\/strong> with the drive id for your Windows OS installaton<\/li>\n<li>Replace\u00a0<strong>Windows\\ 10\u00a0<\/strong>with the name you gave your Virtual Machine (if you need to see what it is run the <em>ls \/mnt\/user\/domains<\/em> command to see what it&#8217;s name is on disk)<\/li>\n<\/ol>\n<\/li>\n<li>Wait. It&#8217;ll take a while, assuming you have a reasonably large OS installation disk.<\/li>\n<\/ol>\n<h2>Start your Windows VM &amp; Install the VirtIO Drivers<\/h2>\n<p>Because Windows is now running as a Virtual Machine on KVM, it will think there is new &#8220;hardware&#8221; and will require (and benefit from) having the right drivers installed.<\/p>\n<ol>\n<li>In the unRAID\u00a0<em>VMs<\/em> tab, click on your newly created VM and click\u00a0<em>Start<br \/>\n<a href=\"https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_start.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3326\" src=\"https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_start.png\" alt=\"\" width=\"1024\" height=\"208\" srcset=\"https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_start.png 1024w, https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_start-300x61.png 300w, https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_start-768x156.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/em><\/li>\n<li>After the VM has started, you can VNC into the machine and interact with it. You can do this one of two ways.\n<ol>\n<li>Click on the running Windows VM and select &#8220;VNC Remote&#8221;<\/li>\n<li><strong>(Preferred)<\/strong> Install a VNC client like <a href=\"http:\/\/www.tightvnc.com\/\">TightVNC <\/a>and connect to the VM directly. To do so, you&#8217;ll need to know the IP address of your server and connect to the VNC port of the VM (which is listed next to the running VM)<\/li>\n<\/ol>\n<\/li>\n<li>In Windows File Explorer, navigate to the VirtIO virtual CD-Rom (likely disk D:\\)<\/li>\n<li>Navigate to\u00a0<em>Balloon &gt; w10 &gt; amd64<\/em>\n<ol>\n<li>Or your specific version of Windows and Architecture<\/li>\n<\/ol>\n<\/li>\n<li>Right click on the .inf file (i.e.\u00a0<em>balloon.inf<\/em>) and click install. (You may need to enable the viewing of file extensions to find the right file)<br \/>\n<a href=\"https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_drivers.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3327\" src=\"https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_drivers.png\" alt=\"\" width=\"1024\" height=\"589\" srcset=\"https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_drivers.png 1024w, https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_drivers-300x173.png 300w, https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_drivers-768x442.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/li>\n<li>Repeat the above process for each of the following folders\n<ol>\n<li>NetKVM<\/li>\n<li>vioserial<\/li>\n<li>viostor<\/li>\n<\/ol>\n<\/li>\n<li>You may want to check Windows Device Manager to make sure there are no devices which have yellow warning exclamations next to them &#8211; if so, you&#8217;ll likely need to install an additional driver.<\/li>\n<li>When done with the driver installation, navigate to the\u00a0<em>guest-agent\u00a0<\/em>folder and double click on <em>qemu-ga-x64.msi<\/em> to install the QEMU\/KVM guest agent.<\/li>\n<\/ol>\n<h2>Shutdown the VM &amp; update disk settings<\/h2>\n<p>Now that you know that the VM boots and you&#8217;ve got the drivers installed, you can stop the VM and update the physical disk to use the VirtIO bus which will give you better performance.<\/p>\n<ol>\n<li>Stop the Windows VM. You can do this one of two ways &#8211; one, by initiating a Shutdown from within Windows. Or, you can click on the VM image in unRAID and select\u00a0<em>Stop<\/em> which will also gracefully shut down Windows.<\/li>\n<li>In the unRAID web UI, in the <em>VMs<\/em> tab, select the Windows VM and select <em>Edit<\/em><\/li>\n<li>Change the following settings:<br \/>\n<a href=\"https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_disks.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3328\" src=\"https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_disks.png\" alt=\"\" width=\"851\" height=\"314\" srcset=\"https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_disks.png 851w, https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_disks-300x111.png 300w, https:\/\/kmwoley.com\/blog\/wp-content\/uploads\/2017\/05\/windows_vm_disks-768x283.png 768w\" sizes=\"auto, (max-width: 851px) 100vw, 851px\" \/><\/a><\/p>\n<ol>\n<li><em>Primary vDisk Bus:<\/em> VirtIO<\/li>\n<li><em>VertIO Drivers ISO:<\/em> delete the entry<\/li>\n<li>Restart the VM and make sure it&#8217;s operating correctly.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<h2>Reactivate your Windows license<\/h2>\n<p>Windows checks it&#8217;s license validity based on your machine&#8217;s hardware. Any time you change the hardware, Windows needs you to reactivate your license. You&#8217;ll need to run through the activation steps in the VM to re-activate your Windows license because Windows will think you just changed a lot of hardware.<\/p>\n<p>To do that, search for &#8220;Activation&#8221; from the Windows 10 Start menu. From there, you should be able to follow the prompts to activate your copy of Windows. Somewhere along the way, in smallish font, it&#8217;ll ask you if you recently changed hardware. Click that option and go from there &#8211; i.e. log into your Microsoft Account, select the machine\/license associated with this Windows installation.<\/p>\n<h2>(Optional) Remove Unneeded Software &amp; Drivers<\/h2>\n<p>Because your old Windows machine had a lot of device specific drivers installed on it to operate on your hardware, you may have a lot of cruft that can now be removed. Log into your Windows machine and take a stroll through the &#8220;Add or Remove Programs&#8221; menu to see if there&#8217;s anything that can be removed. For me, I could uninstall any Intel and RealTek Drivers, ASUS motherboard features, etc. that were no longer relevant. It&#8217;s a nice thing to slim up the now VM&#8217;d Windows OS.<\/p>\n<h2>(Optional) Optimize the Window VM<\/h2>\n<p>The<a href=\"https:\/\/wiki.lime-technology.com\/UnRAID_6\/VM_Guest_Support#Microsoft_Windows\"> unRAID wiki has a good set of steps to consider to optimize your Windows VM<\/a>. I personally don&#8217;t believe in disabling the search indexer, but most of the other tips are worth while.<\/p>\n<h2>(Optional) Reduce \/ Shrink the size of the VM image<\/h2>\n<p>Now, you&#8217;re probably saying to yourself&#8230; geez, I don&#8217;t need a XXX GB image file that just happened to be the size of your old OS hard drive just to run Windows. You probably want to slim that down.\u00a0<a href=\"https:\/\/kmwoley.com\/blog\/reduce-shrink-raw-image-img-size-of-a-windows-virtual-machine\/\">Here&#8217;s instructions on exactly how to do that<\/a>.<\/p>\n<p>Let me know if I missed anything here.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Because I was turning my Windows 10 Pro server into an Linux (unRAID) machine I already had a Windows installation running on the bare metal that I had spent a fair bit of time setting up. I didn&#8217;t want to lose that installation and the work put into it. So, rather than starting over with &hellip; <a href=\"https:\/\/kmwoley.com\/blog\/convert-a-windows-installation-into-a-unraid-kvm-virtual-machine\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Convert a Windows Installation into a unRAID (KVM) Virtual Machine<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[375,344,367,377,376,139],"class_list":["post-3322","post","type-post","status-publish","format-standard","hentry","category-geek","tag-kvm","tag-linux","tag-unraid","tag-virtual-machine","tag-vm","tag-windows"],"_links":{"self":[{"href":"https:\/\/kmwoley.com\/blog\/wp-json\/wp\/v2\/posts\/3322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kmwoley.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kmwoley.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kmwoley.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/kmwoley.com\/blog\/wp-json\/wp\/v2\/comments?post=3322"}],"version-history":[{"count":8,"href":"https:\/\/kmwoley.com\/blog\/wp-json\/wp\/v2\/posts\/3322\/revisions"}],"predecessor-version":[{"id":3350,"href":"https:\/\/kmwoley.com\/blog\/wp-json\/wp\/v2\/posts\/3322\/revisions\/3350"}],"wp:attachment":[{"href":"https:\/\/kmwoley.com\/blog\/wp-json\/wp\/v2\/media?parent=3322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kmwoley.com\/blog\/wp-json\/wp\/v2\/categories?post=3322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kmwoley.com\/blog\/wp-json\/wp\/v2\/tags?post=3322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}