首頁 > 軟體

KVM新增虛擬磁碟

2020-06-16 18:04:36

1.通過圖形介面“虛擬機器管理器”新增虛擬磁碟

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

檢視磁碟分割區:

--------------------------------------分割線 --------------------------------------


IT145.com E-mail:sddin#qq.com