红联Linux门户
Linux帮助

KVM添加虚拟磁盘

发布时间:2015-03-15 14:57:30来源:linux网站作者:dragon123

1.通过图形界面“虚拟机管理器”添加虚拟磁盘
KVM添加虚拟磁盘

KVM添加虚拟磁盘


2.字符界面:
添加一块qcow2
[root@localhost ~]# qemu-img create -f qcow2 kvm-clone.qcow2 2G
Formatting 'kvm-clone.qcow2', fmt=qcow2 size=2147483648 encryption=off cluster_size=65536

在配置文件添加磁盘:
[root@localhost ~]# virsh edit CentOS-virt-clone
virsh edit centos-virt-clone
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/root/kvm-clone-add.qcow2' />
<target dev='vdb' bus='virtio'/>
</disk>

开启虚拟机,发生错误:
[root@localhost ~]# virsh start centos-virt-clone
错误:开始域 centos-virt-clone 失败
错误:internal error Process exited while reading console log output: char device redirected to /dev/pts/2
2015-02-02T11:13:45.039620Z qemu-kvm: -drive file=/root/kvm-clone.qcow2,if=none,id=drive-virtio-disk3,format=qcow2,cache=none: could not open disk image /root/kvm-clone.qcow2: Permission denied

重启“libvirtd”
vim /etc/libvir
user = "root"
# The group for QEMU processes run by the system instance. It can be
# specified in a similar way to user.
group = "root"
dynamic_ownership = 0
[root@localhost ~]# /etc/init.d/libvirtd restart

开启虚拟机:
[root@localhost ~]# virsh start centos-virt-clone
域 centos-virt-clone 已开始


3.在线添加虚拟磁盘:
virsh attach-disk oeltest02 /data/test02_add01.qcow2 sdb --cache=none --subdriver=qcow2

查看磁盘分区:
KVM添加虚拟磁盘

注:以上图片上传到红联Linux系统教程频道中。