HowTo upload your own images to the SmartCloud Enterprise. UBUNTU Server
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.
Create the .ssh folder and the file authorized_keys:
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…”:
– Change the run-level
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:
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
chmod +x /etc/init.d/change_file
Create the template file:
iface lo inet loopback
iface eth0 inet static
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/
– 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 ic-copy-to.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)
-Now, copy all the files from the Red Hat image that you downloaded before to this folder (except BSS.zip, *.img and *.mf files)
– Create a file named BSS.xml and add these lines :
and zip it.
zip BSS.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:
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 FileValidation.sh 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 ic-import-image.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: