【转】KVM/Installation

时间:2022-10-31 17:33:46

【转】KVM/Installation

Installation

Pre-installation checklist

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.

By default, if you booted into XEN kernel it will not display svm or vmx flag using the grep command. To see if it is enabled or not from xen, enter:

cat /sys/hypervisor/properties/capabilities

You must see hvm flags in the output.

Alternatively, you may execute:

kvm-ok 

which may provide an output like this:

INFO: /dev/kvm exists
KVM acceleration can be used

If you see :

INFO: Your CPU does not support KVM extensions
KVM acceleration can NOT be used

You can still run virtual machines, but it'll be much slower without the KVM extensions.

NOTE: You may see a message like "KVM acceleration can/can NOT be used". This is misleading and only means if KVM is *currently* available (i.e. "turned on"), *not* if it is supported.

Use a 64 bit kernel (if possible)

Running a 64 bit kernel on the host operating system is recommended but not required.

  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

Install Necessary Packages

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:

Lucid (10.04) or later

$ sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils

Karmic (9.10) or earlier

$ 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

  • qemu-kvm (kvm in Karmic and earlier) 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.

Add Users to Groups

Karmic (9.10) and later (but not 14.04 LTS)

You need to ensure that your username is added to the group libvirtd:

$ sudo adduser `id -un` libvirtd
Adding user '<username>' to group 'libvirtd' ...

After this, you need to relogin so that your user becomes an effective member of the libvirtd group. The members of this group can run virtual machines. (You can also 'newgrp kvm' in a terminal, but this will affect only that terminal.)

Releases prior to Karmic (9.10)

You need to ensure that your username is added to the groups: kvm and libvirtd.

To check:

$ groups
adm dialout cdrom floppy audio dip video plugdev fuse lpadmin admin sambashare kvm libvirtd

To add your <username> to the groups:

$ sudo adduser `id -un` kvm
Adding user '<username>' to group 'kvm' ...
$ sudo adduser `id -un` libvirtd
Adding user '<username>' to group 'libvirtd' ...

After the installation, you need to relogin so that your user becomes an effective member of kvm and libvirtd user groups. The members of this group can run virtual machines.

Verify Installation

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 (e.g. you did not relogin) 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.

The sock file should have permissions similar to:

$ sudo ls -la /var/run/libvirt/libvirt-sock
srwxrwx--- 1 root libvirtd 0 2010-08-24 14:54 /var/run/libvirt/libvirt-sock

Also, /dev/kvm needs to be in the right group. If you see:

 $ ls -l /dev/kvm
crw-rw----+ 1 root root 10, 232 Jul 8 22:04 /dev/kvm

You might experience problems when creating a virtual machine. Change the device's group to kvm/libvirtd instead:

sudo chown root:libvirtd /dev/kvm

Now you need to either relogin or restart the kernel modules:

rmmod kvm
modprobe -a kvm

Optional: Install virt-manager (graphical user interface)

If you are working on a desktop computer you might want to install a GUI tool to manage virtual machines.

$ sudo apt-get install virt-manager

Virtual Machine Manager will appear in Applications -> System Tools menu. First create a new connection to local QEMU instance from File ->Add Connection menu. Localhost (QEMU) or QEMU/KVM should appear in the virtual machine list. Note: there already exist Localhost (QEMU Usermode) connection but this does not work at least on Ubuntu 10.04.

Create a new virtual machine by pressing the top left Create a new virtual machine toolbar button.

Version-specific Notes

8.10 (Intrepid) Notes

  • Two meta packages have been added: ubuntu-virt-server and ubuntu-virt-mgmtUbuntu-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.

11.10 (Oneric) Notes

Switching to the server kernel might be helpful if there are start problems with virtual machines (i.e. Windows XP freezes approximately once every 5 starts )

