Difference between pages "Package:ACPI Daemon" and "Windows 7 Virtualization with KVM"

(Difference between pages)
(Kernel configuration)
 
(QEMU script)
 
Line 1: Line 1:
 +
This page describes how to set up Funtoo Linux to run Windows 7 Professional 32-bit within a KVM virtual machine. KVM is suitable for running Windows 7 for general desktop application use. It does not provide 3D support, but offers a nice, high-performance virtualization solution for day-to-day productivity applications. It is also very easy to set up.
 +
 
== Introduction ==
 
== Introduction ==
==== What is acpi? ====
 
"In computing, the Advanced Configuration and Power Interface (ACPI) specification provides an open standard for device configuration and power management by the operating system." [(http://en.wikipedia.org/wiki/Advanced_Configuration_and_Power_Interface Wikipedia)]
 
  
==== What is acpid? ====
+
KVM is a hardware-accelerated full-machine hypervisor and virtualization solution included as part of kernel 2.6.20 and later. It allows you to create and start hardware-accelerated virtual machines under Linux using the QEMU tools.
"ACPID is a completely flexible, totally extensible daemon for delivering ACPI events. It listens on a file (/proc/acpi/event) and when an event occurs, executes programs to handle the event. The programs it executes are configured through a set of configuration files, which can be dropped into place by packages or by the admin." [(http://acpid.sourceforge.net/ acpid Sourceforge)]
+
  
== Preparing to install ==
+
[[File:Windows7virt.png|400px|Windows 7 Professional 32-bit running within qemu-kvm]]
==== Kernel configuration ====
+
Before we are ready to emerge acpid, it is a good idea to modify a few things in the kernel. If you have not modified your kernel before, you may want to check out the following page on configuring a kernel manually (page to be added..).
+
  
{{kernelop
+
== Kernel Setup ==
|Enabling acpid (if it is not already enabled)
+
 
|Power management and ACPI options ---> <br>       [*] ACPI (Advanced Configuration and Power Interface) Support
+
If you are using an automatically-built kernel, it is likely that KVM is already available.
}}
+
 
{{Note}} Kernel options after this are not necessary, but are helpful in certain situations.
+
If you are compiling your own kernel, the following kernel config parameters should be enabled (this is based on a 3.x kernel):
{{kernelop
+
 
|Removing support for deprecated acpi files
+
Under <tt>Processor type and features</tt>, enable <tt>Paravirtualized Guest Support</tt>. Under the <tt>Paravirtualized Guest Support</tt> menu, enable any options related to KVM, such as <tt>KVM paravirtualized clock</tt> and in particular <tt>KVM Guest Support</tt>.
|Power management and ACPI options ---> <br>       [*] ACPI (Advanced Configuration and Power Interface) Support ---> <br>       [ ] Deprecated /proc/acpi files <br>[ ] Deprecated power /proc/acpi directories
+
 
}}
+
Under the <tt>Virtualization</tt> category from the main kernel config menu, enable <tt>Kernel-based Virtual Machine (KVM) support</tt>, and enable at least one type of KVM, either for Intel or AMD processors. It is also recommended to enable <tt>Host kernel acceleration for virtio net</tt>.
 +
 
 +
You can use modules or build these parts directly into the kernel. Build your new kernel and modules, and reboot.
 +
 
 +
== Emerge Qemu ==
 +
 
 +
First, add the following USE flags to <tt>/etc/make.conf</tt>
 +
 
 +
<pre>
 +
USE="sdl usbredir"
 +
</pre>
 +
 
 +
Now, emerge qemu:
  
== Installing acpid ==
 
==== Emerging ====
 
To install acpid, run this command:
 
 
<console>
 
<console>
##r### ##b##emerge -av acpid
+
# ##i##emerge -av qemu
 
</console>
 
</console>
  
==== Adding to rc ====
+
After <tt>qemu</tt> and its dependencies have been installed, you are now ready to start setting up your Windows 7 environment.
After you have finished installing acpid, you may want to add it to the list of rc services to be started with your system at boot.
+
 
 +
== Windows 7 ISO Images ==
 +
 
 +
In this tutorial, we are going to install Windows 7 Professional, 32-bit Edition. Microsoft provides a free download of the ISO DVD image, but this does require a valid license key for installation. You can download Windows 7 Professional, 32 bit at the following location:
 +
 
 +
http://msft-dnl.digitalrivercontent.net/msvista/pub/X15-65804/X15-65804.iso
 +
 
 +
In addition, it's highly recommended that you download "VirtIO" drivers produced by Red Hat. These drivers are installed under Windows and significantly improve Windows 7 network and disk performance. You want to download the ISO file (not the ZIP file) at the following location:
 +
 
 +
http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/
 +
 
 +
== Create Raw Disk ==
 +
 
 +
In this tutorial, we are going to create a 30GB raw disk image for Windows 7. Raw disk images offer better performance than the commonly-used QCOW2 format. Do this as a regular user:
 +
 
 
<console>
 
<console>
##r### ##b##rc-update add acpid default
+
$ ##i##cd
 +
$ ##i##qemu-img create -f raw win7.img 30G
 
</console>
 
</console>
Then, run the following to start rc:
+
 
 +
We now have an empty virtual disk image called <tt>win7.img</tt> in our home directory.
 +
 
 +
== QEMU script ==
 +
 
 +
Now, we'll create the following script to start our virtual machine and begin Windows 7 installation. Note that this script assumes that the two ISO files downloaded earlier were placed in the user's <tt>Downloads</tt> directory. Adjust paths as necessary if that is not the case. Also be sure to adjust the following parts of the script:
 +
 
 +
* Adjust the name of <tt>VIRTIMG</tt> to match the exact name of the VirtIO ISO image you downloaded earlier
 +
* Adjust the <tt>smp</tt> option to use the number of CPU cores and threads (if your system has hyperthreading) of your Linux system's CPU.
 +
 
 +
Use your favorite text editor to create the following script. Name it something like <tt>vm.sh</tt>:
 +
 
 +
<syntaxhighlight lang="bash">
 +
#!/bin/sh
 +
export QEMU_AUDIO_DRV=alsaDISKIMG=~/win7.img
 +
WIN7IMG=~/Downloads/X15-65804.iso
 +
VIRTIMG=~/Downloads/virtio-win-0.1-74.iso
 +
qemu-kvm --enable-kvm -drive file=${DISKIMG},if=virtio -m 2048 \
 +
-net nic,model=virtio -net user -cdrom ${WIN7IMG} \
 +
-drive file=${VIRTIMG},index=3,media=cdrom \
 +
-rtc base=localtime,clock=host -smp cores=2,threads=4 \
 +
-usbdevice tablet -soundhw ac97 -cpu host -vga vmware
 +
</syntaxhighlight>
 +
 
 +
Now, make the script executable:
 +
 
 
<console>
 
<console>
##r### ##b##rc
+
$ ##i##chmod +x vm.sh
 
</console>
 
</console>
[[Category:System]]
+
 
 +
Here is a brief summary of what the script does. It starts the <tt>qemu-kvm</tt> program and instructs it to use KVM to accelerate virtualization. The system disk is the 30GB raw image you created, and we tell QEMU to use "virtio" mode for this disk, as well as "virtio" for network access. This will require that we install special drivers during installation to access the disk and enable networking, but will give us better performance.
 +
 
 +
To assist us in installing the VirtIO drivers, we have configured the system with two DVD drives -- the first holds the Windows 7 installation media, and the second contains the VirtIO driver ISO that we will need to access during Windows 7 installation.
 +
 
 +
The <tt>-usbdevice tablet</tt> option will cause our mouse and keyboard interaction with our virtual environment to be intuitive and easy to use.
 +
 
 +
== Starting Windows 7 Installation ==
 +
 
 +
Now, it's time to start Windows 7 installation. Run <tt>vm.sh</tt> as follows:
 +
 
 +
<console>
 +
$ ##i##./vm.sh
 +
</console>
 +
 
 +
Windows 7 installation will begin. During the installation process, you will need to enter a valid license key, and also load ''both'' VirtIO drivers from Red Hat when prompted (Browse to the second DVD, then win7 directory, then x86).
 +
 
 +
After some time, Windows 7 installation will complete. You will be able to perform Windows Update, as by default, you will have network access if your host Linux system has network access.
 +
 
 +
Enjoy your virtualized Windows 7 system!

Revision as of 05:03, November 22, 2013

This page describes how to set up Funtoo Linux to run Windows 7 Professional 32-bit within a KVM virtual machine. KVM is suitable for running Windows 7 for general desktop application use. It does not provide 3D support, but offers a nice, high-performance virtualization solution for day-to-day productivity applications. It is also very easy to set up.

Introduction

KVM is a hardware-accelerated full-machine hypervisor and virtualization solution included as part of kernel 2.6.20 and later. It allows you to create and start hardware-accelerated virtual machines under Linux using the QEMU tools.

Windows 7 Professional 32-bit running within qemu-kvm

Kernel Setup

If you are using an automatically-built kernel, it is likely that KVM is already available.

If you are compiling your own kernel, the following kernel config parameters should be enabled (this is based on a 3.x kernel):

Under Processor type and features, enable Paravirtualized Guest Support. Under the Paravirtualized Guest Support menu, enable any options related to KVM, such as KVM paravirtualized clock and in particular KVM Guest Support.

Under the Virtualization category from the main kernel config menu, enable Kernel-based Virtual Machine (KVM) support, and enable at least one type of KVM, either for Intel or AMD processors. It is also recommended to enable Host kernel acceleration for virtio net.

You can use modules or build these parts directly into the kernel. Build your new kernel and modules, and reboot.

Emerge Qemu

First, add the following USE flags to /etc/make.conf

USE="sdl usbredir"

Now, emerge qemu:

# emerge -av qemu

After qemu and its dependencies have been installed, you are now ready to start setting up your Windows 7 environment.

Windows 7 ISO Images

In this tutorial, we are going to install Windows 7 Professional, 32-bit Edition. Microsoft provides a free download of the ISO DVD image, but this does require a valid license key for installation. You can download Windows 7 Professional, 32 bit at the following location:

http://msft-dnl.digitalrivercontent.net/msvista/pub/X15-65804/X15-65804.iso

In addition, it's highly recommended that you download "VirtIO" drivers produced by Red Hat. These drivers are installed under Windows and significantly improve Windows 7 network and disk performance. You want to download the ISO file (not the ZIP file) at the following location:

http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/

Create Raw Disk

In this tutorial, we are going to create a 30GB raw disk image for Windows 7. Raw disk images offer better performance than the commonly-used QCOW2 format. Do this as a regular user:

$ cd
$ qemu-img create -f raw win7.img 30G

We now have an empty virtual disk image called win7.img in our home directory.

QEMU script

Now, we'll create the following script to start our virtual machine and begin Windows 7 installation. Note that this script assumes that the two ISO files downloaded earlier were placed in the user's Downloads directory. Adjust paths as necessary if that is not the case. Also be sure to adjust the following parts of the script:

  • Adjust the name of VIRTIMG to match the exact name of the VirtIO ISO image you downloaded earlier
  • Adjust the smp option to use the number of CPU cores and threads (if your system has hyperthreading) of your Linux system's CPU.

Use your favorite text editor to create the following script. Name it something like vm.sh:

#!/bin/sh
export QEMU_AUDIO_DRV=alsaDISKIMG=~/win7.img
WIN7IMG=~/Downloads/X15-65804.iso
VIRTIMG=~/Downloads/virtio-win-0.1-74.iso
qemu-kvm --enable-kvm -drive file=${DISKIMG},if=virtio -m 2048 \
-net nic,model=virtio -net user -cdrom ${WIN7IMG} \
-drive file=${VIRTIMG},index=3,media=cdrom \
-rtc base=localtime,clock=host -smp cores=2,threads=4 \
-usbdevice tablet -soundhw ac97 -cpu host -vga vmware

Now, make the script executable:

$ chmod +x vm.sh

Here is a brief summary of what the script does. It starts the qemu-kvm program and instructs it to use KVM to accelerate virtualization. The system disk is the 30GB raw image you created, and we tell QEMU to use "virtio" mode for this disk, as well as "virtio" for network access. This will require that we install special drivers during installation to access the disk and enable networking, but will give us better performance.

To assist us in installing the VirtIO drivers, we have configured the system with two DVD drives -- the first holds the Windows 7 installation media, and the second contains the VirtIO driver ISO that we will need to access during Windows 7 installation.

The -usbdevice tablet option will cause our mouse and keyboard interaction with our virtual environment to be intuitive and easy to use.

Starting Windows 7 Installation

Now, it's time to start Windows 7 installation. Run vm.sh as follows:

$ ./vm.sh

Windows 7 installation will begin. During the installation process, you will need to enter a valid license key, and also load both VirtIO drivers from Red Hat when prompted (Browse to the second DVD, then win7 directory, then x86).

After some time, Windows 7 installation will complete. You will be able to perform Windows Update, as by default, you will have network access if your host Linux system has network access.

Enjoy your virtualized Windows 7 system!