How to resize a virtual disk of KVM

I test it for qcow2 format. Other formats are TBA.

qemu-img resize kvm1.qcow2 +20G
cp kvm1.qcow2 kvm1-orig.qcow2
virt-resize --expand /dev/sda1 kvm1-orig.qcow2 kvm1.qcow2

Reference: https://fatmin.com/2016/12/20/how-to-resize-a-qcow2-image-and-filesystem-with-virt-resize/

I test it for qcow2 format. Other formats are TBA.

qemu-img resize kvm1.qcow2 +20G
cp kvm1.qcow2 kvm1-orig.qcow2
virt-resize --expand /dev/sda1 kvm1-orig.qcow2 kvm1.qcow2

Reference: https://fatmin.com/2016/12/20/how-to-resize-a-qcow2-image-and-filesystem-with-virt-resize/

Similar Posts

  • How to tune systems to achieve high performance in virtualization circumstances?

    Most time, we need to tune system parameters to achieve better performance but what the general parameters to be tuned in Linux systems. I think you may want to add following parameters to Kernel boot (/etc/default/grub) parameters intel_idle.max_cstate=0 processor.max_cstate=0 idle=poll intel_pstate=disable At the same time, you may also want to shutdown/open Pause Loop Exiting (PLE)….

  • |

    git push error

    $ git push error: The requested URL returned error: 403 Forbidden while accessing https://github.com/HarryWei/hummer.git/info/refs fatal: HTTP request failed Replace (or add) url=ssh://git@github.com/HarryWei/hummer.git with url=https://git@github.com/HarryWei/hummer.git under “[remote “origin”]” section in ~/.gitconfig file. Reference:http://stackoverflow.com/questions/7438313/pushing-to-git-returning-error-code-403-fatal-http-request-failed Read more: Git push error under CENTOS 6.7 Push and Pull data from Restful Service in Asp.net MVC Application using Angular JS Fixing…

  • Installing Dropbox on Linux

    How to install Dropbox on Linux ? Just follow Dropbox’s instruction here: https://www.dropbox.com/install?os=lnx A quick command for 64-bit Linux: $ cd ~ && wget -O – “https://www.dropbox.com/download?plat=lnx.x86_64” | tar xzf – Use the dropx CLI: http://www.dropboxwiki.com/Using_Dropbox_CLI Download dropbox.py: $ wget -O ~/bin/dropbox.py “https://www.dropbox.com/download?dl=packages/dropbox.py” Set the permissions: $ chmod +x ~/bin/dropbox.py Start Dropbox: $ dropbox.py start Status:…

  • How to force umount a NFS directory on Linux?

    The NFS server is down. It is reported “Stale NFS file handle”. I tried ‘umount’ and ‘umount -f’. But neither succeeded. # umount /mnt/store umount.nfs: /mnt/store: Stale NFS file handle # umount -f /mnt/store umount.nfs: /mnt/store: Stale NFS file handle How to force umounting the NFS without rebooting the Linux server? I usually have to…

2 Comments

  1. The right answer is:

    cp kvm1.qcow2 kvm1-orig.qcow2
    qemu-img resize kvm1.qcow2 +20G
    virt-resize –expand /dev/sda1 kvm1-orig.qcow2 kvm1.qcow2

    First copy, second resize the new image, third resize partition.

  2. How to expand a kvm .img with only one reboot:

    qemu-img resize {/smnt/virt/images/name.img} +size (k, M, G or T)
    virsh qemu-monitor-command {VM-name} info block –hmp (Capture the drive-virtio-disk number, usually 0)
    virsh qemu-monitor-command {VM-name} block_resize drive-virtio-disk# [new size k, M, G or T] –hmp
    lsblk should show the updated size of /dev/vda
    dmesg {system picks up updated size}
    delete and recreate vda3 using fdisk /dev/vda (c, u, d, 3, w) (c, u, n, p, 3, {default}, {default}, w)
    reboot VM, need to reboot the KVM to update the kernel of the new partition size. Parted will not update the kernel because the volumes are mounted, remounting without reboot will not update the kernel.
    lsblk should show updated size of partition
    resize2fs /dev/vda3

Leave a Reply

Your email address will not be published. Required fields are marked *