Difference between pages "Windows 7 Virtualization with KVM" and "Emerge"

From Funtoo
(Difference between pages)
Jump to: navigation, search
 
 
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.
+
== Getting started with emerge ==
 +
Emerge is the front-end for funtoo's portage package manager. With emerge its easy to install, update or remove packages.
  
== Introduction ==
+
=== Update package database ===
 +
Sync local package database. This will update your local Portage tree with the latest Funtoo ebuilds.
 +
<console># emerge --sync</console>
  
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.
+
=== Search packages ===
 +
Search packages by name.
 +
<console># emerge -s firefox
 +
# emerge --search firefox</console>
  
[[File:Windows7virt.png|400px|Windows 7 Professional 32-bit running within qemu-kvm]]
+
Search packages by description.
 +
<console># emerge -S web browser
 +
# emerge --searchdesc web browser</console>
  
== Kernel Setup ==
+
=== Install packages ===
 +
Install package.
 +
<console># emerge firefox</console>
  
If you are using an automatically-built kernel, it is likely that KVM is already available.
+
Install multiple packages.
 +
<console># emerge firefox thunderbird</console>
  
If you are compiling your own kernel, the following kernel config parameters should be enabled (this is based on a 3.x kernel):
+
Install package. Ask for confirmation before performing any changes. Show verbose output.
 +
<console># emerge -av firefox</console>
  
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>.
+
=== Remove packages ===
 +
Remove package.
 +
<console># emerge -C firefox
 +
# emerge --unmerge firefox</console>
  
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>.
+
Remove package. Ask for confirmation before performing any changes.
 +
<console># emerge -aC firefox</console>
  
You can use modules or build these parts directly into the kernel. Build your new kernel and modules, and reboot.
+
Remove orphaned packages. Ask for confirmation before performing any changes.
 +
<console># emerge -a --depclean</console>
  
== Emerge Qemu ==
+
=== Update packages ===
 +
Update all packages.
 +
<console># emerge -uDN @world</console>
  
First, add the following USE flags to <tt>/etc/make.conf</tt>
+
Update all packages. Ask for confirmation before performing any changes. Show verbose output.
 +
<console># emerge -uavDN @world</console>
  
<pre>
+
== Emerge options ==
USE="sdl usbredir"
+
</pre>
+
  
Now, emerge qemu:
+
; --sync
 +
: Updates the portage tree that is located in /usr/portage by default.
  
<console>
+
; --search -s
# ##i##emerge -av qemu
+
: Searches  for  matches  of  the  supplied  string in the portage tree.
</console>
+
  
After <tt>qemu</tt> and its dependencies have been installed, you are now ready to start setting up your Windows 7 environment.
+
; --searchdesc -S
 +
: Matches the search string against the description field as well as the package name.
  
== Windows 7 ISO Images ==
+
; --ask -a
 +
: Ask for confirmation before performing any changes.
  
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:
+
; --pretend -p
 +
: Instead of actually performing the merge, simply display what *would* have been installed if --pretend weren't used.
  
http://msft-dnl.digitalrivercontent.net/msvista/pub/X15-65804/X15-65804.iso
+
; --unmerge -C
 +
: Removes all matching packages.
  
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:
+
; --update -u
 +
: Updates  packages to the best version available, which may not always be the highest version number due to masking for testing and development.
  
http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/
+
; --deep [DEPTH] -D
 +
: force  emerge  to  consider  the  entire  dependency tree of packages, instead of checking only the immediate dependencies of the packages.
  
== Create Raw Disk ==
+
; --newuse -N
 +
: Tells emerge to include installed packages where USE flags have changed since compilation.
  
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:
+
; --depclean -c
 +
: Remove orphaned packages. Cleans the system by removing packages that are not associated with explicitly merged packages.
  
<console>
+
; --autounmask-write
$ ##i##cd
+
: Automatically write package.use settings as necessary to satisfy dependencies.
$ ##i##qemu-img create -f raw win7.img 30G
+
</console>
+
  
We now have an empty virtual disk image called <tt>win7.img</tt> in our home directory.
+
; --resume -r
 +
: Resumes  the  most recent merge list that has been aborted due to an error.
  
== QEMU script ==
+
; --jobs[=JOBS] -j [JOBS]
 +
: Specifies the number of packages to build simultaneously.
  
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:
+
; --load-average [LOAD]
 +
: Specifies  that  no  new  builds should be started if there are other builds running and the load average is at least LOAD (a floating-point number).
  
* Adjust the name of <tt>VIRTIMG</tt> to match the exact name of the VirtIO ISO image you downloaded earlier
+
== Configuration ==
* 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.
+
Emerge can be configured with /etc/portage/make.conf
 +
<pre>CFLAGS="-march=native -O2 -pipe"
 +
CXXFLAGS="-march=native -O2 -pipe"
  
Use your favorite text editor to create the following script. Name it something like <tt>vm.sh</tt>:
+
MAKEOPTS="-j2"
 +
EMERGE_DEFAULT_OPTS="--jobs 2 --load-average 2"
 +
