Amazon Elastic Compute Cloud
CLI Reference (API Version 2011-12-15)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

ec2-bundle-vol

Description

Creates a bundled AMI by compressing, encrypting and signing a snapshot of the local machine's root file system.

To use ec2-bundle-vol, first you must install the AMI tools on the instance you are bundling, then run ec2-bundle-vol on that instance, not on a local system. For information about getting the AMI tools, go to Amazon EC2 AMI Tools.

[Note]Note

Scripts that require a copy of the public key from the launch key pair must obtain the key from the instance's metadata (not the key file in the instance store) for instances bundled with the 2007-08-29 AMI tools and later. AMIs bundled before this release will continue to work normally.

On a running instance, Amazon EC2 attempts to inherit product codes, kernel settings, RAM disk settings, and block device mappings with which the instance launched.

Syntax

ec2-bundle-vol -k private_key -u user_id -c cert -r architecture [-s size] [-d destination] [-e exclude_directory_1,exclude_directory_1,...] [-p ami_prefix] [-v volume] [--ec2cert cert_path] [--fstab fstab_path] [--generate-fstab] [--kernel kernel-id] [--ramdisk ramdisk_id] [--block-device-mapping block_device_mapping] [--[no-]inherit] [--productcodes product_code]

Options

OptionDescriptionRequired

-k, --privatekey private_key

The path to the user's PEM-encoded RSA key file.

Example: -k pk-HKZYKTAIG2ECMXYIBH3HXV4ZBEXAMPLE.pem

Yes

-u, --user user_id

The user's AWS account ID without dashes. Do not use the Access Key ID.

Example: -u 111122223333

Yes

-c, --cert cert

The user's PEM encoded RSA public key certificate file.

Example: -c cert-HKZYKTAIG2ECMXYIBH3HXV4ZBEXAMPLE.pem

Yes

-r, --arch architecture

Image architecture. If you don't provide this on the command line, you'll be prompted to provide it when the bundling starts.

Valid Values: i386 | x86_64

Example: -r x86_64

Yes

-s, --size size

The size, in MB (1024 * 1024 bytes), of the image file to create. The maximum size is 10240 MB.

Default: 10240

Example: -s 2048

No

-d, --destination destination

The directory in which to create the bundle.

Default: /tmp

Example: -d /var/run/my-bundle

No

-e, --exclude directory_1,directory_2,...

A list of absolute directory paths and files to exclude from the bundle operation. This parameter overrides the --all option. When exclude is specified, the directories and subdirectories listed with the parameter will not be bundled with the volume.

Example: Assuming the mount point of the volume is -v /foo, and you want to exclude directories /foo/bar and /foo/baz, specify -e /bar,/baz.

No

-i, --include file_1,file_2,...

A list of files to include in the bundle operation. This option overrides the exclusion of files that are by default filtered out because they might contain sensitive information.

Use this option to explicitly include a file that might contain sensitive data — i.e., '*.sw', '*.swo', '*.swp', '*.pem', '*.priv', '*.gpg', '*.jks', '*/.ssh/authorized_keys', '*/.bash_history'. The files listed with the parameter will be bundled with the volume.

Example: Assuming the mount point of the volume is -v /mnt/myvol/ and you want to include file /mnt/myvol/foo/bar.pem, specify -i /foo/bar.pem.

No

-p, --prefix ami_prefix

The filename prefix for bundled AMI files.

Default: image

Example: -p my-image-is-special

No

-v, --volume volume

The absolute path to the mounted volume from which to create the bundle.

Default: The root directory (/)

Example: -v /mnt/my-customized-ami

No

-a, --all

Bundle all directories, including those on remotely mounted filesystems.

Example: -a

No

--ec2cert cert_path

The path to the Amazon EC2 X.509 public key certificate.

Default: /etc/ec2/amitools/cert-ec2.pem (varies, depending on tools)

Example: --ec2cert /etc/ec2/amiutil/cert-ec2.pem

No

--fstab fstab_path

The path to the fstab to bundle into the image. If this is not specified, Amazon EC2 bundles /etc/fstab.

Example: --fstab /etc/fstab

No

--generate-fstab

Causes Amazon EC2 to bundle the volume using an Amazon EC2-provided fstab.

Example: --generate-fstab

No

--kernel kernel_id

The ID of the kernel to select.

Example: --kernel aki-ba3adfd3

No

--ramdisk ramdisk_id

The ID of the RAM disk to select.

Some kernels require additional drivers at launch. Check the kernel requirements for information on whether you need to specify a RAM disk. To find the kernel requirements, go to the Resource Center and search for the kernel ID.

Example: --ramdisk ari-badbad00

No

--block-device-mapping mappings

Default block-device-mapping scheme with which to launch the AMI. This defines how block devices are exposed to an instance of this AMI if the instance type supports the specified device.

The scheme is a comma-separated list of key=value pairs, where each key is a virtual name and each value is the desired device name. Virtual names include:

  • ami—The root file system device, as seen by the instance

  • root—The root file system device, as seen by the kernel

  • swap—The swap device, as seen by the instance

  • ephemeralN—The Nth ephemeral store

Example: --block-device-mapping ami=sda1,root=/dev/sda1,ephemeral0=sda2,swap=sda3

Example: --block-device-mapping ami=0,root=/dev/dsk/c0d0s0,ephemeral0=1

No

--[no-]inherit

Whether the image should inherit the instance's metadata (the default is to inherit). Bundling will fail if you enable inherit but the instance metadata is not accessible.

Example: --inherit

No

--productcodes product_code

Product code to attach to the image at registration time.

Example: --productcodes 1234abcd

No

Output

Status messages describing the stages and status of the bundling.

Example

This example creates a bundled AMI by compressing, encrypting and signing a snapshot of the local machine's root file system.

$ ec2-bundle-vol -d /mnt -k pk-HKZYKTAIG2ECMXYIBH3HXV4ZBEXAMPLE.pem -c cert-HKZYKTAIG2ECMXYIBH3HXV4ZBEXAMPLE.pem -u 111122223333 -r x86_64
  Copying / into the image file /mnt/image...
  Excluding:
       sys
       dev/shm
       proc
       dev/pts
       proc/sys/fs/binfmt_misc
       dev
       media
       mnt
       proc
       sys
       tmp/image
       mnt/img-mnt
  1+0 records in
  1+0 records out
  mke2fs 1.38 (30-Jun-2005)
  warning: 256 blocks unused.

  Splitting /mnt/image.gz.crypt...
  Created image.part.00
  Created image.part.01
  Created image.part.02
  Created image.part.03
  ...
  Created image.part.22
  Created image.part.23
  Generating digests for each part...
  Digests generated.
  Creating bundle manifest...
  Bundle Volume complete.