RunningKVM: Difference between revisions

From KVM
No edit summary
 
m (Bsd moved page HOWTO1 to RunningKVM: Rename to something more appropriate)
 
(5 intermediate revisions by 5 users not shown)
Line 3: Line 3:
You will need (see download section):
You will need (see download section):


* kvm-''release''.tar.gz
* qemu-kvm-''release''.tar.gz
* kvm-kmod-''release''.tar.bz2 (if you want/need to compile kernel modules yourself)
* A VT capable Intel processor, or an SVM capable AMD processor
* A VT capable Intel processor, or an SVM capable AMD processor
* qemu prerequisites:
* qemu prerequisites:
Line 13: Line 14:


On a debian etch system you can install the prerequisites with:
On a debian etch system you can install the prerequisites with:
   apt-get install gcc libsdl1.2-dev zlib1g-dev libasound2-dev linux-kernel-headers pkg-config libgnutls-dev
   apt-get install gcc libsdl1.2-dev zlib1g-dev libasound2-dev linux-kernel-headers pkg-config libgnutls-dev libpci-dev


'''Note:''' When building from git, you also need gawk.
'''Note:''' When building from git, you also need gawk.
Line 24: Line 25:
There exists a [attachment:kvm-26-alt-grab.diff.gz patch] which will change the SDL keygrab combination from ctrl-alt to ctrl-alt-shift.  It was written primarily to deal with the heavy use of ctrl-alt-delete in NT-based VMs.
There exists a [attachment:kvm-26-alt-grab.diff.gz patch] which will change the SDL keygrab combination from ctrl-alt to ctrl-alt-shift.  It was written primarily to deal with the heavy use of ctrl-alt-delete in NT-based VMs.


If you are using a patched kernel (e.g. a recent -mm kernel or the kvm git tree), configure the kernel normally, boot into it, and:
If you are using a recent kernel (2.6.25+) with kvm modules included, boot into it, and:


  tar xzf kvm-release.tar.gz
  tar xzf qemu-kvm-release.tar.gz
  cd kvm-release
  cd qemu-kvm-release
  ./configure --prefix=/usr/local/kvm --with-patched-kernel
  ./configure --prefix=/usr/local/kvm
  make
  make
  sudo make install
  sudo make install
Line 34: Line 35:
  # or: sudo /sbin/modprobe kvm-amd
  # or: sudo /sbin/modprobe kvm-amd


If you're ''not'' running a patched kernel:
If you're using an older kernel, or a kernel from your distribution without the kvm modules, you'll have to compile the modules yourself:


  tar xzf kvm-release.tar.gz
  tar xjf kvm-kmod-release.tar.bz2
  cd kvm-release  
  cd kvm-kmod-release  
  ./configure --prefix=/usr/local/kvm
  ./configure
  make  
  make  
  sudo make install  
  sudo make install  
Line 47: Line 48:


== Creating a disk image for the guest ==
== Creating a disk image for the guest ==
  /usr/local/kvm/bin/qemu-img create -f qcow vdisk.img 10G  
  /usr/local/kvm/bin/qemu-img create -f qcow2 vdisk.img 10G  




Line 56: Line 57:


