CloudStack CentOS Template – Install From ISO
This is a part 1/3 creating CentOS 6.x CloudStack template with the following features:
- Minimal and fully updated CentOS 6.5 for 32-bit and 64-bit platforms with guest OS tools
- Root password management using cloudstack-guest-set-passwordscript
- SSH key management using cloud-init
Register CentOS ISO
- Login to CloudStack management UI
- Navigate to ‘Templates’ and select view ‘ISO’ from the drop-down list
- Click ‘Register ISO’. Use the latest CentOS release ISO, which at this time (as of Jan 2014) is CentOS 6.5
- Set ‘Name’ and ‘Description’ fields to CentOS-6.5-x86_64-minimal.iso
- Set the URL to the nearest ISO mirror. I usedhttp://mirror.leapswitch.com/centos/6.5/isos/x86_64/CentOS-6.5-x86_64-minimal.iso for CentOS 6.4 64-bit andhttp://mirror.leapswitch.com/centos/6.5/isos/i386/CentOS-6.5-i386-minimal.iso for the 32-bit version.
- Check the ‘Bootable’ checkbox
- 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
- Click OK button to start the download
- CloudStack will now start to download the ISO from the mirror. You can check the status by clicking on the ISO’s name
- Wait for the ISO download and complete registration successfully. It takes a few minutes depending on the speed of your connection
Once the ISO registration is completed, create a new instance with the ISO
Create CentOS Instance
- Click on ‘Instances’ and ‘Add Instance’. Select ‘ISO’ button and click‘Next’
- 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’.
- Select a ‘Compute Offering’ and click ‘Next’. A 1vCPU/512MB offering is what I have used
- Choose a ‘Data Disk’ offering. I have used a 20GB disk
- Choose defaults for ‘Affinity’ and ‘Network Offering’
- 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 identificationIn my environment, I end up with 4 golden instances per OS. So for CentOS 6.5, it’s centos65-xen32, centos65-xen64, centos65-kvm32 andcentos65-kvm64 instances
- Wait for the instance to start ‘running’. Takes a few seconds depending on the performance of your CloudStack IaaS infrastructure
- Click on the running instance ‘centos65-xen64’ for additional details
Once the instance is running, connect via the console and complete the installation
Install CentOS
- Connect via the console. You would have the Anaconda install screen waiting for you to start the installation. Skip the disk check.
- CentOS Language Selection. I chose ‘English’
- CentOS keyboard selection. I chose ‘US’ default
- CentOS detects the 20GB Virt-IO based data disk. Re-Initialize all disks
- 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 later
- 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.
- Use the entire 20GB disk vda
- Write changes to the disk. The installer would now partition and format the disk.
- Wait for the package installation to complete. Might take a few minutes depending on your infrastructureSince we are using the minimal CentOS install ISO, you wont be prompted for manual package selection
- Reboot once the install completes
- Detach the ISO from the instance. You might want to do it very quickly before the OS completes the reboot
- Reboot the instance with a console ctrl-alt-del if it happens to be stuck in the installer screen (since we detached the ISO)
- centos65-xen64 would now boot and present you with the login prompt
- Finally, login as ‘root’
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
- Login as root via console
- Update file /etc/sysconfig/network-scripts/ifcfg-eth0 as below and reboot the instance. I use the vi editor for editing files.12345
DEVICE=eth0
Type=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=dhcp
- Reboot the instance1
[root@localhost ~]# reboot
- After reboot, the hostname of the instance would have changed fromlocalhost to centos65-xen64 indicating that the networking service is running with DHCP settings.
- 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.
- 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.
- Check ICMP Pings and SSH access as root user
Our instance is now ready for use.
In the next article, we will customize and add CloudStack specific features to our CentOS template.