当前位置:网站首页>KVM virtual machine online disk expansion -- the road to dream

KVM virtual machine online disk expansion -- the road to dream

2022-06-21 22:35:00 The road to dream

KVM Online capacity expansion method of virtual machine disk :

1. adopt virsh blockresize Command to expand the current disk

2. adopt virsh attach-disk Command to add a hard disk device to the virtual machine online

#  View virtual machine disk information 

virsh domblklist win10

#  Disk expansion 

 View current disk information 

qemu-img info  /kvm/img/win10.img

 Disk expansion 

virsh blockresize win10 /kvm/img/win10.img 100G

#  Enter system expansion volume   Omit   
virsh attach-disk Capacity expansion 

#  View all virtual machines 

virsh list --all

#  View the disk information of the specified virtual machine 

virsh domblklist vm01

#  create disk 

qemu-img create -f qcow2   /kvm/img/vm01_add01.qcow2 5G

#  Add disks online 

virsh attach-disk  vm01 /kvm/img/vm01_add01.qcow2 vdb --cache=none --subdriver=qcow2

#  Enter virtual machine verification 

virsh console   vm01

 fdisk -l /dev/sdb

#  Create partitions  lvm Capacity expansion 

 This step is omitted 

#  Modify the virtual machine configuration file 

 Write the new disk configuration to the virtual machine disk configuration , Avoid loss of restart 

virsh edit vm01

<disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/kvm/img/vm01_add01.qcow2'/>
      <target dev='vdb' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</disk>

#  Restart validation 

virsh  console vm01

原网站

版权声明
本文为[The road to dream]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206212039577933.html