Migrate an Image
This section covers migrating images to and from your Eucalyptus cloud.
This is the multi-page printable view of this section. Click here to print.
This section covers migrating images to and from your Eucalyptus cloud.
A common way to create a new image is to customize an existing instance. This topic describes how to create a new image by modifying an existing EBS-backed instance.This example shows how to create a new EBS-backed Eucalyptus image based on an existing EBS-backed Eucalyptus instance.
Log on to an existing Eucalyptus EBS-backed instance and customize the instance. Prepare the image. See for instructions. Create a new image based on the image you just modified by using the eucalyptus-create-image command, specifying a name, a description, and the instance ID of the Eucalyptus instance you customized in the previous step. For example: euca-create-image -n "mynewimage" -d "This is my new custom recycled image" i-1ABCDEFF
This command will show the ID of the new machine image and exit immediately. In the background, Eucalyptus will begin the process of creating a new image based on the instance you supplied.
You can monitor the status of the image using the euca-describe-images command, supplying the ID of the image returned from the euca-create-image command. For example:
euca-describe-images i-e12398ab
A common way to create a new image is to customize an existing instance.This example shows how to create a new instance store Eucalyptus image based on an existing instance store Eucalyptus instance. This topic describes how to create a new image by modifying an existing instance-store instance.
Log on to an existing Eucalyptus instance-store instance and customize the instance. See Prepare a Linux Image for Eucalyptus for instructions on required changes the instance needs before re-bundling. Create a new image based on the image you just modified by using the euca-bundle-instance
command, specifying a name, a description, and the instance ID of the Eucalyptus instance you customized in the previous step. For example:
euca-bundle-instance -b mybundle -p mycentos6 -o $EC2_ACCESS_KEY -w $EC2_SECRET_KEY i-96154365
BUNDLE bun-96154365 i-96154365 mybundle mycentos 62013-11-05T21:37:23.469Z2013-11-05T21:37:23.469Z pending 0
This command will the bundle task ID and exit immediately. In the background, Eucalyptus will begin the bundling process. Depending on the size of the instance, it can take several minutes for the bundling task to complete.
You can monitor the status of the bundle task using the euca-describe-bundle-tasks
command, supplying the ID of the image returned from the eucalyptus-bundle-instance
command. For example:
euca-describe-bundle-tasks
BUNDLE bun-96154365 i-96154365 mybundle mycentos6 2013-11-05T21:37:23.469Z2013-11-05T21:37:58.446Z storing 0
Once the bundle task is complete, you can register thebundle as an instance-store image using the euca-register command, specifying the path to the bundle manifest in the format [bucket]/[prefix].manifest.xml
.
euca-register --virtualization-type=hvm mybundle/mycentos6.manifest.xml.
Your new image is now ready for use in your Eucalyptus cloud.This section explains how to prepare a running Linux system (cloud instance, virtual machine, or a system running on bare metal) before importing it for use in Eucalyptus.Install cloud software and drivers: Make sure Virtio drivers are installed if the image is going to be run in a KVM cluster which has virtio enabled, and verify use if possible (ie. set disks and network interface in hypervisor, try hot plug in for disks, etc). For most recent Linux distributions nothing is needed to be done. Make sure appropriate init scripts are in place; for example: cloud-init packages (if appropriate), and rc.local or similar scripts to prepare new instances at boot time utilizing user/meta-data.
Install cloud-init:
For Red Hat Enterprise Linux, and CentOS 7:
yum install cloud-init
Install and configure ssh: For Red Hat and CentOS:
yum install openssh-server
systemctl enable sshd.service
Install Euca2ools: For Red Hat and CentOS:
yum install euca2ools
Optionally, update existing packages. For RHEL and CentOS:
yum update
Prepare the network: Disable the firewall. It is recommended that the firewall is disabled and network rules are instead enforced in the security-group the instances run in. If the guest’s firewall is not disabled, review the existing rules and make sure they are appropriate for the guest’s future use within a cloud environment. Clear or disable iptable rules: Save the rules in case you want to restore them later:
sudo iptables-save > /root/firewall.rules
Clear the rules:
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
For RHEL and CentOS 7, see the Red Hat Migration and Planning Guide Security and Access Control section .
Make sure there is only a single primary network interface. Check the configuration for:
For RHEL and CentOS images, the configuration for the default network interface can usually be found in the following file:
/etc/sysconfig/network-scripts/ifcfg-eth0
The following is an example of an ifcfg-eth0
configuration file:
DEVICE=eth0
ONBOOT=yes
#THE HWADDR LINE MUST BE COMMENTED OUT OR REMOVED
#HWADDR=AA:BB:CC:DD:EE:FF
TYPE=Ethernet
BOOTPROTO=dhcp
PERSISTENT_DHCLIENT=yes
Remove persistent udev rules:
echo "" > /etc/udev/rules.d/70-persistent-net.rules
echo "" > /lib/udev/rules.d/75-persistent-net-generator.rules
On CentOS and RHEL, disable zeroconf by adding an entry to the /etc/sysconfig/network
file:
NETWORKING=yes
NOZEROCONF=yes
Clean the image: We recommend that you remove all non-root, non-administrator users before bundling the image. Remove root/Administrator password. We recommend that you remove root’s password for Linux systems.
/boot/grub/menu.lst
file: console=ttyS0
You’ve now prepared your instance for image creation.You can migrate an S3-backed image from AWS to Eucalyptus.
euca-describe-images --region us-east-1 --owner 999999999999
IMAGE ami-e1a1e888 999999999999/precise-test 999999999999 available private x86_64 machine aki-88aa75e1 instance-store paravirtual xen
BLOCKDEVICEMAPPING EPHEMERAL sda2 ephemeral0
Run the AWS instance.
euca-run-instance ami-e1a1e888 --region us-east-1
Install Euca2ools on the instance. For instructions, see the Euca2ools Guide. Make sure that you have enough space on a volume to hold the bundle that we will create. Bundle the running AWS instance. For example:
sudo -s
ec2-bundle-vol -b testbucket -d /mnt -u 4299-4227-3585 -k my-aws.pem -c my-aws-cert.pem -r x86_64 -s 2048
Copying / into the image file /mnt/image...
Excluding:
/dev/pts
/
/sys
/proc
/proc/sys/fs/binfmt_misc
/dev
/media
/mnt
/proc
/sys
/mnt/image
/mnt/img-mnt
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.00209056 s, 502 MB/s
mke2fs 1.42.3 (14-May-2012)
Bundling image file...
Splitting /mnt/image.tar.gz.enc...
Created image.part.00
Created image.part.01
[example truncated]
Created image.part.30
Generating digests for each part...
Digests generated.
Unable to read instance meta-data for ancestor-ami-ids
Unable to read instance meta-data for ramdisk-id
Unable to read instance meta-data for product-codes
Creating bundle manifest...
ec2-bundle-vol complete.
Switch the Euca2ools configuration file to use Eucalyptus. You can do this by specifying the Eucalyptus region as defined in your Euca2ools configuration file by specifying the --region
parameter on the command line, or by changing the default-region
option in the Euca2ools configuration file:
default-region = euca-release
Download the bundle from the AWS S3 bucket:
euca-download-bundle --bucket testbucket --directory /tmp/aws-image/ --region us-east-1
Unbundle the AWS instance bundle:
euca-unbundle --manifest /tmp/aws-image/image.manifest.xml --source /tmp/aws-image/ --destination /tmp/aws-image/ --region us-east-1
Run some checks to make sure that the image can be used with Eucalyptus: Mount the image via loopback:
# sudo mkdir /mnt/aws-image
# sudo mount -o loop /tmp/aws-image/image /mnt/aws-image
# df -ah
……
/tmp/aws-image/image
9.9G 1.1G 8.3G 12% /mnt/aws-image
Make sure that the distro repositories in the image do not point to EC2-specific repositories. TODO: Need an actual example here. Install a non-Xen kernel into the image from distro and make sure VirtIO modules are added. TODO: Need an actual example here. Extract the ramdisk and kernel to be bundled, uploaded and registered as ERI and EKI files. In this example, initrd.img-3.2.0-53-virtual and vmlinuz-3.2.0-53-virtual will be copied from /mnt/aws-image/boot to the /tmp/aws-image directory:
# sudo cp /mnt/aws-image/boot/initrd.img-3.2.0-53-virtual /tmp/aws-image/.
# sudo cp /mnt/aws-image/boot/vmlinuz-3.2.0-53-virtual /tmp/aws-image/.
Make sure that the file system of the image is either ext2, ext3, or ext4 by using the file command. For example:
# file /tmp/aws-image/image
/tmp/aws-image/image: Linux rev 1.0 ext4 filesystem data (extents) (large files) (huge files)
Bundle the image using euca-bundle-image:
euca-bundle-image -i /tmp/aws-image/image
Upload the AWS bundled instance to Eucalyptus.
euca-upload-bundle -b hybrid-guide-sample-bucket -m /tmp/aws-image/image.manifest.xml --access-key myaccesskey --secret-key mysecretkey
Test the new uploaded image.
euca-run-instance emi-a6e15bcf
This topic describes how to migrate an image from Eucalyptus to AWS.
euca-run-instance emi-1A6338AE
SSH into the instance and verify that the instance is valid for use with AWS: Download the latest ec2-modules from and put them into the /lib/modules
directory on the instance. Copy the AWS EC2 certificate and private key from the AWS instance to your local workstation. Shut down unneeded services on the AWS instance (for example, Apache and MySQL). Clear out log files and bash history files. Remove your ssh keys from the instance. Reset passwords for the instance, and for any services that maintain their own password database. Clear out any temporary directories. Install Euca2ools on the instance.
Mount a volume that is at least 1.5 times as large as the entire instance. Bundle the running instance.
euca-bundle-instance
Switch the Euca2ools configuration file to use Eucalyptus
default-region = euca-release
Upload the AWS bundled instance to Eucalyptus.
euca-upload-bundle -b bucket_name -m manifest_file
Test the new uploaded image.
euca-run-instance emi-a6e15bcf