A. Virtualization

A virtual machine (VM) program simulates the hardware functions of a computer within an application running on another computer. It lets you run an entire operating system as an application program so that you can work in various operating systems without rebooting. Virtualization has been used on big mainframe computers since the 1960s, and it is now also used on PCs and PC-type server computers. You could conceivably have Windows XP, Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10, various versions of Windows Server and Linux, and other operating systems all running at once on your desktop. You can also run a copy of Windows inside a virtual computer on a machine running Linux, Mac OS X, or other versions of Windows.

Virtualization is a handy way for individuals and organizations to run multiple operating systems without having to set up dual- or multiboot environments or purchase additional hardware. IT departments use virtualization to consolidate multiple server computers into a smaller number of machines and to test software updates and patches before rolling them out to end users; and developers use virtualization when creating, testing, and documenting software programs. End users most commonly use virtualization to run applications that require an older version of Windows on a computer that has a newer version of Windows.

In virtualization vocabulary, the host operating system is the one that runs the physical computer. A guest operating system runs inside the virtual machine system provided by the host. In this appendix, we talk about Windows 10 as both host and guest.

Windows 10 as a Host: Running Other Operating Systems Inside Windows 10

You can install a virtualization host program so that you can run other operating systems inside Windows 10. Microsoft’s Hyper-V product is included with the 64-bit versions of Windows 10 Professional, Enterprise, and Education editions. Hyper-V is Microsoft’s industrial-strength VM system used across the Windows Server product line. In this section, we show you how to activate Hyper-V (which by default is not enabled), how to create new virtual machines (VMs), and how to convert an existing physical installation of Windows into a VM that you can then run inside Windows 10.

If you want to run virtual machines inside Windows 10 Mobile or Home, or in any 32-bit version of Windows 10, you’ll have to use a different virtual machine manager, such as Oracle’s VirtualBox (free, from www.virtualbox.org) or VMware’s VMware Workstation ($249, from www.vmware.com). I used VirtualBox extensively while writing this book and found it completely adequate. There are some screen-refreshing issues at times (which were annoying but not deal-killers), but there are also frequent bug-fix updates to the program.

Microsoft’s previous virtualization offerings, Microsoft Virtual PC and Windows Virtual PC, do not work on Windows 8 through 10. The Windows XP Mode system—a preconfigured, virtualized copy of Windows XP that Microsoft offered to Windows 7 Professional, Ultimate, and Enterprise users—is also not available on Windows 8 through 10. We talk about converting existing Virtual PC and XP Mode virtual machines for Hyper-V in the following sections.

The version of Hyper-V provided with Windows 10 is called Client Hyper-V, and it’s is almost exactly the same VM manager used on the industrial-strength Windows Server operating systems. When Hyper-V is installed and you start your computer, Hyper-V actually loads first, and Windows 10 loads on top of it as a sort of half-client/half-partner. Your copy of Windows 10 won’t be running on the “bare metal” exactly, but it’s also not as restricted as a regular virtual machine would be—and there’s almost no performance hit. Windows 10 runs as what’s called Hyper-V’s Management Operating System, and it has direct access to the computer’s hardware. You can see this in the Device Manager, which shows that Windows 10 still “sees” your computer’s real hardware devices, not the simulated Intel network adapter and video adapter that a regular Hyper-V VM sees.

Installing and Configuring Hyper-V

To install Hyper-V on Windows 10, press Windows Logo+X and select Control Panel. Select Programs and then select Turn Windows Features On or Off. Check the Hyper-V box and click OK. Windows will need to restart once or twice.

When you sign back in, at the Start menu, select Hyper-V Manager. When this opens on the desktop, you might want to right-click its icon in the taskbar and select Pin This Program to Taskbar.

The next step is to create a virtual network switch (network hub) that your virtual computer will use to connect to your LAN and to the Internet. To do this, in the Actions panel, select Virtual Switch Manager. Select New Virtual Switch. In the list of switch types, select External and click Next. This will let your virtual machines connect to your LAN through your computer’s network adapter. Click Create Virtual Switch. Change the name to Shared Network Switch. If your computer has more than one network adapter, under External Network, select the adapter that leads to your LAN and to the Internet. Be sure to keep Allow Management Operating System to Share This Network Adapter checked. The Management Operating System is your copy of Windows 10, and you don’t want to disconnect it from the network adapter.

Finally, click OK to close the Virtual Switch Manager.

