【问题标题】:AWS::EC2::Instance refuses to boot. Mounting the wrong drive as root?AWS::EC2::Instance 拒绝启动。以root身份安装错误的驱动器?
【发布时间】:2017-01-29 23:11:07
【问题描述】:

我正在尝试配置一些需要多个 EBS 驱动器的 EC2 实例。我正在尝试通过 BlockDeviceMappings 定义根卷和 4 个其他卷。

问题: 据我所知,下面的代码符合我在网上看到的任何示例。但是当 Windows 启动时,它会立即死掉。查看 EC2 控制台 (screenshot),我可以看到该实例附加了 7 个 EBS 卷(而不是 5 个),并且 /dev/xda 设置为 root 而不是 /dev/sda1。

  "Mappings" : {
    "AWSRegionToAMI" : {
      "us-east-1"      : { "Windows2012R2" : "ami-5d1b984a" },
      "us-west-1"      : { "Windows2012R2" : "ami-07713767" },
      "us-west-2"      : { "Windows2012R2" : "ami-241bd844" }
    },
    "VolumeSize" : {
      "DataDrive"      : { "Size" : "50" },
      "LogDrive"       : { "Size" : "50" },
      "TempDrive"      : { "Size" : "400" },
      "BackupDrive"    : { "Size" : "100" }
    },
    "stackmap" : {
      "sqlha" : {
        "Name": "MS SQL Server 2014 Always On",
        "chefjson" : "https://s3.amazonaws.com/[redacted]",
        "os" : "win",
        "bootstrapurl" : "https://s3.amazonaws.com/[redacted]"
      }
    }
  },

"WSFCNode1": {
  "Type": "AWS::EC2::Instance",
  "Properties": {
    "ImageId" : { "Fn::FindInMap" : [ "AWSRegionToAMI", { "Ref" : "AWS::Region" }, "Windows2012R2" ] },
    "InstanceType": { "Ref": "InstanceType" },
    "EbsOptimized": "true",
    "NetworkInterfaces": [
      {
        "DeleteOnTermination": "true",
        "DeviceIndex": 0,
        "SubnetId": { "Ref": "PrivateSubnet1ID" },
        "SecondaryPrivateIpAddressCount": 2,
        "GroupSet": [
            { "Ref": "WSFCSecurityGroup" },
            { "Ref": "WSFCClientSecurityGroup" }
        ]
      }
    ],
    "BlockDeviceMappings": [
      {
        "DeviceName": "/dev/sda1",
        "Ebs" : {"VolumeSize": "60"}
      },
      {
        "DeviceName": "/dev/xvdb",
        "Ebs" : {"VolumeSize": { "Fn::FindInMap" : [ "VolumeSize", "DataDrive", "Size" ]} }
      },
      {
        "DeviceName": "/dev/xvdc",
        "Ebs" : {"VolumeSize": { "Fn::FindInMap" : [ "VolumeSize", "LogDrive", "Size" ]} }
      },
      {
        "DeviceName": "/dev/xvdd",
        "Ebs" : {"VolumeSize": { "Fn::FindInMap" : [ "VolumeSize", "TempDrive", "Size" ]} }
      },
      {
        "DeviceName": "/dev/xvde",
        "Ebs" : {"VolumeSize": { "Fn::FindInMap" : [ "VolumeSize", "BackupDrive", "Size" ]} }
      }
    ],
    "KeyName": { "Ref": "KeyPairName" },
    "UserData"       : { "Fn::Base64" : { "Fn::Join" : ["", [
      "<powershell>\n",

      "# Disable UAC and allow scripts to run\n",
      "New-ItemProperty -Path HKLM:Software\\Microsoft\\Windows\\CurrentVersion\\policies\\system -Name EnableLUA -PropertyType DWord -Value 0 -Force\n",
      "Set-ExecutionPolicy Unrestricted -force\n",
      "c:\\windows\\System32\\WindowsPowershell\\v1.0\\powershell.exe -noninteractive -noprofile Set-ExecutionPolicy unrestricted -force\n",
      "c:\\windows\\syswow64\\windowspowershell\\v1.0\\powershell.exe -noninteractive -noprofile Set-ExecutionPolicy unrestricted -force\n",

      "#Change TimeZone\n",
      "tzutil /s ", {"Ref" : "Timezone"}, "\n",

      "#Run Bootstrap PS1\n",
      "$newname = '", { "Fn::Join" : ["", [{"Ref" : "Environment"}, {"Ref" : "Location"}, {"Ref" : "Stack"}, {"Ref" : "Role"} ]]},"'\n",
      "$region = '", {"Ref" : "VPCRegion"}, "'\n",
      "$role = '", {"Ref" : "Role"}, "'\n",
      "$chef_rb = '", { "Fn::FindInMap" : [ "stackmap", { "Ref" : "Role" }, "chefjson"]}, "'\n",
      "mkdir 'c:\\temp' -force\n",
      "(new-object System.Net.WebClient).DownloadFile( 'https://s3.amazonaws.com/[redacted]', 'c:\\temp\\bootstrap.ps1')\n",
      "powershell c:\\temp\\bootstrap.ps1 -newname $newname -region $region -role $role -chef_rb $chef_rb -logfile c:\\temp\\bootstrap.log -verbose true\n",

      "#Reboot if needed\n",
      "Start-Sleep -s 10\n",
      "Restart-Computer\n",
      "mkdir 'c:\\temp\\cf_reboot_cmd_ran' -force\n",
      "shutdown -r\n",
      "mkdir 'c:\\temp\\cf_shut_cmd_ran' -force\n",
      "Start-Sleep -s 10\n",
      "mkdir 'c:\\temp\\cf_ran_again' -force\n",

      "</powershell>"
      ] ] } 
    },
    "Tags": [
        { "Key": "Name", "Value": "SQL Node 1" }
    ]
  }
},

令人困惑的是,即使我删除了所有额外的驱动器并只对一个磁盘进行块设备映射

    "BlockDeviceMappings": [
      {
        "DeviceName": "/dev/sda1",
        "Ebs" : {"VolumeSize": "60"}
      }
    ],

...我最终还是得到了三个卷,并且错误的一个 (/dev/xda) 被分配为 root。 Screenshot

这是 Windows 的事情吗?我的块设备映射需要什么样的外观才能以 root(或 C:,在这种情况下)正确挂载?

【问题讨论】:

    标签: amazon-ec2 amazon-cloudformation


    【解决方案1】:

    没关系。根本问题出在我选择的 AMI 中。一旦我选择了合适的 Windows AMI,一切都运行良好。

    对于遇到此问题的其他人,请仔细检查您的 AMI 选择。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-15
      • 2012-02-25
      • 2013-11-23
      • 2013-10-14
      • 2018-04-09
      • 1970-01-01
      相关资源
      最近更新 更多