vm-bhyve icon indicating copy to clipboard operation
vm-bhyve copied to clipboard

Cloud images are not resized according to the required disk size

Open galdor opened this issue 2 years ago • 0 comments

In the current state (vm-bhyve 1.5), vm created from a cloud image have a disk whose size is the virtual size of the cloud image size.

For example:

vm img https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.img
vm create -i ubuntu-22.04-server-cloudimg-amd64.img -s 100G

This creates a VM whose disk is 2.2GB, which is the virtual size of the Ubuntu cloud image (check with qemu-img info <vm-path>/.img/ubuntu-22.04-server-cloudimg-amd64.img), even though we expect a VM with a 100GB disk.

One way to fix this would be to use qemu-img resize. But since we probably do not want to touch the original image, would it be acceptable to modify core::write_img to:

  • Copy $_imgpath to ${img_path}.tmp.
  • Call qemu-img resize ${img_path}.tmp $_size.
  • Run qemu-img dd on the temporary image.
  • Delete the temporary image.

Of course it would mean extra disk usage during the operation. I do not think this is a huge deal, but someone may have a better idea.

I can write the patch if maintainers (who are they?) agree.

galdor avatar Aug 02 '22 09:08 galdor