个人工具

“UbuntuHelp:KVM/Installation”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
 
第4行: 第4行:
 
<<Include(KVM/Header)>>
 
<<Include(KVM/Header)>>
 
== Installation ==
 
== Installation ==
=== How to check if your CPU supports hardware virtualisation ===
+
=== Check that your CPU supports hardware virtualization ===
To run KVM, you need a processor that supports virtualisation; Intel and AMD both have developed extensions for their processors, respectively INTEL-VT and AMD-V. To see if your processor supports one of these, you can run the following command:
+
To run KVM, you need a processor that supports hardware virtualization. Intel and AMD both have developed extensions for their processors, deemed respectively Intel VT-x (code name Vanderpool) and AMD-V (code name Pacifica). To see if your processor supports one of these, you can review the output from this command:
 
<pre><nowiki>
 
<pre><nowiki>
egrep '(vmx|svm)' --color=always /proc/cpuinfo
+
egrep -c '(vmx|svm)' /proc/cpuinfo
  
 
</nowiki></pre>
 
</nowiki></pre>
If nothing is printed, it means that your CPU doesn't support hardware virtualisation. Otherwise, it does - but you still need to make sure that virtualisation is enabled in the BIOS.
+
If '''0''' it means that your CPU doesn't support hardware virtualization.
=== Use a 64 bit kernel if possible ===
+
If '''1''' (or more) it does - but you still need to make sure that virtualization is enabled in the BIOS.
<ol><li>To serve more than 2047 MB of RAM for your VMs, you '''must''' use a 64 bit kernel (see [[UbuntuHelp:32bit_and_64bit|32bit_and_64bit]]). On a 32 bit kernel install, you'll be limited to 2GB RAM at maximum for a given VM.
+
=== Use a 64 bit kernel (if possible) ===
</li><li>Also, a 64 bit system can host both 32 bit and 64 bit guests.  A 32 bit system can only host 32 bit guests.</li></ol>
+
<ol><li>To serve more than 2GB of RAM for your VMs, you '''must''' use a 64-bit kernel (see [[UbuntuHelp:32bit_and_64bit|32bit_and_64bit]]). On a 32-bit kernel install, you'll be limited to 2GB RAM at maximum for a given VM.
 +
</li><li>Also, a 64-bit system can host both 32-bit and 64-bit guests.  A 32-bit system can only host 32-bit guests.</li></ol>
  
To see if your processor is 64 bit, you can run the following command:
+
To see if your processor is 64-bit, you can run this command:
 
<pre><nowiki>
 
<pre><nowiki>
grep ' lm ' /proc/cpuinfo
+
egrep -c ' lm ' /proc/cpuinfo
 
</nowiki></pre>
 
</nowiki></pre>
If nothing is printed, it means that your CPU is not 64 bit. ''lm'' stands for Long Mode, so 64 bit CPU.
+
If '''0''' is printed, it means that your CPU is not 64-bit.
To see if your running kernel is 64 bit, just issue the following command:
+
If '''1''' or higher, it is.  Note: ''lm'' stands for Long Mode which equates to a 64-bit CPU.
 +
Now see if your running kernel is 64-bit, just issue the following command:
 
<pre><nowiki>
 
<pre><nowiki>
 
uname -m
 
uname -m
 
</nowiki></pre>
 
</nowiki></pre>
'''x86_64''' indicates a 64-bit kernel running. If you use see i386, i486, i586 or i686, you're running a 32 bit kernel.
+
'''x86_64''' indicates a running 64-bit kernel. If you use see i386, i486, i586 or i686, you're running a 32-bit kernel.
 +
Note: x86_64 is synonymous with amd64.
 
=== Installation of KVM ===
 
=== Installation of KVM ===
 
For the following setup, we will assume that you are deploying KVM on a server, and therefore do not have any X server on the machine.
 
For the following setup, we will assume that you are deploying KVM on a server, and therefore do not have any X server on the machine.
第35行: 第38行:
 
* ubuntu-vm-builder powerful command line tool for building virtual machines
 
* ubuntu-vm-builder powerful command line tool for building virtual machines
 
* bridge-utils provides a bridge from your network to the virtual machines
 
