Manual Image Customization

Sometimes users need to further customize their images by installing their own software—software which may not be able to be installed with the image generation tool. In this tutorial, we explain how users can perform this customization in the images created with the FG image generation tool. Detailed information about FG image management tools can be found in http://futuregrid.github.com/rain/.

Logging into India

$ ssh <username>@india.futuregrid.org 
$ module load futuregrid

 

Requesting access

Submit a ticket to request access http://archive.futuregrid.org/help

Obtaining the image

You can get your image from our repository, or generate a new one.

Getting an image from the repository

$ fg-repo -u <username> -g <imageId>

Generating a new image

We are going to generate an Ubuntu image. Since we want to modify the image, we have specified the -g parameter to retrieve the image after it is generated. By default, it is uploaded to the image repository.
$ fg-generate -u jdiaz -o ubuntu -v 12.04 -a x86_64 -s wget, openmpi-bin -g

In both cases, we will obtain a tgz file that contains the image file (.img) and a manifest (.manifest.xml). For example, our image could be in /N/u/<username>/123123123.tgz .

Customizing the image

To continue with the rest of the tutorial, we need a UNIX machine where we have root privileges.

Assuming that we are in a UNIX machine with root privileges:

1. Retrieve the image from India:
$ scp <username>@india.futuregrid.org:/N/u/<username/123123123.tgz .
2. Decompress the image:
$ tar vxfz 123123123.tgz

jdiaz859434.img
jdiaz859434.manifest.xml
3. Mount the image. This will mount the image file into a directory. In this way, we will have access to the OS files that are inside the image.
$ mkdir image
$ sudo mount -o loop jdiaz859434.img image
Copy your software into the image directory (if needed). In this case, I am going to copy a software directory to the tmp directory of the image:
$ cp -r /home/javi/mysoftware image/tmp
Chroot into the image. This changes the root of the OS to the one of the image. In this way, evey operation we execute will have effect only inside the image. After executing this command, you will be the root users inside the image.
$ sudo chroot image
Now you can install whatever software you need. You can also use yum/apt to install packages from the software repository. Remember that they will be installed inside the image. As example, here I install tomcat with apt and compile my software with make:
# apt-get install tomcat6
# cd /tmp/mysoftware
# make && make install
You can also configure the OS of image to start services during the boot time. The easiest way to do that is by modifying the /etc/rc.local file.

Once you have finished customizing your image, you need to exit from the chroot command, unmount the image, and compress it again:
# exit
$ sudo umount image
$ tar vxfz mynewimage.tgz jdiaz859434.img jdiaz859434.manifest.xml

Transfer the image back to India

$ scp mynewimage.tgz <username>@india.futuregrid.org:/N/u/<username>/

Log into India

$ ssh <username>@india.futuregrid.org 
$ module load futuregrid

Upload the image to the repository

We upload the image to the repository so we can reuse it and share it with other users. When uploading the image, you can specify some metadata to describe the properties of the image:
$ fg-repo -p mynewimage.tgz "os=Ubuntu12 & arch=x86_64 & description=My new customized image & tag=tomcat, openmpi"

This command will provide you the ID your image has in the repository. This ID is needed for the next step.

Register your image in different infrastructures

You now have your image ready to be registered in the different FutureGrid infrastructures. To use OpenStack (tutorial) and Eucalyptus (tutorial), you need to indicate the location of you novarc and eucarc file.

Register the image in Openstack

$ fg-register -u <username> -r <imageID> -s india -v ~/novarc

Register the image in Eucalyptus

$ fg-register -u <username> -r <imageID> -e india -v ~/eucarc

Register the image in HPC

$ fg-register -u <username> -r <imageID> -x india

Each command will provide you with the ami-ID that your image has in the specified infrastructure.

Using your Registered Image

OpenStack (more info in http://archive.futuregrid.org/tutorials/openstack)

source novarc
euca-run-instance -k <keyname> <ami-ID>

Eucalyptus (more info in http://archive.futuregrid.org/tutorials/eucalyptus3)

source eucarc
euca-run-instance -k <keyname> <ami-ID>

HPC (more info in http://archive.futuregrid.org/tutorials/hpc)

Provision a machine with our image and go into Interactive mode (you are logged into the machine):
qsub -l os=<ami-ID> -I
Provision two machines with our image and execute an script:
qsub -l os=<ami-ID> -l nodes=2:ppn=8 myscript.sh