Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

has someone already done this? I can't seem to find a working example

The Centos 7 cloud images appear to work correctly, so that's probably a good place to start. Here's an extract from the log on a successful boot/resize:

helpers.py[DEBUG]: Running config-growpart using lock (<cloudinit.helpers.DummyLock object at 0x32fdc10>)
cc_growpart.py[DEBUG]: No 'growpart' entry in cfg.  Using default: {'ignore_growroot_disabled': False, 'mode': 'auto', 'devices': ['/']}
util.py[DEBUG]: Running command ['growpart', '--help'] with allowed return codes [0] (shell=False, capture=True)
util.py[DEBUG]: Reading from /proc/734/mountinfo (quiet=False)
util.py[DEBUG]: Read 2695 bytes from /proc/734/mountinfo
util.py[DEBUG]: Reading from /sys/class/block/vda1/partition (quiet=False)
util.py[DEBUG]: Read 2 bytes from /sys/class/block/vda1/partition
util.py[DEBUG]: Reading from /sys/devices/pci0000:00/0000:00:04.0/virtio1/block/vda/dev (quiet=False)
util.py[DEBUG]: Read 6 bytes from /sys/devices/pci0000:00/0000:00:04.0/virtio1/block/vda/dev
util.py[DEBUG]: Running command ['growpart', '--dry-run', '/dev/vda', '1'] with allowed return codes [0] (shell=False, capture=True)
util.py[DEBUG]: Running command ['growpart', '/dev/vda', '1'] with allowed return codes [0] (shell=False, capture=True)
util.py[DEBUG]: resize_devices took 0.529 seconds
cc_growpart.py[INFO]: '/' resized: changed (/dev/vda, 1) from 8588886016 to 21466932224
helpers.py[DEBUG]: Running config-resizefs using lock (<cloudinit.helpers.DummyLock object at 0x32fdd50>)
util.py[DEBUG]: Reading from /proc/734/mountinfo (quiet=False)
util.py[DEBUG]: Read 2695 bytes from /proc/734/mountinfo
cc_resizefs.py[DEBUG]: resize_info: dev=/dev/vda1 mnt_point=/ path=/
util.py[DEBUG]: Running command ['running-in-container'] with allowed return codes [0] (shell=False, capture=True)
util.py[DEBUG]: Running command ['lxc-is-container'] with allowed return codes [0] (shell=False, capture=True)
util.py[DEBUG]: Reading from /proc/1/environ (quiet=False)
util.py[DEBUG]: Read 0 bytes from /proc/1/environ
util.py[DEBUG]: Reading from /proc/self/status (quiet=False)
util.py[DEBUG]: Read 1043 bytes from /proc/self/status
cc_resizefs.py[DEBUG]: Resizing / (xfs) using xfs_growfs /dev/vda1
util.py[DEBUG]: Running command ('xfs_growfs', '/dev/vda1') with allowed return codes [0] (shell=False, capture=True)
util.py[DEBUG]: Resizing took 1.187 seconds
cc_resizefs.py[DEBUG]: Resized root filesystem (type=xfs, val=True)

This suggests that in addition to cloud-init, you need to make sure the growpart command is available to resize the partition, and you need an appropriate filesystem grow command (xfs_growfs in this case, otherwise probably resize2fs for ext filesystems).

So, I would check:

  1. Is growpart installed on your system?
  2. Is an appropriate filesystem resize command available?
  3. Are there any errors in your cloud-init logs?