Skip to content

Instantly share code, notes, and snippets.

@smurugap
Last active November 17, 2023 06:56
Show Gist options
  • Save smurugap/f83284fd6ab37bd27e5e5e600f6997d4 to your computer and use it in GitHub Desktop.
Save smurugap/f83284fd6ab37bd27e5e5e600f6997d4 to your computer and use it in GitHub Desktop.
Install packages:
# yum install -y libguestfs-tools qemu-img
Create the target image
# qemu-img create -f qcow2 target.qcow2 256G
Expand the new image and resize the partitions
# virt-resize --expand /dev/sda1 ubuntu.qcow2 target.qcow2
If CentOS, do xfs_growfs inside the VM after boot
# yum install cloud-utils-growpart
# growpart /dev/vda 1
# xfs_growfs /dev/vda1
@smurugap
Copy link
Author

Used below commands on ubuntu qcow2 to resize the disk from inside the VM.

growpart /dev/vda 1
resize2fs /dev/vda1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment