使用云形成在linux-Ec2实例中自动挂载ebs卷?

前端之家收集整理的这篇文章主要介绍了使用云形成在linux-Ec2实例中自动挂载ebs卷?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
写了一个CFT来创建附加了两个ebs卷的redhat实例.并且需要自动挂载或格式化来自cft本身的ebs卷.

CFT:

"BlockDeviceMappings": [
    {
        "DeviceName": "/dev/sda1","Ebs": {
            "DeleteOnTermination": "true","VolumeSize": "150","VolumeType": "standard"
        }
    },{
        "DeviceName": "/dev/sdm","VolumeSize": "1000","VolumeType": "standard"
        }
    }
]

需要自动挂载“DeviceName”:“/ dev / sdm”,此卷.

解决方法

您需要向实例的UserData属性添加一个小脚本,或者启动与此BlockDeviceMappings关联的配置. UserData在实例第一次引导时执行.使用/ etc / fstab重新启动实例时,将自动重新装入设备.
"UserData" : { "Fn::Base64" : { "Fn::Join" : [ "",[
      "#!/bin/bash -v\n","mkfs -t ext4 /dev/xvdm\n","mkfs -t ext4 /dev/xvda1\n","mkdir /opt/mount1 /opt/mount2\n","mount /dev/xvdm /opt/mount1\n","mount /dev/xvda1 /opt/mount2\n","echo \"/dev/xvdm /opt/mount1 ext4 defaults,nofail 0 2\" >> /etc/fstab\n"
      "echo \"/dev/xvda1 /opt/mount2 ext4 defaults,nofail 0 2\" >> /etc/fstab\n"
    ]]}}

更多信息:http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html

原文链接:https://www.f2er.com/linux/393118.html

猜你在找的Linux相关文章