INPUT_DEVICES="evdev synaptics"
 +
VIDEO_CARDS="intel i965"
 +
LINGUAS="en en_US en_GB"
 +
ACCEPT_LICENSE="*"
  
<syntaxhighlight lang="bash">
+
USE="mmx mmxext sse sse2 sse3 ssse3 threads alsa X gtk xcb dri opengl vaapi udev \
#!/bin/sh
+
    svg x264 xvid gstreamer webm vpx icu bash-completion vim-pager \
export QEMU_AUDIO_DRV=alsaDISKIMG=~/win7.img
+
    -gnome -xscreensaver -cups -fortran -deprecated -iptables -ipv6 -geoloc \
WIN7IMG=~/Downloads/X15-65804.iso
+
    -mta -sendmail -kmod -tiff -live -quicktime -real -gpm -themes"</pre>
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:
+
Per-package use flags can be configured with /etc/portage/package.use
 +
<pre>x11-wm/dwm savedconfig
 +
media-sound/ncmpcpp visualizer clock taglib</pre>
  
<console>
+
If you want to install package that has not been tested on your architecture you need to edit /etc/portage/package.accept_keywords
$ ##i##chmod +x vm.sh
+
<pre>=app-misc/screenfetch-9999 **</pre>
</console>
+
  
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.
+
== Further info ==
 +
For further info see emerge man page.
 +
<console>$ man emerge</console>
  
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.
+
[[Category:Portage]]
 
+
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!
+
  
 +
[[Category:HOWTO]]
 
[[Category:Tutorial]]
 
[[Category:Tutorial]]
 
[[Category:First Steps]]
 
[[Category:First Steps]]

Revision as of 05:23, 22 November 2013

Contents

Getting started with emerge

Emerge is the front-end for funtoo's portage package manager. With emerge its easy to install, update or remove packages.

Update package database

Sync local package database. This will update your local Portage tree with the latest Funtoo ebuilds.

# emerge --sync

Search packages

Search packages by name.

# emerge -s firefox
# emerge --search firefox

Search packages by description.

# emerge -S web browser
# emerge --searchdesc web browser

Install packages

Install package.

# emerge firefox

Install multiple packages.

# emerge firefox thunderbird

Install package. Ask for confirmation before performing any changes. Show verbose output.

# emerge -av firefox

Remove packages

Remove package.

# emerge -C firefox
# emerge --unmerge firefox

Remove package. Ask for confirmation before performing any changes.

# emerge -aC firefox

Remove orphaned packages. Ask for confirmation before performing any changes.

# emerge -a --depclean

Update packages

Update all packages.

# emerge -uDN @world

Update all packages. Ask for confirmation before performing any changes. Show verbose output.

# emerge -uavDN @world

Emerge options

--sync
Updates the portage tree that is located in /usr/portage by default.
--search -s
Searches for matches of the supplied string in the portage tree.
--searchdesc -S
Matches the search string against the description field as well as the package name.
--ask -a
Ask for confirmation before performing any changes.
--pretend -p
Instead of actually performing the merge, simply display what *would* have been installed if --pretend weren't used.
--unmerge -C
Removes all matching packages.
--update -u
Updates packages to the best version available, which may not always be the highest version number due to masking for testing and development.
--deep [DEPTH] -D
force emerge to consider the entire dependency tree of packages, instead of checking only the immediate dependencies of the packages.
--newuse -N
Tells emerge to include installed packages where USE flags have changed since compilation.
--depclean -c
Remove orphaned packages. Cleans the system by removing packages that are not associated with explicitly merged packages.
--autounmask-write
Automatically write package.use settings as necessary to satisfy dependencies.
--resume -r
Resumes the most recent merge list that has been aborted due to an error.
--jobs[=JOBS] -j [JOBS]
Specifies the number of packages to build simultaneously.
--load-average [LOAD]
Specifies that no new builds should be started if there are other builds running and the load average is at least LOAD (a floating-point number).

Configuration

Emerge can be configured with /etc/portage/make.conf

CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="-march=native -O2 -pipe"

MAKEOPTS="-j2"
EMERGE_DEFAULT_OPTS="--jobs 2 --load-average 2"
INPUT_DEVICES="evdev synaptics"
VIDEO_CARDS="intel i965"
LINGUAS="en en_US en_GB"
ACCEPT_LICENSE="*"

USE="mmx mmxext sse sse2 sse3 ssse3 threads alsa X gtk xcb dri opengl vaapi udev \
     svg x264 xvid gstreamer webm vpx icu bash-completion vim-pager \
     -gnome -xscreensaver -cups -fortran -deprecated -iptables -ipv6 -geoloc \
     -mta -sendmail -kmod -tiff -live -quicktime -real -gpm -themes"

Per-package use flags can be configured with /etc/portage/package.use

x11-wm/dwm savedconfig
media-sound/ncmpcpp visualizer clock taglib

If you want to install package that has not been tested on your architecture you need to edit /etc/portage/package.accept_keywords

=app-misc/screenfetch-9999 **

Further info

For further info see emerge man page.

$ man emerge