How to know the root device size of some public AMI?
Solution 1:
To determine the size each EBS volume associated with an AMI, use ec2-describe-images, with the image-id. Part of the output is the block device mapping, which includes the device, snapshot, and size in GB. For example, Amazon's Linux AMI (ami-e565ba8c), would result in the following:
ec2-describe-images ami-e565ba8c
IMAGE ami-e565ba8c amazon/amzn-ami-pv-2012.03.1.x86_64-ebs amazon available public x86_64 machine aki-88aa75e1 ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-dbb6e5a1 8
We can see that this AMI attached its root EBS volume (derived from snap-dbb6e5a1) to /dev/sda1 and that the size is 8GB.
Another example (a random CentOS AMI) - 6GB root device:
ec2-describe-images ami-d91dcbb0
IMAGE ami-d91dcbb0 918714796546/CentOS-6.2-vs 918714796546 available public x86_64 machine aki-8e5ea7e7 ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda snap-14226d70 6
An example from my non-default region (my default region is us-east-1) - 10GB root device:
ec2-describe-images --region us-west-1 ami-2f9bc26a
IMAGE ami-2f9bc26a 081293161529/CentOS-6.2-i386-virtastic-120215-3b 081293161529 available public i386 machine aki-87396bc2 ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda snap-a4854dc6 10
Finally, if I take one of my own AMIs which has multiple attached EBS volumes (10GB, 5GB, 3GB), the output is:
ec2-describe-images ami-xxxxxxxx
IMAGE ami-xxxxxxxx xxxxxxxxxx/MyAMIName xxxxxxxxxx available private x86_64 machine aki-407d9529 ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-xxxxxxxa 10
BLOCKDEVICEMAPPING /dev/sdh1 snap-xxxxxxxb 5
BLOCKDEVICEMAPPING /dev/sdh2 snap-xxxxxxxc 3
The same command does let you apply filters to perform some basic searching on the AMIs. See the AWS documentation for the possible filters and their usage if you are interested.
To use ec2-describe-instances, you need to setup the API tools - they can be setup on either Windows or Linux and are command line tools. --filter
is one of the parameters you pass the command, it allows you to narrow the search results by matching select criteria. Amazon details the installation of the API tools in their documentation. Note that the API tools do not need to be setup on an instance - they can run from any computer.
For instance, to get all public, EBS backed, 64-bit images, that contain 'centos' in the name:
ec2-describe-images -a --filter "name=*centos*" --filter "is-public=true" --filter "root-device-type=ebs" --filter "architecture=x86_64"
To get all public, EBS backed, 64-bit images, that contain 'centos' in the name and that have an 8, 9, or 10GB EBS volume, you can use:
ec2-describe-images -a --filter "name=*centos*" --filter "is-public=true" --filter "root-device-type=ebs" --filter "architecture=x86_64" --filter "block-device-mapping.volume-size=8" --filter "block-device-mapping.volume-size=9" --filter "block-device-mapping.volume-size=10"
IMAGE ami-10548979 021471307000/ebs-ami/hapx/centos_55_64bit 021471307000 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-3ad8b241 10
IMAGE ami-c252f6ab 097336413681/centos-55-64-ebs-120513-2.6.35-8 097336413681 available public x86_64 machine aki-88aa75e1 ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-ad4d0ed1 10
IMAGE ami-f030c799 158864314994/mesos-hypertable-centos-4 158864314994 available public x86_64 machine ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-972d4bfd 10
IMAGE ami-0c2bdc65 158864314994/mesos-hypertable-centos-6 158864314994 available public x86_64 machine ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-f31d7699 10
IMAGE ami-cc887ea5 158864314994/mesos-hypertable-centos-7 158864314994 available public x86_64 machine ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-fb1a3091 10
IMAGE ami-673af20e 180777447352/amazon-linux-centos-64-bit 180777447352 available public x86_64 machine aki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-8aac94e8 8
IMAGE ami-6c47ba05 229012137537/centos-5.6-64bit-ebs-pvgrub 229012137537 available public x86_64 machine aki-427d952b ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-1f689b70 10
IMAGE ami-3bec2e52 240054632121/centos-5.6-64-type-1 240054632121 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-a2e4efc2 10
IMAGE ami-26e1334f 276679183639/citrusleaf-2.0.23.54-trial-centos6 276679183639 available public x86_64 machine aki-4e7d9527 ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda snap-b8d619c3 8
IMAGE ami-158a427c 324077455750/centos-5-x86_64-ebs-beta2.img 324077455750 available public x86_64 machine aki-427d952b ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-811153e3 10
IMAGE ami-838a42ea 324077455750/centos-6-x86_64-ebs-beta2.img 324077455750 available public x86_64 machine aki-427d952b ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-0923616b 10
IMAGE ami-d2855ebb 352560329280/harman-centos-5.6x64 352560329280 available public x86_64 machine aki-e5c1218c ari-e3c1218a ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-82a0dfff 10
BLOCKDEVICEMAPPING /dev/sdf snap-7e9fe003 1
IMAGE ami-18ba1e71 352560329280/harman-centos-5.6x64-pvc86 352560329280 available public x86_64 machine aki-e5c1218c ari-e3c1218a ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-db89e6a7 10
BLOCKDEVICEMAPPING /dev/sdf snap-d189e6ad 1
IMAGE ami-858741ec 405596411149/centos-5.6-x86_64-pegasus-cloud-tutorial-2405596411149 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-cd3f5bac 10
IMAGE ami-e2f8248b 499412572202/centos-5.8-base-with_selinux_disabled 499412572202 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-06566b7d 10
IMAGE ami-5469913d 658020488564/centoswithnxserver 658020488564 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-98a5e7f6 10
IMAGE ami-48f90621 706600422991/centos_5_64_clean 706600422991 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-61c8560e 10
IMAGE ami-d4de25bd 707215113857/centos5-x86_64-ebs 707215113857 available public x86_64 machine aki-f006f399 ari-f406f39d ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-e076448e 10
IMAGE ami-fbd31292 752972755156/opencrowd-ideashare-centos-5.5-x64-trial-v01 752972755156 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-8ff2f4ee 10
IMAGE ami-8f8d53e6 766915741798/nagiosxi/centos/6/2.2-SNAPSHOT-1/x86_64 766915741798 available public x86_64 machine aki-427d952b ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-bb4f6bc1 10
IMAGE ami-a90fd1c0 770727804447/Instance_import_demo_centos_5.6 770727804447 available public x86_64 machine aki-427d952b ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-c7a0a7bd 10
IMAGE ami-d638cbbf 811118151095/suz-lab_ebs_centos-core-x86_64-5.5.7 811118151095 available public x86_64 machine ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-30c0115c 10
IMAGE ami-a038cbc9 811118151095/suz-lab_ebs_centos-core-x86_64-5.5.7-100g 811118151095 available public x86_64 machine ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-b615c4da 10
BLOCKDEVICEMAPPING /dev/sdb1 snap-b015c4dc 100
IMAGE ami-5a02fc33 811118151095/suz-lab_ebs_centos-core-x86_64-5.6.2 811118151095 available public x86_64 machine aki-f006f399 ari-f406f39d ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-f18e929e 10
IMAGE ami-bc649dd5 919814621061/app-apache64-centos55-1-20110609041807 919814621061 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-58e05c36 10
IMAGE ami-3f9e4856 919814621061/app64-centos5-us-east-1-20120117-20120117024004 919814621061 available public x86_64 machine aki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-8a7d1eee 10
IMAGE ami-42ee362b 919814621061/app64-centos5-us-east-1-20120413-20120413071405 919814621061 available public x86_64 machine aki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-429e103f 10
IMAGE ami-dbea33b2 919814621061/base64-centos5-us-east-1-20120405-20120405064803 919814621061 available public x86_64 machine aki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-3cb37441 10
IMAGE ami-fbfe2992 919814621061/centos-5.7-scalr/centos/5/1.0-SNAPSHOT-1/x86_64 919814621061 available public x86_64 machine aki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-b649fbd2 10
IMAGE ami-bb10c7d2 919814621061/centos-6-scalr/centos/6/1.0-SNAPSHOT-1/x86_64 919814621061 available public x86_64 machine aki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-62d85d06 10
IMAGE ami-0166b168 919814621061/memcached64-centos5-us-east-1-20120116-20120116084405 919814621061 available public x86_64 machineaki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-92a1c4f6 10
IMAGE ami-eaee3683 919814621061/memcached64-centos5-us-east-1-20120413-20120413073004 919814621061 available public x86_64 machineaki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-aaae20d7 10
IMAGE ami-f920e690 919814621061/memcached64-centos55-us-east-1-20110802084407 919814621061 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-9f4a03fe 10
IMAGE ami-0366b16a 919814621061/mongodb64-centos5-us-east-1-20120116-20120116084403 919814621061 available public x86_64 machineaki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-8aa1c4ee 10
IMAGE ami-baee36d3 919814621061/mongodb64-centos5-us-east-1-20120413-20120413074803 919814621061 available public x86_64 machineaki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-58bb3525 10
IMAGE ami-8d66b1e4 919814621061/mysql-app64-centos5-us-east-1-20120116-20120116085805 919814621061 available public x86_64 machineaki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-7eb4d11a 10
IMAGE ami-5aee3633 919814621061/mysql-app64-centos5-us-east-1-20120413-20120413071404 919814621061 available public x86_64 machineaki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-de9f11a3 10
IMAGE ami-8f66b1e6 919814621061/percona64-centos5-us-east-1-20120116-20120116085805 919814621061 available public x86_64 machineaki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-78b4d11c 10
IMAGE ami-c4778ead 919814621061/percona64-centos55-1-20110608121605 919814621061 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-bae252d4 10
IMAGE ami-fc956e95 919814621061/percona64-centos55-10-20110627103005 919814621061 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-3eae8d50 10
IMAGE ami-313cfd58 919814621061/pgsql64-centos55-us-east1-20110816100807 919814621061 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-6c06e90c 10
IMAGE ami-0f66b166 919814621061/postgresql64-centos5-us-east-1-20120116-20120116084404 919814621061 available public x86_64 machineaki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-bca1c4d8 10
IMAGE ami-e0ee3689 919814621061/postgresql64-centos5-us-east-1-20120413-20120413073205 919814621061 available public x86_64 machineaki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-24af2159 10
IMAGE ami-0d66b164 919814621061/redis64-centos5-us-east-1-20120116-20120116084404 919814621061 available public x86_64 machine aki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-b6a1c4d2 10
IMAGE ami-ecee3685 919814621061/redis64-centos5-us-east-1-20120413-20120413073004 919814621061 available public x86_64 machine aki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-7aaf2107 10
IMAGE ami-83ed2eea 919814621061/redis64-centos55-us-east-1-20110906090406 919814621061 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-4c61182c 10
IMAGE ami-34a6565d 919814621061/scalr-centos55-x64 919814621061 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-bfc2b8d2 10
IMAGE ami-bb0ac8d2 919814621061/scalr-centos55-x64-20110919 919814621061 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-ec5a468c 10
IMAGE ami-2c9e6145 919814621061/scalr-centos56-x64 919814621061 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-5dda4f32 10
IMAGE ami-c768abae 919814621061/scalr-centos60-x86_64-20110912 919814621061 available public x86_64 machine aki-4e7d9527 ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda snap-e6defe86 8
IMAGE ami-ec778385 919814621061/szr-app-apache-centos55-x86_64-ebs-1 919814621061 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-156fb17f 10
IMAGE ami-5afd1733 919814621061/szr-base-centos54-x86_64-ebs-1 919814621061 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-34c44d5f 10
IMAGE ami-1402f77d 919814621061/szr-base-centos55-x86_64-ebs-1 919814621061 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-66b78d0d 10
IMAGE ami-30ab5459 919814621061/szr-base-centos56-x86_64-ebs-1 919814621061 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-17ca4378 10
IMAGE ami-30dd2a59 919814621061/szr-lamp-centos55-x86_64-ebs-1 919814621061 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-1921bd73 10
IMAGE ami-fe0bff97 919814621061/szr-lb-nginx-centos55-x86_64-ebs-2 919814621061 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-854d92ef 10
IMAGE ami-08f21861 919814621061/szr-mysql-centos54-x86_64-ebs-1 919814621061 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-16840d7d 10
IMAGE ami-a002f7c9 919814621061/szr-mysql-centos55-x86_64-ebs-1 919814621061 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-f0a19b9b 10
IMAGE ami-399e4850 919814621061/www64-centos5-us-east-1-20120117-20120117023604 919814621061 available public x86_64 machine aki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-847b18e0 10
IMAGE ami-4eee3627 919814621061/www64-centos5-us-east-1-20120413-20120413071405 919814621061 available public x86_64 machine aki-825ea7eb ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-22810f5f 10
IMAGE ami-df77b7b6 932221497473/centos_53_x86_64-(2/6/18) 932221497473 available public x86_64 machine windows ebs hvm xen
BLOCKDEVICEMAPPING /dev/sda1 snap-160d9876 11
BLOCKDEVICEMAPPING xvdg snap-180d9878 20
BLOCKDEVICEMAPPING xvdh snap-1a0d987a 10
BLOCKDEVICEMAPPING xvdi snap-1c0d987c 5
IMAGE ami-6dd91a04 932221497473/centos_60_x86_64-(2/6/32) 932221497473 available public x86_64 machine aki-4e7d9527 ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda snap-66027306 8
BLOCKDEVICEMAPPING /dev/sdg snap-68027308 10
BLOCKDEVICEMAPPING /dev/sdh snap-6a02730a 20
IMAGE ami-a847b9c1 932665800539/cloudopt-centos-5.6-x64-ebs 932665800539 available public x86_64 machine aki-b51cf9dc ari-b31cf9da ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda1 snap-90a44afe 10
IMAGE ami-dfc302b6 944964708905/rightimage_centos_6.0_x86_64_20110810.1_ebs944964708905 available public x86_64 machine aki-4e7d9527 ebs paravirtual xen
BLOCKDEVICEMAPPING /dev/sda snap-ede1da8c 8
Note, the above command will return AMIs that have multiple EBS volumes, if any of those volumes meet the criteria. You can always further filter your results using grep
, should you desire.
As always, don't run AMIs from unknown sources. If you want a CentOS AMI, I would actually suggest sticking with Amazon's Linux. It is based on CentOS/RHEL (fully compatible with the binaries from EPEL), well maintained (packages are updated regularly, the current versions of many popular packages are available), is the officially supported AMI of EC2, and is very lightweight (comes with the bare minimum to start with - doesn't take too much space, uses little memory).
Solution 2:
Sloppy method to find details of all 8GB images
ec2-describe-images --all -v > ~/output.txt
cat ~/output.txt | grep -B 18 '<volumeSize>8</volumeSize>'
sample output in east region
<imageId>ami-005daf69</imageId>
<imageLocation>amazon/ElasticBeanstalk-Tomcat6-64bit-20110322-2041</imageLocation>
<imageState>available</imageState>
<imageOwnerId>102837901569</imageOwnerId>
<isPublic>true</isPublic>
<architecture>x86_64</architecture>
<imageType>machine</imageType>
<kernelId>aki-427d952b</kernelId>
<imageOwnerAlias>amazon</imageOwnerAlias>
<name>ElasticBeanstalk-Tomcat6-64bit-20110322-2041</name>
<description>Elastic Beanstalk Tomcat 6 64-bit</description>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName>/dev/sda1</rootDeviceName>
<blockDeviceMapping>
<item>
<deviceName>/dev/sda1</deviceName>
<ebs>
<snapshotId>snap-4bd68427</snapshotId>
<volumeSize>8</volumeSize>
<item>
<imageId>ami-00a97b69</imageId>
<imageLocation>031458542082/TarCloud Client 0.1</imageLocation>
<imageState>available</imageState>
<imageOwnerId>031458542082</imageOwnerId>
<isPublic>true</isPublic>
<architecture>i386</architecture>
<imageType>machine</imageType>
<kernelId>aki-805ea7e9</kernelId>
<name>TarCloud Client 0.1</name>
<description>TarCloud Client 0.1</description>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName>/dev/sda1</rootDeviceName>
<blockDeviceMapping>
<item>
<deviceName>/dev/sda1</deviceName>
<ebs>
<snapshotId>snap-9a946ae1</snapshotId>
<volumeSize>8</volumeSize>
Solution 3:
You have to install the AWS tools. The official one is here:
http://aws.amazon.com/developertools/351
If you install them as per the instructions you'll have a command line interface that will allow you to control the instance(s) from your local command line.