(You can also use the Virtual Switch Manager to create private networks that connect only virtual machines, or a network that contains only VMs and your own computer, but that’s beyond the scope of this book.)

Creating Virtual Machines

To create a new virtual computer, follow these steps:

1. At the Start menu, select Hyper-V Manager, shown in Figure A.1.

Image

Figure A.1 The Hyper-V Manager lets you create and manage virtual machines.

2. In the right pane, select New, Virtual Machine and then click Next.

3. Enter a name for the new VM and click Next.

4. Enter the amount of RAM the VM should see. If your computer has 8GB of RAM or more, you can probably be somewhat generous, offering 2GB to 4GB, or more, but be aware that a 32-bit operating system won’t be able to use any more than 3GB. Check Use Dynamic Memory to let Windows automatically manage the partitioning of your computer’s physical RAM between the VMs and your applications. Then click Next.

5. To give the VM access to your network, select the Shared Network Switch that you created when you installed Hyper-V. Click Next.

6. Unless you have an existing virtual hard disk you want to use, select Create a Virtual Hard Disk, type in a name for it that ends with .vhdx, and set a maximum size limit for its contents. Windows won’t preallocate a file of this size, but the disk file could grow to this size.

If, instead, you want to use the .vhd format so that the file will be compatible with other virtualization programs, in the Action pane, select New, Hard Disk and use the wizard to create a new .vhd hard disk. Then, back in the Connect Virtual Hard Disk dialog box, select Use an Existing Virtual Hard Disk and browse to the file you created.

Then click Next.

7. If you want to attach a physical or virtual (.iso file) CD or DVD to the virtual machine when it boots for the first time so that you can install an operating system, make this selection on the Installation Options screen. Click Next and then Finish.

The virtual machine is now ready to start. The first time you boot it up, install the Integration Services, as described in the next section.

Running and Connecting to a VM

Hyper-V virtual machines run entirely outside Windows 10. The Virtual machines it manages are not desktop applications on your own computer. They have distinct, separate operating systems that are running on what might as well be some other computer; it just so happens that the other computer occupies the same physical space as yours. To “see” a virtual machine’s screen, you use the Hyper-V Virtual Machine Connection program, which is a version of the Remote Desktop connection program that knows how to find VMs on your own computer or other computers.

It’s easiest to start from the Hyper-V Manager, which you can run from the Start menu (or if you pinned it to the taskbar, from the desktop). You might find that you need to right-click its icon and select Run As Administrator for it to see your virtual machines, but try it without doing this first.

In the Virtual Machines list, select the VM that you want to start, and from the Actions menu or in the section below the left Actions panel, select Connect. This will display a Remote Desktop–like window that shows that the computer is turned off. Now, from the Actions menu or from the Actions panel, select Start.

From this point, you can start, stop, pause, and take “snapshots” of the virtual machine’s current configuration using the Hyper-V manager window, and you interact with the VM through the Virtual Machine Connection window, which is shown in Figure A.2. (A snapshot is a backup that you can use to restore the virtual machine’s hard disk to the exact contents it had when the snapshot was taken.)

Image

Figure A.2 The Virtual Machine Connection program lets you view and interact with a virtual machine.

Here are some tips for interacting with the VM:

Image Once you have an operating system installed and running, try to install the Hyper-V Integration Services (IS) inside the VM. There are versions for Windows and Linux. This installs modified disk, network, and mouse drivers inside the VM that “know” about the Hyper-V environment and communicate directly with your real disk, network, and mouse without going through the overhead of working with simulated hardware. For Windows operating systems, IS lets you cut and paste between the host and guest operating systems, and it makes the mouse smoothly cross in and out of the Virtual Machine Connection window.

To install Integration Services, in the Virtual Machine Connection window, select Action, Insert Integration Services Setup Disk. This attaches a CD image file to the VM, and from there, Autorun should run the IS installer. If the installer doesn’t start automatically, locate the CD drive inside the VM and run the setup program manually.

Image Until you install the Integration Services, you have to click the mouse inside the Virtual Machine Connection window for the guest OS to see it, and once you do, the guest “captures” the mouse. It won’t leave the connection window. Press Ctrl+Alt+Left arrow to release it back to Windows 10.

Image Use the Media menu item to select CD, DVD, and floppy disk images to mount inside the VM.

