1

I use GNOME Boxes on Fedora 32 to virtualize a Fedora Silverblue installation. I did not setup a sophisticated/smart partitioning for my virtual Fedora and have run out of disk space on my virtual root partition. My objective is to be able to continue using my virtual Fedora machine as efficient and soon as possible without recreating the virtualization and without adding another partition.

Therefore, how can I increase the root partition of my QEMU-based virtualization?

Similar question: Resize qcow2 root parition

justjulian
  • 31
  • 4

1 Answers1

2

Stop the virtual machine and execute the following steps on the host.

In case its not installed yet, you need the following tools

sudo dnf install libguestfs-tools-c

Locate the image files on your host. On Fedora that is

cd ~/.local/share/gnome-boxes/images

Identify the root partition of your image that you want to increase

virt-filesystems --long --parts --blkdevs -h -a <my-current-fedora-image>

Name       Type       MBR  Size  Parent
/dev/sda1  partition  83   1,0G  /dev/sda
/dev/sda2  partition  8e   19G   /dev/sda
/dev/sda   device     -    20G   -

In my example that is /dev/sda2 = <identified-partition>

Create an empty image file in the correct format with the new root partition file size

qemu-img create -f qcow2 -o preallocation=metadata <my-new-fedora-image> <the-file-size-in-GB>G

Resize the root partition of the current image to the new image

virt-resize --expand <identified-partition> <my-current-fedora-image> <my-new-fedora-image>

Rename the new image file name to the old one so that GNOME Boxes will use it instead of the old one but keep the other one around as backup

mv <my-current-fedora-image> <my-old-fedora-image>
mv <my-new-fedora-image> <my-current-fedora-image>

This is all you have to do on the host. Now start the virtual machine with the increased root disk size, log in, and execute the following steps on the virtual machine.

Resize the partition that you identified for copying

sudo pvresize <identified-partition>

Identify the root filesystem name to extend

df -h

In my example that is /dev/mapper/fedora-root = <identified-filesystem>

Extend its logical volume size to make the additional space usable

sudo lvextend -r -l +100%FREE <identified-filesystem>

Source: https://www.reddit.com/r/gnome/comments/3ijfm5/cant_increase_vm_disk_size_in_gnome_boxes/

justjulian
  • 31
  • 4