CloudStack CentOS Template – Install From ISO

This is a part 1/3 creating CentOS 6.x CloudStack template with the following features:

  1. Minimal and fully updated CentOS 6.5 for 32-bit and 64-bit platforms with guest OS tools
  2. Root password management using cloudstack-guest-set-password script
  3. SSH key management using cloud-init

Register CentOS ISO

  1. Login to CloudStack management UI
  2. Navigate to ‘Templates’ and select view ‘ISO’ from the drop-down listcloudstack-view-iso
  3. Click ‘Register ISO’. Use the latest CentOS release ISO, which at this time (as of Jan 2014) is CentOS 6.5cloudstack-register-iso
  4. Set ‘Name’ and ‘Description’ fields to CentOS-6.5-x86_64-minimal.iso
  5. Set the URL to the nearest ISO mirror. I used http://mirror.leapswitch.com/centos/6.5/isos/x86_64/CentOS-6.5-x86_64-minimal.iso for CentOS 6.4 64-bit and http://mirror.leapswitch.com/centos/6.5/isos/i386/CentOS-6.5-i386-minimal.iso for the 32-bit version.
  6. Check the ‘Bootable’ checkbox
  7. Set the OS Type field to ‘CentOS 6.4 (64-bit)’ as CentOS 6.5 is not listed in the drop down list as of CloudStack 4.2.0. Use OS Type ‘CentOS 6.4 (32-bit)’ for the 32-bit ISO
  8. Click OK button to start the downloadcloudstack-register-iso-centos
  9. CloudStack will now start to download the ISO from the mirror. You can check the status by clicking on the ISO’s namecloudstack-view-iso-progress
  10. Wait for the ISO download and complete registration successfully. It takes a few minutes depending on the speed of your connection cloudstack-view-iso-success

Once the ISO registration is completed, create a new instance with the ISO

Create CentOS Instance

  1. Click on ‘Instances’ and ‘Add Instance’. Select ‘ISO’ button and click ‘Next’cloudstack-add-instance-iso
  2. From the ‘Select A Template’ screen, select ‘CentOS-6.5-x86_64-minimal.iso’ ISO from the ‘My ISOs’ section. Also choose the hypervisor type and click ‘Next’.cloudstack-add-instance-select-iso
  3. Select a ‘Compute Offering’ and click ‘Next’. A 1vCPU/512MB offering is what I have usedcloudstack-add-instance-compute-offering
  4. Choose a ‘Data Disk’ offering. I have used a 20GB diskcloudstack-add-instance-data-disk
  5. Choose defaults for ‘Affinity’ and ‘Network Offering’
  6. Set the instance ‘Name’ from the ‘Review’ screen and ‘Launch VM’. I typically use the format os+version-hypervisor+arch. So CentOS 6.5 64-bit on XenServer becomes ‘centos65-xen64’ for easy identificationcloudstack-add-instance-review-nameIn my environment, I end up with 4 golden instances per OS. So for CentOS 6.5, it’s centos65-xen32, centos65-xen64, centos65-kvm32 and centos65-kvm64 instances
  7. Wait for the instance to start ‘running’. Takes a few seconds depending on the performance of your CloudStack IaaS infrastructurecloudstack-add-instance-running
  8. Click on the running instance ‘centos65-xen64’ for additional detailscloudstack-instance-centos65

Once the instance is running, connect via the console and complete the installation

