Skip to main content

Adjusting Default Disk Size for cloud-init Images in Ubuntu

Before resizing a cloud-init image's disk, you should understand:

  1. cloud-init is an open-source tool for initializing and managing new instances in cloud environments. It can configure initial settings including disk size via config files or environment variables.
  2. Resizing requires tools like qemu-img - a command-line utility for disk image manipulation.
  3. Resizing must be done during image creation, as deployed instances cannot have their disk size modified.

Step-by-Step Guide

  1. First, ensure qemu-utils is installed. On Ubuntu:
sudo apt-get update
sudo apt-get install -y qemu-utils
  1. Resize the image (e.g., to 4GiB):
qemu-img resize cloud-init.img 4G
  1. Verify the new size:
qemu-img info cloud-init.img

Expected output (adjust paths/filenames as needed):

image: /path/to/cloud-init.img
file format: qcow2
virtual size: 4.0 GiB (4294967296 bytes)
disk size: 4.0 GiB
cluster_size: 65536

This confirms successful resizing to 4GiB.