【问题标题】:Cloud Formation EBS mount issueCloud Formation EBS 挂载问题
【发布时间】:2018-10-21 21:39:54
【问题描述】:

我正在尝试在创建 ec2 期间安装多个卷。 CF 没有抱怨 yaml,堆栈没有错误地完成,实例被创建,设备通过“lsblk”显示,但没有安装发生。以下是精简后的 yaml:

对于本练习,我只是尝试安装一个,然后继续为其余部分编写 yaml。

AWSTemplateFormatVersion: '2010-09-09'
Description: "adding instances"
Resources:
Instance01:
Type: AWS::EC2::Instance
Properties:
SubnetId: subnet-xxxxxx
KeyName: 'awesome'
ImageId: ami-xxxxxxx
InstanceType: m5.2xlarge
SecurityGroupIds:
- sg-xxxxxx
- sg-xxxxxx
- sg-xxxxxx
IamInstanceProfile: 'MyRole'
Tags:
- Key: Name
Value: 'awesometag'
BlockDeviceMappings:
- DeviceName: '/dev/xvdb'
Ebs:
VolumeSize: 50
VolumeType: gp2
- DeviceName: '/dev/xvdc'
Ebs:
VolumeSize: 80
VolumeType: gp2
- DeviceName: '/dev/xvdd'
Ebs:
VolumeSize: 50
VolumeType: gp2
- DeviceName: '/dev/xvde'
Ebs:
VolumeSize: 50
VolumeType: gp2
- DeviceName: '/dev/xvdf'
Ebs:
VolumeSize: 50
VolumeType: gp2
- DeviceName: '/dev/xvdg'
Ebs:
VolumeSize: 50
VolumeType: gp2
UserData:
Fn::Base64:
!Sub |
#!/bin/bash -xe
mkfs -t ext4 /dev/xvdc
sleep 5
mkdir -p /mypartition
mount /dev/xvdc /mypartition 
echo "/dev/xvdc /mypartition ext4 defaults,noatime 0 0" >> /etc/fstab
mount -a

(显然 yaml 间距不正确,但这是复制/粘贴问题:)

就像我说的;实例已创建,但 df -h 不显示 /mypartition 并且 /etc/fstab 没有条目。

谢谢!

【问题讨论】:

  • 用户数据脚本的输出显示了什么?
  • 您是否创建了目录“/mypartition”?

标签: amazon-ec2 yaml amazon-cloudformation


【解决方案1】:

mount /dev/xvdc /mypartition 可能导致错误,阻止脚本进一步运行。尝试删除它,因为您在末尾已经有 mount -a

【讨论】:

    【解决方案2】:

    感谢所有输入!原来这是我使用的 ami。

    【讨论】:

      猜你喜欢
      • 2016-12-26
      • 2012-12-12
      • 2016-02-16
      • 2021-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-21
      • 2018-03-09
      相关资源
      最近更新 更多