private key:
PROMPT> ssh -i id_rsa-gsg-keypair root@domU-
root@my-instance #
Otherwise, use the plain ssh command and supply the appropriate password when prompted.
root@my-instance #
You now have complete control over the instance and may add, remove, modify or upgrade packages
and files to suit your needs. Some of the basic configuration settings related to the Amazon EC2
enviroment, such as the network interface configuration and /etc/fstab contents, should only be
changed with extreme care, to avoid making the AMI unbootable or inaccessible from the network once
Upload the Key and Certificate
The new AMI will be encrypted and signed to ensure that it can only be accessed by you and
Amazon EC2. You therefore need to upload your Amazon EC2 private key and X.509 certificate to the
running instance, for use in the AMI bundling process.
Assuming the private key and X.509 certificate are contained in files
cert-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem, copy both of these files to your instance:
100% 685 0.7KB/s 00:00
It is important that the key and cert files are uploaded into /tmp to prevent them being bundled
with the new AMI.
You are now ready to proceed to the next step which involves bundling the volume and uploading the
resulting AMI to Amazon S3. This is described in the section called “Bundling an AMI” .
Creating via a Loopback File
This method entails doing a full operating system installation on a clean root file system, but avoids
having to create a new root disk partition and file system on a physical disk. Once you have installed
your operating system, the resulting image can be bundled as an AMI with the ec2-bundle-image
Create a File to Host the AMI
The dd utility can be used to create files of arbitrary sizes. In this case, make sure to create a file large
enough to host the operating system, tools and applications that you will install. For example, a baseline
Linux installation requires about 700MB, so your file should be at least 1GB. The command below
creates a file of 1024*1MB=1GB.
# dd if=/dev/zero of=my-image.fs bs=1M count=1024
1024+0 records in
1024+0 records out
Amazon EC2
Developer Guide
Create a Root File System Inside the File
There are several variations on the generic mkfs utility that can be used to create a file system inside
my-image.fs. Typical Linux installations default to ext2 or ext3 file systems. Create an ext3 file
system by issuing the following command:
# mke2fs -F -j my-image.fs
mke2fs 1.38 (30-Jun-2005)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
131072 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Mount the File via Loopback
The loopback module allows you to use a normal file as if it were a raw device. In this manner you get a
file-system in a file. Mounting a file system image file via loopback presents it as part of the normal file
system. You can then modify it using your favourite file management tools and utilities. Create a mount
point in the file system where the image will be attached and then mount the file system image, as
# mkdir /mnt/ec2-fs
# mount -o loop my-image.fs /mnt/ec2-fs
Prepare for the Installation
Before the operating system installation can proceed, some basic files have to be created and prepared
on the newly created root file system.
Create /dev
Create a /dev directory and populate it with a minimal set of devices (you can ignore the errors in the
# mkdir /mnt/ec2-fs/dev
# /sbin/MAKEDEV -d /mnt/ec2-fs/dev -x console
MAKEDEV: mkdir: File exists
MAKEDEV: mkdir: File exists
MAKEDEV: mkdir: File exists
# /sbin/MAKEDEV -d /mnt/ec2-fs/dev -x null
MAKEDEV: mkdir: File exists
MAKEDEV: mkdir: File exists
MAKEDEV: mkdir: File exists
# /sbin/MAKEDEV -d /mnt/ec2-fs/dev -x zero
MAKEDEV: mkdir: File exists
Amazon EC2
Developer Guide
Previous Page Next Page