Creating an CentOS 6.5 EBS-backed EMI from an Existing Instance Store-Backed HVM Instance

Follow

Eucalyptus Versions: 3.4.0 and Greater

Creating an CentOS 6.5 EBS-backed EMI from an Existing Instance Store-Backed HVM Instance

This article will focus on migrating a CentOS 6.5 HVM instance store-backed instance to an CentOS 6.5 EBS-backed instance.  

Since the recent release of 4.0, the Eucalyptus Image Management documentation started focusing more on HVM instance store-backed Eucalyptus Machine Images (EMIs).  HVM instance store-backed EMIs are supported on Eucalyptus 3.4 as well.  Along with this change, Eucalyptus also moved away from the eustore Image Management model.  We now encourage users to download HVM images from the Eucalyptus Machine Image Catalog.  Using HVM images cuts down on dealing with kernels and ramdisks when bundling, uploading and registering images.  

Before we get started, lets cover some of the prerequisites that need to be addressed before going through the steps.

Prerequisites

The prerequisites for this KB are as follows:

EBS-Backed EMI Creation

After an instance has been launched from the CentOS 6.5 instance store-backed HVM EMI using euca-run-instances, create a volume using euca-create-volume:

[root@odc-f-13 ~]# euca-create-volume -s 7 -z ViciousLiesAndDangerousRumors
VOLUME vol-B176C482 7 ViciousLiesAndDangerousRumors creating 2014-07-25T23:12:43.932Z

Once the volume reaches the 'available' state, attach it to the CentOS 6.5 instance:

[root@odc-f-13 ~]# euca-describe-volumes vol-B176C482
VOLUME vol-B176C482 7 ViciousLiesAndDangerousRumors available 2014-07-25T23:12:43.932Z standard
[root@odc-f-13 ~]# euca-describe-instances i-C350B50C
RESERVATION r-1DB2EAD3 408396244283 default
INSTANCE i-C350B50C emi-17459F3E euca-10-104-6-235.bigboi.acme.eucalyptus-systems.com euca-172-18-238-138.bigboi.internal running account1-user01 0 m1.medium 2014-07-25T18:03:08.457Z ViciousLiesAndDangerousRumors monitoring-disabled 10.104.6.235 172.18.238.138 instance-store hvm sg-A5133B59
[root@odc-f-13 ~]# euca-attach-volume -i i-C350B50C -d /dev/sde vol-B176C482 
ATTACHMENT vol-B176C482 i-C350B50C /dev/sde attaching 2014-07-25T23:15:41.245Z

SSH into the instance, and check to see if the block device for the volume is present:

[root@odc-f-13 ~]# ssh -i account1-user01/account1-user01.priv root@euca-10-104-6-235.bigboi.acme.eucalyptus-systems.com
Last login: Fri Jul 25 21:31:53 2014 from 10.104.10.55
[root@euca-172-18-238-138 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 4.9G 0 disk
├─vda1 252:1 0 500M 0 part /boot
└─vda2 252:2 0 4.4G 0 part
├─VolGroup-lv_root (dm-0) 253:0 0 3.9G 0 lvm /
└─VolGroup-lv_swap (dm-1) 253:1 0 500M 0 lvm [SWAP]
vdb 252:16 0 5.1G 0 disk
vdc 252:32 0 7G 0 disk

The volume has been attached as the block device /dev/vdc.  Next, update the file /etc/sysconfig/network-scripts/ifcfg-eth0 to look similar to the following:

[root@euca-172-18-238-138 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="dhcp"
IPV6INIT="yes"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
PERSISTENT_DHCLIENT=yes

Use the echo command to zero out the contents of the /etc/udev/rules.d/70-persistent-net.rules and /lib/udev/rules.d/75-persistent-net-generator.rules files:

[root@euca-172-18-238-138 ~]# echo "" > /etc/udev/rules.d/70-persistent-net.rules
[root@euca-172-18-238-138 ~]# echo "" > /lib/udev/rules.d/75-persistent-net-generator.rules

Use the dd command to copy the contents of the block device /dev/vda (root filesystem) to /dev/vdc (the EBS volume):

[root@euca-172-18-238-138 ~]# dd if=/dev/vda of=/dev/vdc
10240000+0 records in
10240000+0 records out
5242880000 bytes (5.2 GB) copied, 677.344 s, 7.7 MB/s

Use the parted command to confirm that the contents were copied over correctly:

[root@euca-172-18-238-138 ~]# parted /dev/vdc print
Model: Virtio Block Device (virtblk)
Disk /dev/vdc: 7516MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1049kB 525MB 524MB primary ext4 boot
2 525MB 5243MB 4718MB primary lvm

Log out of the instance, and use euca-detach-volume to detach the volume from the instance:

[root@odc-f-13 ~]# euca-detach-volume vol-B176C482

Create a snapshot of the volume using the euca-create-snapshot command:

[root@odc-f-13 ~]# euca-create-snapshot vol-B176C482
SNAPSHOT snap-BCC58293 vol-B176C482 pending 2014-07-25T23:35:18.563Z 408396244283 7

Once the snapshot has completed, create an EBS-backed EMI with the snapshot, using the euca-register command:

[root@odc-f-13 ~]# euca-describe-snapshots snap-BCC58293
SNAPSHOT snap-BCC58293 vol-B176C482 completed 2014-07-25T23:35:18.563Z 100% 408396244283 7
[root@odc-f-13 ~]# euca-register -n centos6.5-ebs-hvm --snapshot snap-BCC58293 
IMAGE emi-E041AA72

Testing the Image

Once the EBS-backed EMI has been registered, launch an instance from the EMI using the euca-run-instances command:

[root@odc-f-13 ~]# euca-run-instances -k account1-user01 -t c1.medium emi-E041AA72
RESERVATION r-7FC000D0 408396244283 default
INSTANCE i-E0ED459E emi-E041AA72 pending account1-user01 0 c1.medium 2014-07-25T23:42:31.287Z ViciousLiesAndDangerousRumors monitoring-disabled 0.0.0. 0.0.0.0 ebs hvm sg-A5133B59

Once the instance reaches the 'running' state, make sure port 22 is open for the security group the instance is using (confirm with euca-describe-group), and then SSH into the instance:

[root@odc-f-13 ~]# euca-describe-instances i-E0ED459E
RESERVATION r-7FC000D0 408396244283 default
INSTANCE i-E0ED459E emi-E041AA72 euca-10-104-6-237.bigboi.acme.eucalyptus-systems.com euca-172-18-238-144.bigboi.internal running account1-user01 0 c1.medium 2014-07-25T23:42:31.287Z ViciousLiesAndDangerousRumors monitoring-disabled 10.104.6.237 172.18.238.144 ebs hvm sg-A5133B59
BLOCKDEVICE /dev/sda vol-49230027 2014-07-25T23:42:31.429Z true
[root@odc-f-13 ~]# ssh -i account1-user01/account1-user01.priv root@euca-10-104-6-237.bigboi.acme.eucalyptus-systems.comLast login: Sat Jul 26 02:12:54 2014 from 10.104.10.55
[root@euca-172-18-238-144 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 7G 0 disk
├─vda1 252:1 0 500M 0 part /boot
└─vda2 252:2 0 4.4G 0 part
├─VolGroup-lv_root (dm-0) 253:0 0 3.9G 0 lvm /
└─VolGroup-lv_swap (dm-1) 253:1 0 500M 0 lvm [SWAP]
[root@euca-172-18-238-144 ~]#

That's it!  An EBS-backed EMI has been created from the CentOS 6.5 HVM instance store-backed instance.

Have more questions? Submit a request

Comments

Powered by Zendesk