close x

HowTo upload your own images to the SmartCloud Enterprise. UBUNTU Server

Hey guys,

It is too easy to save and run our images on the cloud. IBM gives us the possibility of uploading our own images, how?.

Some requirements from the source VM:

- First partition /boot, second partition /

- No LVM volumes

- Ext 3 filesystem

- Root partition smaller than 60Gb

1.- The first thing to do is preparing the Virtual Image:

- Create the idcuser and add it to the sudoers file.

adduser idcuser
Create the .ssh folder and the file authorized_keys:

mkdir /home/idcuser/.ssh
touch /home/idcuser/.ssh/authorized_keys
nano /etc/sudoers
and add the following line:

idcuser ALL=(ALL) ALL
- Install SSH

apt-get install ssh
- Modify the ssh config file, commenting all lines starting by “Hostkey…”:

nano /etc/ssh/sshd_config
UsePAM no
PasswordAuthentication no

AllowUsers idcuser

- Change the run-level

nano /etc/init/rc-sysinit.conf
set the run level to 3:

- The system is designed for Red Hat and SuSe images, so we have to create a script in order to set the network parameters when the image will be provisioned. Create the script:

nano /etc/init.d/change_file
IP=$(sed -n ‘s/.*IPADDR=\(.*\)/\1/p’ /etc/sysconfig/network-scripts/ifcfg-eth0|cut -c1-64)
NETMASK=$( sed -n ‘s/.*NETMASK=\(.*\)/\1/p’ /etc/sysconfig/network-scripts/ifcfg-eth0| cut -c1-64)
GATEWAY=$( sed -n ‘s/.*GATEWAY=\(.*\)/\1/p’ /etc/sysconfig/network-scripts/ifcfg-eth0| cut -c1-64)
HW=$(sed -n ‘s/.*HWADDR=\(.*\)/\1/p’ /etc/sysconfig/network-scripts/ifcfg-eth0|cut -c1-64)
cp /etc/init.d/ubuntu_interfaces_0 /etc/init.d/ubuntu_interfaces
sed -i ‘s/IP/’$IP’/’ /etc/init.d/ubuntu_interfaces
sed -i ‘s/MASK/’$NETMASK’/g’ /etc/init.d/ubuntu_interfaces
sed -i ‘s/GATEWAY/’$GATEWAY’/g’ /etc/init.d/ubuntu_interfaces
mv /etc/init.d/ubuntu_interfaces /etc/network/interfaces
/etc/init.d/networking restart

chmod +x /etc/init.d/change_file

Create the template file:

nano /etc/init.d/ubuntu_interfaces_0
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address IP
netmask MASK
gateway GATEWAY
Add the script to the initalization scripts:

apt-get install rcconf
Add the script change_file

Create the original network file from Red Hat:

mkdir -p /etc/sysconfig/network-scripts/
nano /etc/sysconfig/network-scripts/ifcfg-eth0

- Check that you can connect the VM by ssh (service running, firewall…)

2.- The second step is setting up the xml files, these files are the ones that the system uses for running the image.

- The best way to do it is getting these files from an image from the IBM catalogue. I used a Red Hat image. in order to do this you have to create a persistent storage (in this case in Canada) and run the following command: (requirements: we have to use an image saved in our private catalogue and with the “allow copy”

sh -u user_name -w passphrase -g pass_file -I private_image_id -v volumme_id
With this command we will have the Red Hat Enterprise 6 from Canada copied on a persistent storage on Canada

Anyway a copy of the original files is here.

-You need to create a folder called “image” in the persistent storage. (I use to mount the persistent storage on /mnt)

mkdir /mnt/image
-Now, copy all the files from the Red Hat image that you downloaded before to this folder (except, *.img and *.mf files)

- Create a file named BSS.xml and add these lines :

nano BSS.xml

Ubuntu Server 10.04 64 bits
Ubuntu Server 10.04 64 bits

Ubuntu Server 10.04 64 bits

and zip it.

zip BSS.xml
- We need to rename and edit the *.ovf. The new name will be ubuntu.ovf, and we need to edit and change the chain:


You can download the files I used from here.

- Upload the VM file to the machine which has the persistent storega linked. TRICK, to avoid disconnections and re-uploads, you should un-comment this line in the sshd_config file:

nano /etc/ssh/sshd_config
Subsystem sftp /usr/libexec/openssh/sftp-server
if you are a Linux user, use rsync to upload the VM file.

- If you have your VM file in ovf (raw format) you don´t need to perform this step, if not:

yum install qemu*
qemu-img convert -O raw /home/idcuser/ubuntu.vmdk /mnt/image/ubuntu.img
- Copy to the image folder.

- Run it

Choose 2 option to generate the .mf file, it takes a while. And later re-run again to check that it is everything ok, but this time choose first option (just check)

- Assign the right permissions:

Chown root:root –R /mnt/image
Chmod 755 –R /mnt/image
I assume that there weren´t problems till here.

- Delete the machine in order the persistent storage will be detached.

3.- The third step is importing the image, once the persistent storage is detached you have to run this commenad:

sh -u user_name -w passphrase -g pass_file -v id_of_volumme_which_contains_the_VM_file -n name_for_the_new_image
And…. Done in some minutes we will have our new image in our private catalogue. If we want to provision it, we just have to do it as we would do with a common image.

Thanks for helping me:

Tomoyuki Niijima

Hans Moen

Cloud Computing0 comments

Leave a Reply