【转】KVM/Installation的更多相关文章

  1. 云计算大数据:Xen、KVM、VMware、hyper-v等虚拟化技术的比较

    1.Xen.KVM.VMware.hyper-v等虚拟化技术的比较,xen和kvm,是开源免费的虚拟化软件. vmware是付费的虚拟化软件. hyper-v比较特别,是微软windows 2008 ...

  2. Install KVM Hypervisor on arrch64 Linux Server

    Install KVM Hypervisor on arrch64 Linux Server 参考链接: https://wiki.ubuntu.com/ARM64/QEMU https://wiki ...

  3. ubuntu安装KVM

    1. vmware安装ubuntu-14.04.1-server-amd64.iso.2. 安装完成后关机--右键虚拟机--setting--hardware--Processors--将 virtu ...

  4. Android模拟器使用教程

    Using the Emulator In this document Overview Android Virtual Devices and the Emulator Starting and S ...

  5. 【转】How to Start Intel Hardware-assisted Virtualization &lpar;hypervisor&rpar; on Linux to Speed-up Intel Android x86 Emulator

    [转]How to Start Intel Hardware-assisted Virtualization (hypervisor) on Linux to Speed-up Intel Andro ...

  6. 【转】Configuring VM Acceleration on Linux

    Configuring VM Acceleration on Linux Linux-based systems support virtual machine acceleration throug ...

  7. virt

    www.itwhy.org/linux/debian7-%E5%AE%89%E8%A3%85-kvm-%E8%99%9A%E6%8B%9F%E6%9C%BA.html www.storageonlin ...

  8. Ubuntu 18&period;04 下配置 HAXM 加速 Android模拟器

    Ubuntu 18.04 下配置 HAXM 加速 Android模拟器 最近在vmware环境下搭建ubuntu18.04开发环境,开始发现总是运行android模拟器在console提示加载如下错误 ...

  9. Andriod Atom x86模拟器启动报错。

    用Inter Atom模式的Android模拟器启动报一下错误: Starting emulator for AVD 'new' emulator: ERROR: x86 emulation curr ...

随机推荐

  1. iOS开发之ReactiveCocoa下的MVVM(干货分享)

    最近工作比较忙,但还是出来更新博客了,今天给大家分享一些ReactiveCocoa以及MVVM的一些东西,干活还是比较足的.在之前发表过一篇博文,名字叫做<iOS开发之浅谈MVVM的架构设计与团 ...

  2. git 版本控制

    用gitbash进入类似命令行的窗口 用命令 cd e:/learngit 进入该目录,然后在此目录下初始化$ git init, 于是该文件夹就成为了一个工作区,里面的.git文件就是版本库(rep ...

  3. python 培训之 装饰器

    1. 高阶函数 接收 函数作为参数,返回函数. 2. 函数闭包 3. 接收一个函数为参数,对其进行包装,然后返回一个包装函数(tip:包装函数中调用并返回参数函数. #! /usr/env/pytho ...

  4. D3&period;js 更*的条形图

    一.添加一个矩形 //Width and height var w = 500; var h = 100; var dataset = [ 5, 10, 13, 19, 21, 25, 22, 18, ...

  5. 新版mysql(mysql-5&period;7&period;12-winx64)安装

    之前安装了一个php集成运行环境的mysql,不太习惯,还是想弄一个原生的环境来进行学习.于是,卸载了php集成环境中的mysql. 计算机环境:win7 x64. 1.mysql-5.7.12-wi ...

  6. android 中通过代码创建控件

    package bvb.de.openadbwireless.circle; import android.annotation.TargetApi; import android.app.Activ ...

  7. 让用户打开你app的位置功能

    +运动 http://www.ccidnet.com/2015/0819/10014152.shtml 让你的app不再是一个购物网站, 而是一种生活方式, 逛街,在实体店逛街积累里程,兑换积分  送 ...

  8. 关于mysql使用命令行时出现Data too long for column的解决方案:

    方法一: 1,在mysql根目录下找到my.ini文件: 2:将其中sql-mode中的STRICT_TRANS_TABLES这个属性去掉: 3:重启mysql的服务(注意注销电脑不会重启mysql服 ...

  9. Mac下GTest的基本使用

    Mac下GTest的基本使用 gtest全称Google C++ Testing Framework,它是从谷歌内部诞生并受到业界追捧的一个非常优秀的测试框架,支持如自动发现测试.自定义断言.死亡测试 ...

  10. More Effective C&num; 【前戏】

    买了很多很多书,想到就买,觉得有需要就买.买书的情况是不一样的:有时候,买的时候还是比较空,买来之后工作开始忙起来了,就没怎么看:有时候,买的时候比较忙,忙的乱了方寸,觉得有必要找本书来静心一下.不过 ...