增加cloudformation自动缩放组的根设备尺寸 [英] Increase the root device size in cloudformation autoscaling group

查看:133
本文介绍了增加cloudformation自动缩放组的根设备尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提高我的EBS从我cloudformation自动缩放:: LaunchConfiguration支持EC2实例中的硬盘空间。最初的根设备开始8GB。我想增加至40GB。我在IM pression在此基础上<一我可以做到这一点href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-launchconfig.html#cfn-as-launchconfig-blockdevicemappings">documentation.不幸的是下面的配置似乎并没有工作。

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"}
        }]
    }
}

我使用的是自定义的AMI是基于关闭AMI-05355a6c的。

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

推荐答案

您LaunchConfiguration设置EBS卷块设备的大小。然而,文件系统仍认为它应该只使用8 GB

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

您可以在您的自定义自动执行此AMI启动命令,或者你可以传递用户数据的脚本在LaunchConfiguration来的效果:

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:

#!/bin/bash
resize2fs /dev/sda1

用户数据脚本以root身份在第一次启动运行,所以须藤是没有必要的。这里就是我介绍的用户数据脚本的概念一篇文章:<一个href="http://alestic.com/2009/06/ec2-user-data-scripts">http://alestic.com/2009/06/ec2-user-data-scripts

在一个CloudFormation模板,这可能会是这样:

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",
      ""
    ]]}}

下面是一篇文章,我解释了执行线调试的用户数据脚本的用处:<一href="http://alestic.com/2010/12/ec2-user-data-output">http://alestic.com/2010/12/ec2-user-data-output

Here's an article where I explain the usefulness of the "exec" line for debugging user-data scripts: http://alestic.com/2010/12/ec2-user-data-output

这篇关于增加cloudformation自动缩放组的根设备尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