cloud-init does not grow the partition nor the filesystem

6,571

I just fixed the same problem. My vmbuilder created an image with a root partition followed by a swap partition. cloud-utils-growpart can't grow the root partition if there's one immediately after it. I deleted the swap partition and the root partition resized correctly on reboot

Share:
6,571

Related videos on Youtube

Korni22
Author by

Korni22

Updated on September 18, 2022

Comments

  • Korni22
    Korni22 over 1 year

    I am currenty preparing OpenStack-ready images of CentOS 7 and Ubuntu 14.04.

    For the "automation" I use Packer, which is provided by you with a JSON-template. Packer then starts the installation using the virtualization you specify (in my case qemu).

    After the installation, the virtual machine is being provisioned via SSH by Packer and the scripts you supply.

    The status:

    • The root disk has 3 GB.
    • One partition, ext4, boot-flag, 100% of the root disk.

    What I am trying to achieve here:

    • The image should resize itself on the first start to the max size of the disk

    The Problem:

    It does not work. It does not matter if I install only cloud-init or cloud-init and cloud-utils or cloud-init and cloud-utils and cloud-utils-growpart. I do not change the default cloud-init config, apart from enabling the root-login via ssh.

    My cloud-init config is standard, apart from this line

    disable_root: 0

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

    • mcdave
      mcdave over 9 years
      Please include the relevant cloud-init configuration and the commands you run.
    • Korni22
      Korni22 over 9 years
      Config is standard, only root-login is enabled (disable_root: 0) I don't run any specific commands, since it's supposed to "just" work, by installing cloud-init
    • EmmEff
      EmmEff over 9 years
      Do you have the gdisk package installed? This is not a dependency on the 'cloud-utils-growpart' package, but it probably should be.
    • Korni22
      Korni22 over 9 years
      I tried it, still doesn't grow. clearpart --all --initlabel gpt was used to ensure gpt as partitioning scheme.
    • Jayan
      Jayan over 9 years
      Instead of creating partition on root device, create filesystem directly on the root device. That way you can have a resize2fs take care of resizing FS every time the system comes up. NOTE: If you have a partition, you have to somehow automate extension of partition before you could extent FS. You could automate that but would be a little messy.