Introduction
I was trying to get this working earlier and found it a bit confusing, so here's a little guide that might come in handy for people who are forced to use Windoze for work or school. For those who are unfamiliar, QEMU is a pretty simple, straightforward virtual machine manager that works with the Kernel-based Virtual Machine hypervisor built into Linux.
First install the QEMU package.
How-To
Next create the disk image that Windows will be installed into. I would recommend keeping the disk image and install ISO in the same folder, mine is ~/machines/windows. I created a 30GB image, which will plenty for what I need, but you might want more or less. I would also use the qcow2 format, which doesn't automatically take up all the space you've allotted before the virtual machine uses it.
Next you'll need to either copy a Windows 8 ISO from a disc or download a legal ISO from Microsoft (Or windowsiso.net). If the former, insert your Windows disc and, preferably in the machine-specific folder you created for the disk image, copy the iso to your hard drive. The device name of your ODD will likely be /dev/sr0, but if it's something different make sure to modify the command.
If you don't have a CD, you'll need to download an official ISO from Microsoft. Make sure you download the version that matches your serial key. If you don't have a key, there's something you can use called Daz Loader, but I won't condone that in my post (wink, wink). Download the ISO here. Rename it to something sane like install.iso and move it to the folder you have the disk image saved in. Next you need to enable KVM, which will allow the virtual machine to access your hardware much more directly than software emulation. To use KVM, you need an Intel processor with VT-x capability or an AMD processor with AMD-V. If the former, enter:
We also probably want these modules to load at boot. To set this up, make a .conf file in modprobe.d called something that describes what it loads. Mine is vt-x.conf, but it doesn't matter what it's called.
Or kvm_amd. depending on your processor. Now the modules will be present after a reboot.
From here on out I'm going to assume your disk image is called disk.qcow2, your ISO is called install.iso, and you are in the folder containing both of these files. Now we can start up the virtual machine. I'm assuming that you're running this on a 64-bit system (if not, try "qemu-i386" instead of "qemu-system-x86_64"). I set the memory that the virtual machine can use to 4096MB, which is around half the total RAM of my system. Again, modify this based on your system and how much RAM you think the VM needs (keeping in mind that Windows requires 1GB of RAM for i386 and 2GB for x86_ 64).
This will start the VM in a new window. Go through the install process. Once everything is running, you can begin the hellish Windows Update process. You'll probably have to check and install updates three or four times before they're all covered. Now you've got Windows up and running on your machine, quarantined from your pure, virginal Linux system:
To start your VM after shutting it down, you will need to specify all the attributes again, besides for the install ISO. I have a script called windows.sh with the following contents:
- qemu-system-x86_64 -enable-kvm -m 4096 -vga std -daemonize ~/machines/windows/disk.qcow2
Some Further Notes
If you using a tiling window manager, I would recommend setting qemu-system-x86_64 to float automatically, or else Windows will look blurry and distorted due to it's been resized.
SOUND: So I've been playing around with sound for a while, and I believe I've found the solution. I'm going to do a full reinstall before I confirm anything, of course. After trying a bunch of things, the necessary steps seem to be as follows. First you need to set the QEMU audio driver to ALSA, since it defaults to OSS and makes sound not work.
You probably want this to be persistent, so add a line to your .bash_profile, .profile, or whatever autostart file you use. Now that the QEMU audio is set right, boot Windows 7 with the -soundhw ac97 command:
Download the Realtek AC97 driver for Windows 7 from this page. Download this file on the Windows machine, not the host.
Right click > "Extract all" from the .zip you just downloaded
Run the executable named "setup" in the folder you just extracted This will run the whole install process, then ask you to reboot. After you reboot you should hear the ear-grating Windows startup noise and sound should work fine.
Supplement
* Linux: Find Out If CPU Support Intel VT and AMD-V Virtualization Support
沒有留言:
張貼留言