0

I have an Ubuntu server with virt-manager. I have an Ubuntu VM running on this host from a qcow2 file. I don't use separate disk files or img files besides the qcow2 file. I want to allocate 50 GB of new storage space to the VM.

On the VM, df -h has results with a column header of "File Systems" on the left hand side. I want a dedicated file system of 50 GB to be mounted on /opt/special/. I want this to be part of the .qcow2 file.

On the physical server, I tried creating a new qcow2 file. I did so, and created a VM off it. The VM works, but all the space (including the new 50 GB of extra space that I resized in the new qcow2 file) is in a file system that is part of the original file system mounted on /. So I don't know how to unmount it to partition it. I want to take 50 GB from it and dedicate it to its own filesystem (as seen with a df -h). I tried using libguestfs-tools, qemu-img resize, truncate and other commands to make it work. Nothing seems to work at the time I create a new, modified qcow2 file.

I tried using the GUI application named Virtual Machine Manager. But when I added hardware (to add storage capacity as raw disk or a qcow2 file), the VM wouldn't start back up. I got an error. What should I do to add 50 GB of space and have it appear under "Filesystem" when I do a df -h and have this 50 GB be mounted on /opt/special/ (a directory that doesn't exist yet)?

I want the 50 GB file system to be mounted on /opt/special/ even after a reboot.

I could try to create an entirely new VM, then within it try to repartition the disk. Or I could use the virt-* commands to create a new VM with a dedicate partition. Should I use the virt-* commands or use mkfs.ext3 etc. from within the VM? Either way, I'm not sure how to proceed (b/c I cannot unmount the / file system, and the virt-* commands only add disk space to the / file system).

Catbird55
  • 163
  • 1
  • 1
  • 6

1 Answers1

2

Assuming the VM you want to extend is currently running, all you need, with virt-manager is:

  • create the new 50Gb qcow2 storage you want to add
  • open the VM's 'hardware detail' panel
  • add a new virtual disk using the storage just created.
  • reboot the machine: your new storage should appear as /dev/sdb or /dev/vdb depending on disk bus type you are using.
  • at this point, you need to use either fdisk or lvm commands and then mkfs to make use or this storage.
tonioc
  • 1,047
  • 8
  • 11