Increase the root device size in cloudformation autoscaling group

I am trying to increase the hard disk space on my ebs backed ec2 instance from my cloudformation AutoScaling::LaunchConfiguration. Initially the root device starts with 8GB. I'd like to increase this to 40GB. I am under the impression I can do this based on this documentation. Unfortunately the config below doesn't seem to work.

"LaunchConfig" : {
    "Type": "AWS::AutoScaling::LaunchConfiguration",
    "Properties": {
        "BlockDeviceMappings": [{
            "DeviceName": "/dev/sda1",
            "Ebs" : {"VolumeSize": "40"}

I am using a custom ami that is based off of ami-05355a6c.

Answers 1

  • Your LaunchConfiguration sets the size of the EBS volume block device. However, the file system still thinks that it should only be using 8 GB.

    You can run a command like the following to tell the file system it should use up the entire block device:

    sudo resize2fs /dev/sda1

    You could automate this in your custom AMI startup commands, or you could pass in a user-data script in your LaunchConfiguration to the effect of:

    resize2fs /dev/sda1

    user-data scripts are run as root on on first boot, so the sudo is not necessary. Here's an article where I introduced the concept of user-data scripts:

    In a CloudFormation template, this might look something like:

        "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
          "#!/bin/bash -ex\n",
          "exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1\n",
          "resize2fs /dev/sda1\n",

    Here's an article where I explain the usefulness of the "exec" line for debugging user-data scripts:

Related Articles