Image When you’re finished working with the VM, you have several choices: You can shut it down using the guest OS’s own internal menus; you can click Action, Shut Down to send the signal the VM would get if you pressed a real computer’s Power button; or you can click Action, Save to store a copy of the VM’s current state to your hard disk. You can resume it later. (This is like hibernation, except it happens outside rather than inside the guest OS.)

Image If the guest operating system requires you to press Ctrl+Alt+Del to sign in, press Ctrl+Alt+End. That sends a Ctrl+Alt+Del keystroke to the guest.

Image If you simply close the Virtual Machine Connection window, the guest OS does not stop running. You won’t see anything saying that it’s running even in the Task Manager. Only the Hyper-V Manager shows that it’s still active. You must reconnect to the VM or use the Hyper-V Manager to shut it down.

Remember that a virtual machine can tie up a considerable amount of your computer’s RAM. If it’s cranking away at something, it will keep your CPU busy on its tasks, and can up use your network bandwidth. So, be aware that having virtual machines running takes resources away from Windows 10 and your own work.

There is plenty more to using Hyper-V. You can find lots of information online at https://technet.microsoft.com.

Converting a Physical Computer to a VM

If you’re like me, you probably have one or two old computers that you rarely use anymore, but you keep around because of one application you use once or twice a year, and some files you might want to get to someday. If so, you may be able to vacuum up the contents of its hard disk into a virtual machine so that you can run the old computer anytime you want, right from within Windows 10. Older computers often have hard disks that are fairly small by today’s standards—under 300GB in most cases, with most of that unused—so copying their contents into a single file on your new hard disk, which might be 750GB or more, isn’t that unreasonable.

We’ll give you the procedure for Hyper-V. Other products such as VMware have their own physical-to-virtual disk tools. This procedure isn’t guaranteed to work, but it’s worth a shot.

First, prepare the old machine for imaging. Clean up anything you can think of cleaning up: Run the Disk Cleanup Wizard, delete temporary Internet files, and so on. If you feel daring, run Device Manager to delete the installed network and display adapters, but this step is optional. Remove any huge files you’re certain you don’t want. Remove any unwanted startup programs (The free tool live.sysinternals.com/autoruns.exe is great for finding these). Then empty the Recycle Bin.

The next step is to capture an image of the hard disk in the old computer. You can temporarily install the old disk in your new computer, or you can perform the imaging step on the old computer and then either save the image file on a detachable USB hard drive or save it across the network to your Windows 10 computer. To create the image, download and run Disk2VHD from sysinternals.com (this site is owned by Microsoft, by the way, and it’s safe). Follow Disk2VHD’s instructions to create an image of the old disk. Leave Create Vhdx checked to create the newer .vhdx file format, unless you also want to use the disk image with other virtualization programs such as VirtualBox. Save the .vhdx or .vhd file directly to your Windows 10 computer, or transport it on a removable drive and then copy it to your Windows 10 computer. Put the file on your Windows 10 system in c:usersPublicDocumentsHyper-VVirtual Hard Disks.

Now, on Windows 10, run the Hyper-V Manager and create a new VM using the steps described earlier in this appendix, but with these changes:

Image At the Connect Virtual Hard Disk Step, select Use an Existing Virtual Hard Disk and then browse to the .vhdx or .vhd file you created in the previous step.

Image Under Installation Options, select Install an Operating System Later.

Image When you boot the machine for the first time, install the Integration Options.

Windows XP Mode Virtual Machines

If you used Windows XP Mode under Windows 7, you have a fully bootable VHD file containing Windows XP that has your old Windows applications and data already set up, and you might want to continue to use it under Windows 10. Unfortunately, this copy of Windows XP is not licensed to be used on Windows 10, and if you try to do so, Windows product activation enforces the license restriction. You technically can move a Windows XP Mode virtual machine to Hyper-V, but once you start it up, Windows XP detects the new environment and initiates a product activation cycle that you can’t complete.

You can, however, keep the XP Mode virtual hard disk and the files it contains. Use the DISK2VHD application described in the previous section to create a snapshot of the disk as seen inside the copy of XP. Copy this file to your Windows 10 computer. On Windows 10, you can double-click this file’s icon to mount and view the contents of the virtual hard disk file.

Windows 10 as a Guest: Running Windows 10 Inside Other Operating Systems

You can run Windows 10 as a guest operating system in some virtual machine host systems. It runs well in Hyper-V, so you can run a Windows 10 guest inside a Windows 10 host. (Why would someone do that? Here are a couple of reasons: for sandboxing; that is, testing software in an environment where it can’t do any damage, and for testing software on all the various editions in both 32-bit and 64-bit versions.) You also might want to work with Windows 10 on a computer that happens to run Mac OS X, Linux, or an older version of Windows as its primary OS.