Install CentOS

  1. Connect via the console. You would have the Anaconda install screen waiting for you to start the installation. Skip the disk check.centos-install-splashcentos-install-welcome
  2. CentOS Language Selection. I chose ‘English’centos-install-lang-english
  3. CentOS keyboard selection. I chose ‘US’ defaultcentos-install-keyboard-us
  4. CentOS detects the 20GB Virt-IO based data disk. Re-Initialize all diskscentos-install-disk-reinit
  5. Select the ‘Time Zone’. I choose ‘UTC/GMT’ as default as my hypervisors run on UTC timezone. The end user can always change his timezone as appropriate latercentos-install-time-utc
  6. Pick a root password. It does not matter what you use here as we will build the template to automatically as a ‘password enabled’ template. Lets use ‘password’ for now.centos-install-root-password
  7. Use the entire 20GB disk vdacentos-install-disk-partition
  8. Write changes to the disk. The installer would now partition and format the disk.centos-install-write-changes-diskcentos-install-format
  9. Wait for the package installation to complete. Might take a few minutes depending on your infrastructurecentos-install-packagescentos-install-packages-completeSince we are using the minimal CentOS install ISO, you wont be prompted for manual package selection
  10. Reboot once the install completescentos-install-rebootcentos-install-rebooting
  11. Detach the ISO from the instance. You might want to do it very quickly before the OS completes the rebootcentos-instance-detach-isocentos-instance-detach-iso-confirm
  12. Reboot the instance with a console ctrl-alt-del if it happens to be stuck in the installer screen (since we detached the ISO)centos-instance-ctrl-alt-del
  13. centos65-xen64 would now boot and present you with the login promptcentos-instance-login-prompt
  14. Finally, login as ‘root’ centos-instance-root-login

In a minimal CentOS install via the text installer, eth0 is disabled by default. So the first thing to do would be to console login and enable the network interface for eth0 device. Once network is enabled, all other customization tasks would be done over SSH instead of the console.

Enable CentOS Networking

  1. Login as root via consolecentos-instance-root-login
  2. Update file /etc/sysconfig/network-scripts/ifcfg-eth0 as below and reboot the instance. I use the vi editor for editing files.
    DEVICE=eth0
    Type=Ethernet
    ONBOOT=yes
    NM_CONTROLLED=no
    BOOTPROTO=dhcp
    

    centos-instance-ifcfg-eth0

  3. Reboot the instance
    [root@localhost ~]# reboot
    
  4. After reboot, the hostname of the instance would have changed from localhost to centos65-xen64 indicating that the networking service is running with DHCP settings.centos-instance-login-prompt-dhcp-hostname
  5. sshd would also be running. Also identify the IP address assigned to eth0. It would match the NIC settings found on the instance’s NIC details page. In this case, eth0 is 10.1.1.38 and matches the CloudStack assigned NIC 1 IP address.
    centos-instance-sshd-ifconfig-eth0
    cloudstack-centos-instance-nic-settings
  6. Assign a static SNAT IP to centos65-xen64 to make it reachable from an external network. Also open SSH port from the firewall settings. In this case, the SNAT IP is 192.168.64.106.

    centos-instance-snat-ip

    centos-instance-firewall-icmp-ssh

  7. Check ICMP Pings and SSH access as root user

    centos-ssh

Our instance is now ready for use.

In the next article, we will customize and add CloudStack specific features to our CentOS template.

Shanker Balan

Shanker Balan is a devops and infrastructure freelancer with over 14 years of industry experience in large scale Internet systems. He is available for both short term and long term projects on contract. Please use the Contact Form for any enquiry.

More Posts - Website

Follow Me:
TwitterLinkedIn

Published by

Shanker Balan

Shanker Balan is a devops and infrastructure freelancer with over 14 years of industry experience in large scale Internet systems. He is available for both short term and long term projects on contract. Please use the Contact Form for any enquiry.

13 thoughts on “CloudStack CentOS Template – Install From ISO”

  1. Tank you for your article Shanker! I’m implementing ACS for a consumer here in Brazil and your article was very useful to prepare the templates for them.

  2. Hello,
    I have a problem I can not create instances with ISOs size 2.4GB, such as Kali Linux. I Have reviewed the ISO size parameters and everything is ok. What can is going on?

  3. Hi Shanker,

    when I enter the given centos urls in the browser, it says “requested url not found on the server.”
    Is givern url not valid anymore??
    Can you please help.

  4. Hi Manish, its been a while since I revisited CentOS installation. It is very likely that the URL is updated. You should be able to find alternative download sites quite easily.

  5. Hi Shankar,
    I have two issues in my clodustack environment ,

    1. I created one centos 6.7 template in cloudstack with password change script . For some time it was working successfully and generated working passwords for the VMs created . But for last few weeks the password showing in the pop up window is not working in the VM console . Can you guide me to troubleshoot this issue ?

    2. Some of the Virtual routers getting shut down automatically .. what will be the cause of this ?

Leave a Reply