Linux KVM | Performing vStorage Management on KVM Hypervisors
In this session, discussion and demo are on performing vStorage management on Linux KVM hypervisors. Here we are providing the commands which we have used for the practical session. Follow the Video tutorial for the more clean understanding of KVM Disk management.
Click here to see the Video tutorial
Many Organizations uses Linux KVM as their Virtualization Hypervisor. As a system engineer managing the Linux KVM VMs, there are tasks admins perform very often:
- Allocate the new disks to the KVM guests.
- Resize the existing allocated disks.
- Detach and delete the existing allocated disks.
For the disk creation, we are going to use “qemu-img” utility. I have seen many admins use “dd” to create new disks/images, but I recommend “qemu-img” over “dd”. Couple of benefits
- Creates sparse file.
- Images can be modified (ex can be resized).
- This utility can handle all type of image formats supported by QEMU.
Please Note – It’s recommendation to the power of the guest when modifying the existing image, which is already allocated /used by a guest VM. If you perform modification operation when VM is using the disk (VM online) can damage the data.
Linux KVM Lab Setup Today:
KVM Data Store : /kvmstore
KVM New Image : /kvmstore /testvm1-appdisk1.img (Hypervisior) & vdb (Guest)
KVM Guest : testvm1
Create virtual disk image.
# qemu-img create -f raw /kvmstore/testvm1-appdisk1.img 200M
Attach the newly created disk to the Linux KVM guest.
# virsh attach-disk testvm1 –source /kvmstore/testvm1-appdisk1.img –target vdb –persistent
Resize the existing image.
# qemu-img resize /kvmstore/testvm1-appdisk1.img +300M
To detach the disk from the KVM.
# virsh detach-disk testvm1 vdb
Conclusion: check out the youtube video for the practical session on KVM Disk management. In this session, we have done disk attaching to the KVM guest and also detaching the same disk.