1 建立新的虛擬硬盤dom
# qemu-img create -f qcow2 /data/kvm/CentOs6.7_2.qcow2 2Gide
2 關閉虛擬機spa
# virsh shutdown CentOs6.7
ci
3 編輯配置文件,注意source file和source fileget
<disk type='file' device='disk'>虛擬機
<driver name='qemu' type='qcow2' cache='none'/>it
<source file='/data/kvm/CentOs6.7.qcow2'/>io
<target dev='vda' bus='virtio'/>console
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>function
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/data/kvm/CentOs6.7_2.qcow2'/>
<source file='vdb' bus='virtio'/>
# 此行刪去,會自動生成
# <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</disk>
4 啓動虛擬機
# virsh start CentOs6.7 --console
5 分區、格式化、掛載便可使用
# mkfs.ext4 /dev/vdb
# mount /dev/vdb /mnt/
6 此處也能夠將新的虛擬磁盤加入root的lvm中,此處不詳述
# pvcreate /dev/vdb
# vgextend VolGroup /dev/vdb
# lvextend -l +100%FREE /dev/VolGroup/lv_root
# resize2fs -p /dev/VolGroup/lv_root
# df -h