Tuesday, 16 July 2013

Eucalyptus 3.3 Tutorials- Creating Instance Store Backed EMI

Eucalyptus 3.3 Tutorials
Creating Instance Store backed EMIs

In this set of tutorials, we are going have a look at the steps required to build a CentOS-based Instance-store-backed EMI.

To create image, we will need a raw HDD for the virtual machine. Use the following command to create your raw HDD.

# qemu-img create -f raw <IMAGE_NAME>.img <SIZE>

NOTE: Ideally provide at least 3-4 GB for your img file.

Next, we use parted to set the appropriate disk label

# parted <IMAGE_NAME>.img mklabel msdos

Once that's done, create a filesystem for your image. This filesystem can be either an ext3 or ext4

# mkfs.ext3 -F <IMAGE_NAME>.img -L rootdisk

Now that the filesystem is ready, we associated the disk image with a loopback device.

# losetup -f --s <IMAGE_NAME>.img

Create a folder and mount the loopback device to it.

# mkdir /mnt/centos
# mount /dev/loop0 /mnt/centos/

Next, create the mount points for virtual filesystems within the image:

# mkdir -p /mnt/centos/{proc,etc,dev,var/{cache,log,lock/rpm}}
# MAKEDEV -d /mnt/centos/dev -x console
# MAKEDEV -d /mnt/centos/dev -x null
# MAKEDEV -d /mnt/centos/dev -x zero
# mount -t proc none /mnt/centos/proc

Finally, create the fstab entries for your image. Use a text editor and paste the following in the fstab file:

# cat > /mnt/centos/etc/fstab << EOF
LABEL=rootdisk    /    ext3    defaults    1    1
none    /proc    proc    defaults    0    0
none    /sys    sysfs    defaults    0    0

NOTE: Provide tabs between each entry in the fstab file. Avoid spaces.

We are now ready to install the base system in our Image. This step requires internet connectivity, however, you can do these steps without internet as well, by creating a Yum local repository as mentioned in the EARLIER TUTORIAL.

# yum --installroot=/mnt/centos/ groupinstall Base -y
The command will install the base CentOS packages into the Image. It will take sometime for this step to complete.

Once the base OS is installed, copy the necessary repository files from your host CentOS to your Image. In this step, I am only copying the CentOS-Media.repo that we created in our EARLIER TUTORIAL. Once copied, you can now install any particular RPM that you wish to install in your image. Few necessary ones such as VIM, OpenSSH Server, DHClient, telnet, curl and NTP etc are good to have in your Image.
# yum install --installroot=/mnt/centos/ vim-minimal openssh-server dhclient curl ntp -y 
You can install and configure your image with other RPMs as your requirement may specify.

Next, change root to your new image using chroot:
# chroot /mnt/centos/

Turn off unrequired services:

# chkconfig abrt-ccpp off
# chkconfig abrt-oops off
# chkconfig abrtd off
# chkconfig ip6tables off
# chkconfig iptables off
# chkconfig kdump off
# chkconfig lvm2-monitor off
# chkconfig ntpd on
# chkconfig sshd on

Edit the global network configuration to disable the ZEROCONF networking route: 

# cat > /etc/sysconfig/network << EOF

Next, create a file for the network interface:

# cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF

Once all your changes are done, exit the chroot

Finally, unmount the image and virtual filesystems, forcing changed blocks to disk for good measure:
# sync
# umount /mnt/centos/proc
# umount /mnt/centos


With this, your Image should be ready for uploading into Eucalyptus.

In the next part of this series, we will look at few simple steps for uploading EMIs to Eucalyptus.. so stay tuned !!

>> Eucalyptus Tutorials: Upload EMIs to Eucalyptus

No comments :

Post a Comment

Note: only a member of this blog may post a comment.