* bridge-utils provides a bridge from your network to the virtual machines
You might also want to install ''virt-viewer'', for viewing instances
+
You might also want to install ''virt-viewer'', for viewing instances.
'''8.10 (intrepid) Notes''':
+
* Two meta packages have been added: <code><nowiki>ubuntu-virt-server</nowiki></code> and <code><nowiki>ubuntu-virt-mgmt</nowiki></code>.  <code><nowiki>Ubuntu-virt-server</nowiki></code> installs the packages needed to setup a base virtulization host (kvm, libvirt-bin and openssh-server) and <code><nowiki>ubuntu-virt-mgmt</nowiki></code> installs what you need to administer it from a management station (virt-manager, python-vm-builder and virt-viewer). 
+
* <code><nowiki>ubuntu-vm-builder</nowiki></code> has been replaced by <code><nowiki>python-vm-builder</nowiki></code> ([[UbuntuHelp:JeOSVMBuilder|tutorial]]).
+
'''Note:'''
+
libdevmapper does not load its module when it is installed ([https://bugs.launchpad.net/ubuntu/+source/vm-builder/+bug/277648 bug 277648]) , so you will either need to do a
+
<code><nowiki> $ sudo modprobe dm-loop </nowiki></code>
+
or reboot your system before being able to use it.
+
=== Adding Users ===
+
'''9.10 Notes''':
+
* The libvirt-bin package will now automatically add members of the ''admin'' group to the ''libvirtd'' group.  You still need to log out, and log back in for this change to take effect.
+
Add yourself to the ''libvirtd'' group (note that there is no need to add yourself to the ''kvm'' group):
+
<pre><nowiki>
+
$ sudo adduser `id -un` libvirtd
+
</nowiki></pre>
+
This will give you access to the system-wide libvirtd instance. This is preferable for you because it gives you access to the advanced networking options rather than simply the "userspace networking" option as you may know it from QEmu.
+
'''Note: You need to log out and log back in for the new group membership to take effect.'''
+
Note: The `id -un` command will return the current username, for example if your username is ''joe'' you will be effectively be running ''sudo adduser joe libvirtd''.
+
 
You can test if your install has been successful with the following command:
 
You can test if your install has been successful with the following command:
 
<pre><nowiki>
 
<pre><nowiki>
第69行: 第55行:
 
</nowiki></pre>
 
</nowiki></pre>
 
Something is wrong and you probably want to fix this before you move on. The critical point here is whether or not you have write access to ''/var/run/libvirt/libvirt-sock''.
 
Something is wrong and you probably want to fix this before you move on. The critical point here is whether or not you have write access to ''/var/run/libvirt/libvirt-sock''.
 +
=== Version-specific Notes ===
 +
==== 10.04 (Lucid) Notes ====
 +
None at this time.
 +
==== 9.10 (Karmic) Notes ====
 +
'''Adding Users:'''
 +
* The libvirt-bin package will now automatically add members of the ''admin'' group to the ''libvirtd'' group.  You still need to log out, and log back in for this change to take effect.
 +
Add yourself to the ''libvirtd'' group (note that there is no need to add yourself to the ''kvm'' group):
 +
<pre><nowiki>
 +
$ sudo adduser `id -un` libvirtd
 +
</nowiki></pre>
 +
This will give you access to the system-wide libvirtd instance. This is preferable for you because it gives you access to the advanced networking options rather than simply the "userspace networking" option as you may know it from QEmu.
 +
Note: You need to log out and log back in for the new group membership to take effect.
 +
Note: The `id -un` command will return the current username, for example if your username is ''joe'' you will be effectively be running ''sudo adduser joe libvirtd''.
 +
==== 8.10 (Intrepid) Notes ====
 +
* Two meta packages have been added: <code><nowiki>ubuntu-virt-server</nowiki></code> and <code><nowiki>ubuntu-virt-mgmt</nowiki></code>.  <code><nowiki>Ubuntu-virt-server</nowiki></code> installs the packages needed to setup a base virtulization host (kvm, libvirt-bin and openssh-server) and <code><nowiki>ubuntu-virt-mgmt</nowiki></code> installs what you need to administer it from a management station (virt-manager, python-vm-builder and virt-viewer). 
 +
* <code><nowiki>ubuntu-vm-builder</nowiki></code> has been replaced by <code><nowiki>python-vm-builder</nowiki></code> ([[UbuntuHelp:JeOSVMBuilder|tutorial]]).
 +
Note: libdevmapper does not load its module when it is installed ([https://bugs.launchpad.net/ubuntu/+source/vm-builder/+bug/277648 bug 277648]) , so you will either need to do a
 +
<code><nowiki> $ sudo modprobe dm-loop </nowiki></code>
 +
or reboot your system before being able to use it.
 
<<Include(KVM/Header)>>
 
<<Include(KVM/Header)>>
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2010年5月19日 (三) 23:05的最新版本

  1. title KVM Installation

<<Include(KVM/Header)>>

Installation

Check that your CPU supports hardware virtualization

To run KVM, you need a processor that supports hardware virtualization. Intel and AMD both have developed extensions for their processors, deemed respectively Intel VT-x (code name Vanderpool) and AMD-V (code name Pacifica). To see if your processor supports one of these, you can review the output from this command:

egrep -c '(vmx|svm)' /proc/cpuinfo

If 0 it means that your CPU doesn't support hardware virtualization. If 1 (or more) it does - but you still need to make sure that virtualization is enabled in the BIOS.

Use a 64 bit kernel (if possible)

  1. To serve more than 2GB of RAM for your VMs, you must use a 64-bit kernel (see 32bit_and_64bit). On a 32-bit kernel install, you'll be limited to 2GB RAM at maximum for a given VM.
  2. Also, a 64-bit system can host both 32-bit and 64-bit guests. A 32-bit system can only host 32-bit guests.

To see if your processor is 64-bit, you can run this command:

egrep -c ' lm ' /proc/cpuinfo

If 0 is printed, it means that your CPU is not 64-bit. If 1 or higher, it is. Note: lm stands for Long Mode which equates to a 64-bit CPU. Now see if your running kernel is 64-bit, just issue the following command:

uname -m

x86_64 indicates a running 64-bit kernel. If you use see i386, i486, i586 or i686, you're running a 32-bit kernel. Note: x86_64 is synonymous with amd64.

Installation of KVM

For the following setup, we will assume that you are deploying KVM on a server, and therefore do not have any X server on the machine. You need to install a few packages first:

$ sudo aptitude install kvm libvirt-bin ubuntu-vm-builder bridge-utils
  • libvirt-bin provides libvirtd which you need to administer qemu and kvm instances using libvirt
  • kvm is the backend
  • ubuntu-vm-builder powerful command line tool for building virtual machines
  • bridge-utils provides a bridge from your network to the virtual machines

You might also want to install virt-viewer, for viewing instances. You can test if your install has been successful with the following command:

$ virsh -c qemu:///system list
 Id Name                 State
----------------------------------

$

If on the other hand you get something like this:

$ virsh -c qemu:///system list
libvir: Remote error : Permission denied
error: failed to connect to the hypervisor
$

Something is wrong and you probably want to fix this before you move on. The critical point here is whether or not you have write access to /var/run/libvirt/libvirt-sock.

Version-specific Notes

10.04 (Lucid) Notes

None at this time.

9.10 (Karmic) Notes

Adding Users:

  • The libvirt-bin package will now automatically add members of the admin group to the libvirtd group. You still need to log out, and log back in for this change to take effect.

Add yourself to the libvirtd group (note that there is no need to add yourself to the kvm group):

$ sudo adduser `id -un` libvirtd

This will give you access to the system-wide libvirtd instance. This is preferable for you because it gives you access to the advanced networking options rather than simply the "userspace networking" option as you may know it from QEmu. Note: You need to log out and log back in for the new group membership to take effect. Note: The `id -un` command will return the current username, for example if your username is joe you will be effectively be running sudo adduser joe libvirtd.

8.10 (Intrepid) Notes

  • Two meta packages have been added: ubuntu-virt-server and ubuntu-virt-mgmt. Ubuntu-virt-server installs the packages needed to setup a base virtulization host (kvm, libvirt-bin and openssh-server) and ubuntu-virt-mgmt installs what you need to administer it from a management station (virt-manager, python-vm-builder and virt-viewer).
  • ubuntu-vm-builder has been replaced by python-vm-builder (tutorial).

Note: libdevmapper does not load its module when it is installed (bug 277648) , so you will either need to do a $ sudo modprobe dm-loop or reboot your system before being able to use it. <<Include(KVM/Header)>>