(kvm doesn't make a distinction between i386 and x86_64 so even in i386 you should use `qemu-system-x86_64`)[[BR]]   
(kvm doesn't make a distinction between i386 and x86_64 so even in i386 you should use `qemu-system-x86_64`)[[BR]]   
If you're installing Windows, forcing your emulated machine to not have ACPI support by using -no-acpi could result in much faster installation and performance while running.  See ["Windows ACPI Workaround"] for details.


If you have less than 1GB of memory don't use the -m 384 flag (which allocates 384 MB of RAM for the guest). For computers with 512MB of RAM it's safe to use -m 192, or even -m 128 (the default)
If you have less than 1GB of memory don't use the -m 384 flag (which allocates 384 MB of RAM for the guest). For computers with 512MB of RAM it's safe to use -m 192, or even -m 128 (the default)
Line 72: Line 71:
If you're on Debian Etch, substitute `kvm` for `qemu-system-x86_64` (thanks to fromport, soren and mael_). See also the entries under the label "Ubuntu" on the [[HOWTO]] page.
If you're on Debian Etch, substitute `kvm` for `qemu-system-x86_64` (thanks to fromport, soren and mael_). See also the entries under the label "Ubuntu" on the [[HOWTO]] page.
qemu-system-x86_64`
qemu-system-x86_64`
If you're on Fedora/RHEL/CentOS (and installed a kvm package and not built kvm yourself from source) then substitute '''qemu-kvm''' for '''qemu-system-x86_64'''

Latest revision as of 15:57, 16 May 2015

Prerequisites

You will need (see download section):

  • qemu-kvm-release.tar.gz
  • kvm-kmod-release.tar.bz2 (if you want/need to compile kernel modules yourself)
  • A VT capable Intel processor, or an SVM capable AMD processor
  • qemu prerequisites:
    • `zlib` libraries and headers
    • `SDL` libraries and headers
    • `alsa` libraries and headers (optional alsa support: disabled by default but can be enabled with --enable-alsa)
    • `gnutls` libraries and headers (optional VNC TLS support: enabled by default but can be disabled with --disable-vnc-tls)
    • kernel headers (on Fedora, the kernel-devel package)

On a debian etch system you can install the prerequisites with:

 apt-get install gcc libsdl1.2-dev zlib1g-dev libasound2-dev linux-kernel-headers pkg-config libgnutls-dev libpci-dev

Note: When building from git, you also need gawk.

Please report problems (and successes) to the mailing list.

Unpacking and configuring kvm components

You may wish to take a look at the ["Kernel-optimizations"] page. There exists a [attachment:kvm-26-alt-grab.diff.gz patch] which will change the SDL keygrab combination from ctrl-alt to ctrl-alt-shift. It was written primarily to deal with the heavy use of ctrl-alt-delete in NT-based VMs.

If you are using a recent kernel (2.6.25+) with kvm modules included, boot into it, and:

tar xzf qemu-kvm-release.tar.gz
cd qemu-kvm-release
./configure --prefix=/usr/local/kvm
make
sudo make install
sudo /sbin/modprobe kvm-intel
# or: sudo /sbin/modprobe kvm-amd

If you're using an older kernel, or a kernel from your distribution without the kvm modules, you'll have to compile the modules yourself:

tar xjf kvm-kmod-release.tar.bz2
cd kvm-kmod-release 
./configure
make 
sudo make install 
sudo /sbin/modprobe kvm-intel 
# or: sudo /sbin/modprobe kvm-amd

Note: if sound doesn't play in the guest vm you can add --audio-drv-list="alsa oss" to ./configure as explained in http://www.linux-kvm.com/content/sound-problem-solved

Creating a disk image for the guest

/usr/local/kvm/bin/qemu-img create -f qcow2 vdisk.img 10G 


Installing a guest operating system

sudo /usr/local/kvm/bin/qemu-system-x86_64 -hda vdisk.img -cdrom /path/to/boot-media.iso \ 
   -boot d  -m 384

(kvm doesn't make a distinction between i386 and x86_64 so even in i386 you should use `qemu-system-x86_64`)BR

If you have less than 1GB of memory don't use the -m 384 flag (which allocates 384 MB of RAM for the guest). For computers with 512MB of RAM it's safe to use -m 192, or even -m 128 (the default)

Running the newly-installed guest

sudo /usr/local/kvm/bin/qemu-system-x86_64 vdisk.img -m 384

or a slightly more complicated example, where it is assumed that bridged networking is available on tap0; see ["Kernel-optimizations"] for some setup hints:

/usr/local/kvm/bin/qemu-system-x86_64 -hda xp-curr.img -m 512 -soundhw es1370 -no-acpi -snapshot -localtime -boot c -usb -usbdevice tablet -net nic,vlan=0,macaddr=00:00:10:52:37:48 -net tap,vlan=0,ifname=tap0,script=no

(kvm doesn't make a distinction between i386 and x86_64 so even in i386 you should use `qemu-system-x86_64`)

If you're on Debian Etch, substitute `kvm` for `qemu-system-x86_64` (thanks to fromport, soren and mael_). See also the entries under the label "Ubuntu" on the HOWTO page. qemu-system-x86_64`

If you're on Fedora/RHEL/CentOS (and installed a kvm package and not built kvm yourself from source) then substitute qemu-kvm for qemu-system-x86_64