[英]AWS EC2 - Attach Larger Volume with run-instances
I'm having difficulty launching an EC2 instance and increasing the size of the root partition in a single command with aws ec2 run-instances
: 我在使用aws ec2 run-instances
在单个命令中启动EC2实例并增加根分区的大小时遇到困难:
aws ec2 run-instances \
--image-id ami-0b33d91d \
--count 1 \
--instance-type m3.2xlarge \
--key-name my_key \
--security-group-ids "sg-xxxxxxx" \
--ebs-optimized \
--block-device-mapping "[ { \"DeviceName\": \"/dev/sda1\", \"Ebs\": { \"VolumeSize\": 120 } } ]"
The instance launches, and I can see the new 120GB volume listed (though not as root) in the console, but then the instance immediately stops (not terminates). 实例启动,我可以看到控制台中列出了新的120GB卷(虽然不是root用户),但实例立即停止(不终止)。 I've tried renaming the DeviceName property per these conventions , This is a temporary instance that I'm going to launch, do stuff, then terminate. 我已经尝试按照这些约定重命名DeviceName属性,这是一个临时实例,我将要启动,执行操作,然后终止。 Maybe I need to run create-volume
first and then attach it with a separate series of commands? 也许我需要首先运行create-volume
然后用一系列单独的命令附加它? The AWS documentation seems to be all over the place on this and I can't find a clear explanation, though I've come across a few links here and here . 虽然我在这里和这里遇到了一些链接,但AWS文档似乎已经到处都是,我无法找到明确的解释。 This SO question suggests resizing the partition but I'm not sure if that's what I need to do. 这个问题建议调整分区大小,但我不确定这是否是我需要做的。 As far as I can tell, the m3.2xlarge
instance type has EBS available. 据我所知, m3.2xlarge
实例类型有EBS可用。 Am I naming the partition incorrectly? 我错误地命名分区了吗? Is something in this configuration causing the stoppage of the instance? 此配置中的某些内容是否导致实例停止?
EDIT 编辑
After the instance stops itself, I get the follow as part of the response to describe-instances
: 在实例停止后,我将以下内容作为对describe-instances
的响应的一部分:
"BlockDeviceMappings": [
{
"DeviceName": "/dev/xvda",
"Ebs": {
"Status": "attached",
"DeleteOnTermination": true,
"VolumeId": "vol-xxxx",
"AttachTime": "2017-03-05T00:57:23.000Z"
}
},
{
"DeviceName": "/dev/sda1",
"Ebs": {
"Status": "attached",
"DeleteOnTermination": true,
"VolumeId": "vol-xxxx",
"AttachTime": "2017-03-05T00:57:23.000Z"
}
}
],
"Architecture": "x86_64",
"StateReason": {
"Message": "Client.InstanceInitiatedShutdown: Instance initiated shutdown",
"Code": "Client.InstanceInitiatedShutdown"
},
"RootDeviceName": "/dev/xvda",
"VirtualizationType": "hvm",
"AmiLaunchIndex": 0
I think you're running into the same problem that this SO question is having: 我认为你遇到了这个问题所面临的同样问题:
https://serverfault.com/questions/615188/aws-t1-to-t2-migration-client-instanceinitiatedshutdown-on-new-t2-instance https://serverfault.com/questions/615188/aws-t1-to-t2-migration-client-instanceinitiatedshutdown-on-new-t2-instance
Your instance is an HVM instance and wants to use /dev/xvda
as the root device. 您的实例是HVM实例,并希望使用/dev/xvda
作为根设备。 However, you're specifying /dev/sda1
. 但是,您正在指定/dev/sda1
。 This is (a) creating a secondary volume instead, but then (b) preventing the instance from launching because that's a PV-related device rather than HVM. 这是(a)创建一个辅助卷,但随后(b)阻止实例启动,因为这是一个PV相关设备而不是HVM。
So, as a solution, use /dev/xvda
as the device name instead. 因此,作为解决方案,请使用/dev/xvda
作为设备名称。 Like the following command line: 像以下命令行一样:
aws ec2 run-instances \
--image-id ami-0b33d91d \
--count 1 \
--instance-type m3.2xlarge \
--key-name my_key \
--security-group-ids "sg-xxxxxxx" \
--ebs-optimized \
--block-device-mapping "[ { \"DeviceName\": \"/dev/xvda\", \"Ebs\": { \"VolumeSize\": 120 } } ]"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.