特殊:Badtitle/NS100:KVM/Installation
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/KVM/Installation }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/af | • {{#if: UbuntuHelp:KVM/Installation|Afrikaans| [[::KVM/Installation/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/ar | • {{#if: UbuntuHelp:KVM/Installation|العربية| [[::KVM/Installation/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/az | • {{#if: UbuntuHelp:KVM/Installation|azərbaycanca| [[::KVM/Installation/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/bcc | • {{#if: UbuntuHelp:KVM/Installation|جهلسری بلوچی| [[::KVM/Installation/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/bg | • {{#if: UbuntuHelp:KVM/Installation|български| [[::KVM/Installation/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/br | • {{#if: UbuntuHelp:KVM/Installation|brezhoneg| [[::KVM/Installation/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/ca | • {{#if: UbuntuHelp:KVM/Installation|català| [[::KVM/Installation/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/cs | • {{#if: UbuntuHelp:KVM/Installation|čeština| [[::KVM/Installation/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/de | • {{#if: UbuntuHelp:KVM/Installation|Deutsch| [[::KVM/Installation/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/el | • {{#if: UbuntuHelp:KVM/Installation|Ελληνικά| [[::KVM/Installation/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/es | • {{#if: UbuntuHelp:KVM/Installation|español| [[::KVM/Installation/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/fa | • {{#if: UbuntuHelp:KVM/Installation|فارسی| [[::KVM/Installation/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/fi | • {{#if: UbuntuHelp:KVM/Installation|suomi| [[::KVM/Installation/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/fr | • {{#if: UbuntuHelp:KVM/Installation|français| [[::KVM/Installation/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/gu | • {{#if: UbuntuHelp:KVM/Installation|ગુજરાતી| [[::KVM/Installation/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/he | • {{#if: UbuntuHelp:KVM/Installation|עברית| [[::KVM/Installation/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/hu | • {{#if: UbuntuHelp:KVM/Installation|magyar| [[::KVM/Installation/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/id | • {{#if: UbuntuHelp:KVM/Installation|Bahasa Indonesia| [[::KVM/Installation/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/it | • {{#if: UbuntuHelp:KVM/Installation|italiano| [[::KVM/Installation/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/ja | • {{#if: UbuntuHelp:KVM/Installation|日本語| [[::KVM/Installation/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/ko | • {{#if: UbuntuHelp:KVM/Installation|한국어| [[::KVM/Installation/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/ksh | • {{#if: UbuntuHelp:KVM/Installation|Ripoarisch| [[::KVM/Installation/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/mr | • {{#if: UbuntuHelp:KVM/Installation|मराठी| [[::KVM/Installation/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/ms | • {{#if: UbuntuHelp:KVM/Installation|Bahasa Melayu| [[::KVM/Installation/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/nl | • {{#if: UbuntuHelp:KVM/Installation|Nederlands| [[::KVM/Installation/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/no | • {{#if: UbuntuHelp:KVM/Installation|norsk| [[::KVM/Installation/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/oc | • {{#if: UbuntuHelp:KVM/Installation|occitan| [[::KVM/Installation/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/pl | • {{#if: UbuntuHelp:KVM/Installation|polski| [[::KVM/Installation/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/pt | • {{#if: UbuntuHelp:KVM/Installation|português| [[::KVM/Installation/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/ro | • {{#if: UbuntuHelp:KVM/Installation|română| [[::KVM/Installation/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/ru | • {{#if: UbuntuHelp:KVM/Installation|русский| [[::KVM/Installation/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/si | • {{#if: UbuntuHelp:KVM/Installation|සිංහල| [[::KVM/Installation/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/sq | • {{#if: UbuntuHelp:KVM/Installation|shqip| [[::KVM/Installation/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/sr | • {{#if: UbuntuHelp:KVM/Installation|српски / srpski| [[::KVM/Installation/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/sv | • {{#if: UbuntuHelp:KVM/Installation|svenska| [[::KVM/Installation/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/th | • {{#if: UbuntuHelp:KVM/Installation|ไทย| [[::KVM/Installation/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/tr | • {{#if: UbuntuHelp:KVM/Installation|Türkçe| [[::KVM/Installation/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/vi | • {{#if: UbuntuHelp:KVM/Installation|Tiếng Việt| [[::KVM/Installation/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/yue | • {{#if: UbuntuHelp:KVM/Installation|粵語| [[::KVM/Installation/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/zh | • {{#if: UbuntuHelp:KVM/Installation|中文| [[::KVM/Installation/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/zh-hans | • {{#if: UbuntuHelp:KVM/Installation|中文(简体)| [[::KVM/Installation/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:KVM/Installation | UbuntuHelp:KVM/Installation | {{#if: | :}}KVM/Installation}}/zh-hant | • {{#if: UbuntuHelp:KVM/Installation|中文(繁體)| [[::KVM/Installation/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:KVM/Installation|:KVM/Installation|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :KVM/Installation/zh | | {{#ifexist: KVM/Installation/zh | | {{#ifeq: {{#titleparts:KVM/Installation|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:KVM/Installation|1|-1|}} | zh | | }}
- title KVM Installation
<<Include(KVM/Header)>>
Preflight check
How to check if your CPU supports hardware virtualisation
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:
egrep '(vmx|svm)' --color=always /proc/cpuinfo
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.
Use a 64 bit kernel if you need more than 2GB RAM for your VMs
To serve more than 2047 MB 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. To see if your processor is 64 bit, you can run the following command:
grep ' lm ' /proc/cpuinfo
If nothing is printed, it means that your CPU is not 64 bit. lm stands for Long Mode, so 64 bit CPU. To see if your running kernel is 64 bit, just issue the following command:
uname -m
x86_64 indicates a 64-bit kernel running. If you use see i386, i486, i586 or i686, you're running a 32 bit kernel.
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 apt-get install kvm libvirt-bin ubuntu-vm-builder qemu 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 8.10 (intrepid) Notes:
- Two meta packages have been added:
ubuntu-virt-server
andubuntu-virt-mgmt
.Ubuntu-virt-server
installs the packages needed to setup a base virtulization host (kvm, libvirt-bin and openssh-server) andubuntu-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 bypython-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.
Adding Users
Add yourself to the libvirtd group (note that there is no need to add yourself to the kvm group):
$ sudo usermod -aG libvirtd `id -un`
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 usermod -aG libvirtd joe. 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. Note: You should also run the kvm command as root, which should give you the help message of kvm. If you get an error message complaining about the lack of Hardware Acceleration, it is probably disabled at the bios level. You should be able to confirm that by reading the last line of dmesg which should say kvm: disabled at bios level. This is what it looks like when it works:
$ sudo kvm QEMU PC emulator version 0.9.1 (kvm-62), Copyright (c) 2003-2008 Fabrice Bellard usage: qemu [options] [disk_image] ... $
You will get something like this when hardware acceleration is not supported by your CPU or disabled at bios level:
$ sudo kvm Could not initialize KVM, will disable KVM support Ubuntu does not support running KVM without hardware acceleration. Sorry. $
Removing KVM
Removing kvm is pretty easy:
$ sudo apt-get purge kvm
This will unload the kvm modules, remove the kvm and purge its configuration (for example, files in /etc).
If kvm was already removed, the following will finally purge it:
$ sudo dpkg -P kvm
<<Include(KVM/Header)>> ---