Image Note

Be sure to check the licensing terms for your copy of Windows 10 to see whether you can install it in a virtual machine. Generally, the OEM licenses for a copy of Windows 10 that comes preinstalled on a new computer are tied to the computer itself. You might be able to run your copy of Windows 10 in a VM on the same computer. (This capability can be useful, as we mentioned earlier, for testing and sandboxing.) To run Windows 10 on a different computer, you would need an additional license.


If the host OS runs a 64-bit operating system, you should be able to install and run both the 32-bit and 64-bit versions of Windows 10. If the host runs as a 32-bit operating system, you will only be able to run the 32-bit versions of Windows 10.

At the time this was written, and as we mentioned earlier, Microsoft’s Hyper-V, Oracle’s VirtualBox, and VMware’s VMware Workstation can all run Windows 10 as a guest. By the time you read this, other VM software vendors might have made their products able to run Windows 10. These products are available for Windows XP through Windows 10, Mac OS X, and Linux, so you can run Windows 10 within any of these host operating systems.

Unfortunately, neither Microsoft Virtual PC nor Windows Virtual PC can run Windows 10 as a guest OS. These programs were available as free downloads for Windows 7, Vista, and XP. You can run Windows 10 on these older versions of Windows using one of the aforementioned third-party VM applications. Windows 10 runs well in VirtualBox, but it works only if the CPU in the host computer has hardware virtualization support.

Booting a VHD File on Hardware

If you have Windows 7 Ultimate or Enterprise, Windows 8.1 Professional or Enterprise, Windows 8.1 Professional or Enterprise, Windows 10 Professional, Enterprise or Education, or Windows Server versions from Server 2008R2 and up, your computer can physically boot and run these operating systems from installations stored in a VHD virtual disk file. You can take advantage of this to physically boot and run the operating system stored within the VHD file directly, with your computer’s real display and other hardware, rather than in a virtual machine. We recommend making a backup copy of the VHD file before you try this.

To set up a new boot option, you can use an inexpensive third-party GUI boot manager tool such as EasyBCD (www.neosmart.net), or you can use the BCDEDIT command-line tool provided with Windows. Follow these steps:

1. Open an elevated Command Prompt window. To do this on Windows 10, press Windows Logo+X and then select Command Prompt (Admin) on the pop-up menu.

2. Type the following command:

bcdedit /copy {default} /d "New Name"

Replace New Name with the name you’d like to give the new boot option—something like Windows 7 Ultimate 32bit VHD. This will print a new globally unique identifier (GUID), something like {e88fb488-e1a9-11dd-8a96-a967342a44b3}.

3. Press Alt+Space and type E K to prepare to copy text to the clipboard. Then use the mouse to select the new GUID, including its curly brackets, and press Enter. (On Windows 10, you might be able to just select the text and press Ctrl+C, but the preceding method always works.)

4. Type the following three commands, replacing {guid} with the identifier you just copied. Press Alt+Space and type E P to paste it in. Type the actual path to your bootable VHD file in place of [C:]pathfilename. In these commands, the square brackets don’t mean that the drive letter is optional; you really must type them in literally, as shown.

bcdedit /set {guid} device vhd="[C:]pathfilename.vhd"
bcdedit /set {guid} osdevice vhd="[C:]pathfilename.vhd"
bcdedit /set {guid} detecthal on

Now you should be able to restart and select the new OS entry from the boot menu.

When the VHD copy of Windows starts, it will see your computer’s physical hardware for the first time and should install the appropriate devices. You should be able to switch back and forth between booting it on real hardware and booting it inside Hyper-V or another VM manager. There could conceivably be some complaining by Windows Product Activation; however, a license that covers a VM installation should cover bare-metal execution of the same OS installation as well, because it’s all installed on the exact same hardware and CPU. The OS may see different hardware due to virtualization, but it’s running on the same system in both cases.


Image Note

My experience has been that the boot manager installed on your real hard disk has come from the same or a more recent version than the version of Windows you’re trying to boot from VHD. This means that if your computer has, say, only Windows 7 installed on its hard disk, it won’t be able to successfully boot Windows 10 from a VHD file. A Windows 10 computer, though, can boot and run Windows 7 through 10 from a VHD file.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.178.166