NSCEE Research Cloud -- Building Custom Linux Images

From NSIwiki

This procedure was last verified to work on January 6, 2015

This is the procedure that I use to build custom Linux images for use on the Rebel Research Cloud. Note: I did this using a real desktop running native CentOS, however it should work inside of a virtual machine.

  0.1) install CentOS 6.5 from DVD image (select software development workstation)
  0.2) yum update
  0.3) easy_install ez_setup
  0.4) activate the EPEL repository
       wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
       wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
       rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
       change "enabled=1" to "enabled=0" in /etc/yum.repo.d/epel.repo
  0.5) yum --enablerepo=epel install python-imgcreate cloud-init
  0.6) git clone https://github.com/katzj/ami-creator.git
  0.7) cd ami-creator
  0.8) python setup.py build
  0.9) python setup.py install

You should now be able to create images. There is a ks-fedora-14.cfg configuration file as part of the ami-creator package. It will not build because fedora 14 is too old. NOTE: The following procedure has only been tested with CentOS images, not fedora. ALso, note that the EPEL people like to change how access to their repositories are done, if the ami-creator command fails, double check the EPEL access... I had to change from using --baseurl to --mirrorlist. You can look at the /etc/yum.repos.d/epel.repo file that was created in step 0.4 above.

To create a centos image:

 1.1) You need to change the ks-centos6.cfg:
    $ diff -c ks-centos6.cfg~ ks-centos6.cfg
    *** ks-centos6.cfg~	  2014-06-05 11:05:57.401012565 -0700
    --- ks-centos6.cfg	  2014-06-05 11:19:04.356922097 -0700
    *** 25,32 ****
      # Repositories
      repo --name=CentOS6-Base --mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
      repo --name=CentOS6-Updates --mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
    ! repo --name=EPEL --baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/
    --- 25,32 ----
      # Repositories
      repo --name=CentOS6-Base --mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
      repo --name=CentOS6-Updates --mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
    ! #repo --name=EPEL --baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/
    ! repo --name=EPEL --mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
 1.2) mkdir centos6-image
 1.3) cd centos6-image/
 1.4) cp ../ks-centos6.cfg .
 1.5) ami-creator -c ks-centos6.cfg -n centos6test -v -e

You can then modify your disk image. I use centos6test in this example. You probably need to be root.

 2.1) mount -o loop centos6test.img /mnt
 2.2) chroot /mnt
 2.3) Install additional software/make modifications as needed 
 2.4) exit
 2.5) umount /mnt

How to bundle up your image (NOTE: Only the system administrator can register kernel images (step 3.3 below). Please try and use one of the already installed kernels, if you need a special kernel registered, send email to ron@nscee.edu. Also, you will need to use dfferent names for mybucket and mybucket2:

 3.1) make sure you have your credentials active (. ./eucarc)
 3.2) make sure you have install euca2ools,
      yum --enablerepo=epel install euca2ools
 3.3) euca-bundle-image -i vmlinuz-2.6.32-504.3.3.el6.x86_64 --kernel true
      euca-upload-bundle -b mybucket \
              -m /tmp/vmlinuz-2.6.32-504.3.3.el6.x86_64.manifest.xml 
      euca-register mybucket/vmlinuz-2.6.32-504.3.3.el6.x86_64.manifest.xml
      IMAGE  eki-C05938B8        (this value is returned -- needed later)
 3.4) euca-bundle-image -i initramfs-2.6.32-504.3.3.el6.x86_64.img \
    		       --ramdisk true
      euca-upload-bundle -b mybucket2 \
           -m /tmp/initramfs-2.6.32-504.3.3.el6.x86_64.img.manifest.xml 
      euca-register mybucket2/initramfs-2.6.32-504.3.3.el6.x86_64.img.manifest.xml
      IMAGE  eri-2F6C38F5        (this value is returned -- needed later)
 3.5) euca-bundle-image -i centos6test.img \
          --ramdisk eri-CB183617 \

--kernel eki-1E4534B8

      euca-upload-bundle -b mybucket2 -m /tmp/centos6test.img.manifest.xml 
      euca-register mybucket2/centos6test.img.manifest.xml \
    		   -n centos6test-rly -a x86_64
      IMAGE  emi-61C14237

At this point your image/kernel/initrd should be available as emi-61C14237 (mybucket2/centos6test-rly).