您的位置:首页 > 其它

debian install kvm qemu

2016-06-26 10:23 363 查看

1 首先要查看CPU是否支持虚拟化:

egrep '^flags.*(vmx|svm)' /proc/cpuinfo

2 KVM与qemu的关系:

KVM是Linux kernel的一个模块,可以用命令modprobe去加载KVM模块。加载了该模块后,才能进一步通过工具创建虚拟机。但是仅有KVM模块是不够的。因为用户无法直接控制内核去做事情,还必须有一个运行在用户空间的工具才行。这个用户空间的工具,kvm开发者选择了已经成型的开源虚拟化软件QEMU。说起来QEMU也是一个虚拟化软件。它的特点是可虚拟不同的CPU。比如说在x86的CPU上可虚拟一个power的CPU,并可利用它编译出可运行在power上的CPU,并可利用它编译出可运行在power上的程序。KVM使用了QEMU的一部分,并稍加改造,就成了可控制KVM的用户空间工具了。所以你会看到,官方提供的KVM下载有两大部分(qemu和kvm)三个文件(KVM模块、QEMU工具以及二者的合集)。也就是说,你可以只升级KVM模块,也可以只升级QEMU工具。这就是KVM和QEMU
的关系。(转)

3 安装KVM qemu

sudo apt-get install qemu-kvm qemu uml-utilities libvirt-bin libvirt-dev

加载内核模块:

modprobe kvm_intel #or kvm_amd

安装图形界面管理工具:

sudo apt-get install virt-manager

添加到开机启动:

systemctl enable libvirtd.service

启动服务:

systemctl restart libvirtd.service

添加现有虚拟机出现错误:“ 'internal error: process exited while connecting to monitor: Could not access KVM kernel module: Permission denied failed to initialize KVM: Permission denied”

处理方式:

编辑/etc/libvirt/qemu.conf

user = "root"

# The group for QEMU processes run by the system instance. It can be
# specified in a similar way to user.
group = "root"

# Whether libvirt should dynamically change file ownership
# to match the configured user/group above. Defaults to 1.
# Set to 0 to disable file ownership changes.
dynamic_ownership = 0
把 user group dynamic_owership 前面的注释去掉
重启服务:

systemctl restart libvirtd.service

4 常用命令:

创建虚拟磁盘:

kvm-img create -f qcow2
centos.img 30G

virsh # list # 查看已经运行的虚拟机

virsh # list --all # 查看所有虚拟机

quit # 退出virsh命令模式

快照管理:

create:

virsh snapshot-create-as Server08 snap1

list:

virsh snapshot-list Server08

reverse:

virsh snapshot-revert --domain Server08 snap1

del:

virsh snapshot-delete Server08 snap1
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  qemu kvm 虚拟化