How to launch ec2 instance with custom root volume ebs size (more than 8GB) using AWS Cli
I m trying to launch an ec2 instance using aws cli but by default root volume is 8Gb only. how can I launch ec2 instance using CLI with say 100GB of root volume?
I m trying this command,
aws ec2 run-instances --image-id ami-xxxxx --count 1 --instance-type t2.micro
--subnet-id xxxxxxx
--key-name my-key
--security-group-ids sg-xxxxxx
--no-associate-public-ip-address
--user-data file://test.sh
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=test-server}]'
I tried adding below parameters, but its not working.
--block-device-mapping DeviceName=/dev/sda1,Ebs={VolumeSize=100}
--block-device-mapping /dev/sda1=:100:false
--block-device-mappings --> adds secondary ebs volume to the instance.
amazon-web-services amazon-ec2 aws-ebs
add a comment |
I m trying to launch an ec2 instance using aws cli but by default root volume is 8Gb only. how can I launch ec2 instance using CLI with say 100GB of root volume?
I m trying this command,
aws ec2 run-instances --image-id ami-xxxxx --count 1 --instance-type t2.micro
--subnet-id xxxxxxx
--key-name my-key
--security-group-ids sg-xxxxxx
--no-associate-public-ip-address
--user-data file://test.sh
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=test-server}]'
I tried adding below parameters, but its not working.
--block-device-mapping DeviceName=/dev/sda1,Ebs={VolumeSize=100}
--block-device-mapping /dev/sda1=:100:false
--block-device-mappings --> adds secondary ebs volume to the instance.
amazon-web-services amazon-ec2 aws-ebs
Is there some error you are getting? Also, why are you trying to specify the volume size in two different ways? This :--block-device-mapping /dev/sda1=:100:false
is deprecated syntax, you should be fine with just using--block-device-mapping DeviceName=/dev/sda1,Ebs={VolumeSize=100}
– AlexK
Nov 19 '18 at 9:09
add a comment |
I m trying to launch an ec2 instance using aws cli but by default root volume is 8Gb only. how can I launch ec2 instance using CLI with say 100GB of root volume?
I m trying this command,
aws ec2 run-instances --image-id ami-xxxxx --count 1 --instance-type t2.micro
--subnet-id xxxxxxx
--key-name my-key
--security-group-ids sg-xxxxxx
--no-associate-public-ip-address
--user-data file://test.sh
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=test-server}]'
I tried adding below parameters, but its not working.
--block-device-mapping DeviceName=/dev/sda1,Ebs={VolumeSize=100}
--block-device-mapping /dev/sda1=:100:false
--block-device-mappings --> adds secondary ebs volume to the instance.
amazon-web-services amazon-ec2 aws-ebs
I m trying to launch an ec2 instance using aws cli but by default root volume is 8Gb only. how can I launch ec2 instance using CLI with say 100GB of root volume?
I m trying this command,
aws ec2 run-instances --image-id ami-xxxxx --count 1 --instance-type t2.micro
--subnet-id xxxxxxx
--key-name my-key
--security-group-ids sg-xxxxxx
--no-associate-public-ip-address
--user-data file://test.sh
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=test-server}]'
I tried adding below parameters, but its not working.
--block-device-mapping DeviceName=/dev/sda1,Ebs={VolumeSize=100}
--block-device-mapping /dev/sda1=:100:false
--block-device-mappings --> adds secondary ebs volume to the instance.
amazon-web-services amazon-ec2 aws-ebs
amazon-web-services amazon-ec2 aws-ebs
asked Nov 19 '18 at 6:15
DivyDivy
61
61
Is there some error you are getting? Also, why are you trying to specify the volume size in two different ways? This :--block-device-mapping /dev/sda1=:100:false
is deprecated syntax, you should be fine with just using--block-device-mapping DeviceName=/dev/sda1,Ebs={VolumeSize=100}
– AlexK
Nov 19 '18 at 9:09
add a comment |
Is there some error you are getting? Also, why are you trying to specify the volume size in two different ways? This :--block-device-mapping /dev/sda1=:100:false
is deprecated syntax, you should be fine with just using--block-device-mapping DeviceName=/dev/sda1,Ebs={VolumeSize=100}
– AlexK
Nov 19 '18 at 9:09
Is there some error you are getting? Also, why are you trying to specify the volume size in two different ways? This :
--block-device-mapping /dev/sda1=:100:false
is deprecated syntax, you should be fine with just using --block-device-mapping DeviceName=/dev/sda1,Ebs={VolumeSize=100}
– AlexK
Nov 19 '18 at 9:09
Is there some error you are getting? Also, why are you trying to specify the volume size in two different ways? This :
--block-device-mapping /dev/sda1=:100:false
is deprecated syntax, you should be fine with just using --block-device-mapping DeviceName=/dev/sda1,Ebs={VolumeSize=100}
– AlexK
Nov 19 '18 at 9:09
add a comment |
1 Answer
1
active
oldest
votes
This is covered in the AWS CLI Documentation here:
https://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html
To launch an instance with a modified block device mapping
You can change individual characteristics of existing AMI block device mappings to suit your needs. Perhaps you want to use an existing AMI, but you want a larger root volume than the usual 8 GiB. Or, you would like to use a General Purpose (SSD) volume for an AMI that currently uses a Magnetic volume.
Use the describe-images command with the image ID of the AMI you want to use to find its existing block device mapping. You should see a block device mapping in the output:
{
"DeviceName": "/dev/sda1",
"Ebs": {
"DeleteOnTermination": true,
"SnapshotId": "snap-1234567890abcdef0",
"VolumeSize": 8,
"VolumeType": "standard",
"Encrypted": false
}
}
You can modify the above mapping by changing the individual parameters. For example, to launch an instance with a modified block device mapping, add the following parameter to your run-instances command to change the above mapping's volume size and type:
--block-device-mappings file://mapping.json
Where mapping.json contains the following:
[
{
"DeviceName": "/dev/sda1",
"Ebs": {
"DeleteOnTermination": true,
"SnapshotId": "snap-1234567890abcdef0",
"VolumeSize": 100,
"VolumeType": "gp2"
}
}
]
To do this on one command line, the command should be in the format:
aws ec2 run-instances --block-device-mapping DeviceName=/dev/xvda,Ebs={VolumeSize=100} --image-id ami-0a5e707736615003c --region eu-west-1 --instance-type t3.micro
Note that the device name needs to match the root device name, which you can find with a command in the format:
aws ec2 describe-images --image-id ami-0a5e707736615003c --region eu-west-1
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53369224%2fhow-to-launch-ec2-instance-with-custom-root-volume-ebs-size-more-than-8gb-usin%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is covered in the AWS CLI Documentation here:
https://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html
To launch an instance with a modified block device mapping
You can change individual characteristics of existing AMI block device mappings to suit your needs. Perhaps you want to use an existing AMI, but you want a larger root volume than the usual 8 GiB. Or, you would like to use a General Purpose (SSD) volume for an AMI that currently uses a Magnetic volume.
Use the describe-images command with the image ID of the AMI you want to use to find its existing block device mapping. You should see a block device mapping in the output:
{
"DeviceName": "/dev/sda1",
"Ebs": {
"DeleteOnTermination": true,
"SnapshotId": "snap-1234567890abcdef0",
"VolumeSize": 8,
"VolumeType": "standard",
"Encrypted": false
}
}
You can modify the above mapping by changing the individual parameters. For example, to launch an instance with a modified block device mapping, add the following parameter to your run-instances command to change the above mapping's volume size and type:
--block-device-mappings file://mapping.json
Where mapping.json contains the following:
[
{
"DeviceName": "/dev/sda1",
"Ebs": {
"DeleteOnTermination": true,
"SnapshotId": "snap-1234567890abcdef0",
"VolumeSize": 100,
"VolumeType": "gp2"
}
}
]
To do this on one command line, the command should be in the format:
aws ec2 run-instances --block-device-mapping DeviceName=/dev/xvda,Ebs={VolumeSize=100} --image-id ami-0a5e707736615003c --region eu-west-1 --instance-type t3.micro
Note that the device name needs to match the root device name, which you can find with a command in the format:
aws ec2 describe-images --image-id ami-0a5e707736615003c --region eu-west-1
add a comment |
This is covered in the AWS CLI Documentation here:
https://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html
To launch an instance with a modified block device mapping
You can change individual characteristics of existing AMI block device mappings to suit your needs. Perhaps you want to use an existing AMI, but you want a larger root volume than the usual 8 GiB. Or, you would like to use a General Purpose (SSD) volume for an AMI that currently uses a Magnetic volume.
Use the describe-images command with the image ID of the AMI you want to use to find its existing block device mapping. You should see a block device mapping in the output:
{
"DeviceName": "/dev/sda1",
"Ebs": {
"DeleteOnTermination": true,
"SnapshotId": "snap-1234567890abcdef0",
"VolumeSize": 8,
"VolumeType": "standard",
"Encrypted": false
}
}
You can modify the above mapping by changing the individual parameters. For example, to launch an instance with a modified block device mapping, add the following parameter to your run-instances command to change the above mapping's volume size and type:
--block-device-mappings file://mapping.json
Where mapping.json contains the following:
[
{
"DeviceName": "/dev/sda1",
"Ebs": {
"DeleteOnTermination": true,
"SnapshotId": "snap-1234567890abcdef0",
"VolumeSize": 100,
"VolumeType": "gp2"
}
}
]
To do this on one command line, the command should be in the format:
aws ec2 run-instances --block-device-mapping DeviceName=/dev/xvda,Ebs={VolumeSize=100} --image-id ami-0a5e707736615003c --region eu-west-1 --instance-type t3.micro
Note that the device name needs to match the root device name, which you can find with a command in the format:
aws ec2 describe-images --image-id ami-0a5e707736615003c --region eu-west-1
add a comment |
This is covered in the AWS CLI Documentation here:
https://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html
To launch an instance with a modified block device mapping
You can change individual characteristics of existing AMI block device mappings to suit your needs. Perhaps you want to use an existing AMI, but you want a larger root volume than the usual 8 GiB. Or, you would like to use a General Purpose (SSD) volume for an AMI that currently uses a Magnetic volume.
Use the describe-images command with the image ID of the AMI you want to use to find its existing block device mapping. You should see a block device mapping in the output:
{
"DeviceName": "/dev/sda1",
"Ebs": {
"DeleteOnTermination": true,
"SnapshotId": "snap-1234567890abcdef0",
"VolumeSize": 8,
"VolumeType": "standard",
"Encrypted": false
}
}
You can modify the above mapping by changing the individual parameters. For example, to launch an instance with a modified block device mapping, add the following parameter to your run-instances command to change the above mapping's volume size and type:
--block-device-mappings file://mapping.json
Where mapping.json contains the following:
[
{
"DeviceName": "/dev/sda1",
"Ebs": {
"DeleteOnTermination": true,
"SnapshotId": "snap-1234567890abcdef0",
"VolumeSize": 100,
"VolumeType": "gp2"
}
}
]
To do this on one command line, the command should be in the format:
aws ec2 run-instances --block-device-mapping DeviceName=/dev/xvda,Ebs={VolumeSize=100} --image-id ami-0a5e707736615003c --region eu-west-1 --instance-type t3.micro
Note that the device name needs to match the root device name, which you can find with a command in the format:
aws ec2 describe-images --image-id ami-0a5e707736615003c --region eu-west-1
This is covered in the AWS CLI Documentation here:
https://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html
To launch an instance with a modified block device mapping
You can change individual characteristics of existing AMI block device mappings to suit your needs. Perhaps you want to use an existing AMI, but you want a larger root volume than the usual 8 GiB. Or, you would like to use a General Purpose (SSD) volume for an AMI that currently uses a Magnetic volume.
Use the describe-images command with the image ID of the AMI you want to use to find its existing block device mapping. You should see a block device mapping in the output:
{
"DeviceName": "/dev/sda1",
"Ebs": {
"DeleteOnTermination": true,
"SnapshotId": "snap-1234567890abcdef0",
"VolumeSize": 8,
"VolumeType": "standard",
"Encrypted": false
}
}
You can modify the above mapping by changing the individual parameters. For example, to launch an instance with a modified block device mapping, add the following parameter to your run-instances command to change the above mapping's volume size and type:
--block-device-mappings file://mapping.json
Where mapping.json contains the following:
[
{
"DeviceName": "/dev/sda1",
"Ebs": {
"DeleteOnTermination": true,
"SnapshotId": "snap-1234567890abcdef0",
"VolumeSize": 100,
"VolumeType": "gp2"
}
}
]
To do this on one command line, the command should be in the format:
aws ec2 run-instances --block-device-mapping DeviceName=/dev/xvda,Ebs={VolumeSize=100} --image-id ami-0a5e707736615003c --region eu-west-1 --instance-type t3.micro
Note that the device name needs to match the root device name, which you can find with a command in the format:
aws ec2 describe-images --image-id ami-0a5e707736615003c --region eu-west-1
edited Nov 19 '18 at 11:48
answered Nov 19 '18 at 11:34
Ian MassinghamIan Massingham
613
613
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53369224%2fhow-to-launch-ec2-instance-with-custom-root-volume-ebs-size-more-than-8gb-usin%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Is there some error you are getting? Also, why are you trying to specify the volume size in two different ways? This :
--block-device-mapping /dev/sda1=:100:false
is deprecated syntax, you should be fine with just using--block-device-mapping DeviceName=/dev/sda1,Ebs={VolumeSize=100}
– AlexK
Nov 19 '18 at 9:09