Preparing Oracle Linux VHD for Windows Azure Cloud
At the time of this writing (December, 2013) Windows Azure supported Linux distributions from Canonical (Ubuntu), Open Logic (CentOS), SUSE (SUSE Linux Enterprise), Open SUSE and Oracle Linux. However no documentation existed for preparing your own VHD on-premise and use it as a base for VM creation on Azure.
This process should also work for Red Hat Linux; however, it is not supported on Windows Azure IaaS
This process was used for Oracle Linux 6.4, Linux Integration Components 3.4 and Windows Azure Agent 1.3.3-1. The steps listed below assumes your familiarity with Hyper-V and Linux:
1. Download Oracle Linux from https://edelivery.oracle.com/linux, create VM on Hyper-V, attach the ISO file and install the OS on the VM.
2. Set up networking so that DHCP will provide the IP address, DNS and the gateway information
a. Uninstall NetworkManager by running the following command: Rpm –e –nodeps NetworkManager
[ignore the error if the NetworkManager is not installed in the first place]
b. Create “/etc/sysconfig/network” file with the following content:
NETWORKING=yes
HOSTNAME=localhost.localadmin
c. Create Ethernet adapter by creating the file “/etc/sysconfig/network-scripts/ ifcfg-eth0” with the following content:
DEVICE=eth0
ONBOOT=yes
DHCP=yes
BOOTPROTO=dhcp
TYPE=Ethernet
USERCTL=no
PEERDNS=yes
IPV6INIT=no
d. Enable the “network” service through the following command
chkconfig network on
3. Edit “/etc/grub.conf” to add “console=ttyS0 rootdelay=300 vga=813” to the kernel boot entry
If you have multi-boot setting, pick the right entry in the list. Following is the example:
Default=1
title Oracle Linux Server Unbreakable Enterprise Kernel (2.6.39-400.17.1.e16uek.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.39-400.17.1.e16uek.x86_64 [… entries omitted for brevity …] numa=off console=ttyS0 rootdelay=300 vga=813
initrd /initramfs-2.6.32-358.e16.x86_64.img
title Orcale Linux Server Red Hat Compatible Kernel (2.6.32-358.e16.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-358.e16.x86_64 [… entries omitted for brevity …] numa=off console=ttyS0 rootdelay=300 vga=813
initrd /initramfs-2.6.39-400.17.1.e16uek.x86_64.img
[Note that the Oracle Linux installs UEK kernel as the default boot option; I changed it to Redhat compatible kernel as this is the closest cousin to the endorsed CentOS distro. Make sure to edit /etc/sysconfig/kernel to remove _uek prefix. Check the blog https://blogs.technet.com/b/gbanin/archive/2013/04/02/how-to-install-oracle-linux-6-update-3-on-hyper-v-2012-with-lis-3-4.aspx for details.]
4. Download WALinuxAgent-1.3.3-1.noarch.rpm from OpenLogic using the command
[Since CentOS and Oracle Linux are compatible, the waagent downloaded from OpenLogic works on Oracle Linux]
5. Install Linux Integration Components on the VM [this step is not necessary for Oracle Linux 6.4]
Note that once you install Linux Integration components you will not be able access any attached ISO files inside the Hyper-V run VM. See https://support.microsoft.com/kb/2600152 for the problem description. For this reason, copy any RPMs you needed later into the VM. Download the version 3.4 of Linux Integration Services (the ISO can be downloaded from https://www.microsoft.com/en-us/download/search.aspx?q=linux%20integration%20services)
a. Download LinuxICv34.iso from https://www.microsoft.com/en-us/download/details.aspx?id=34603.
b. Add the iso file as a DVD drive
c. Mount the “cdrom” and execute RHEL3/INSTALL.SH
d. Shutdown the VM using the command “shutdown –h now”
6. Add an internet connected network adapter through the VM’s Hyper-V settings and restart the VM from Hyper-V Manager
7. Install python-pyasn1 as “waagent” depends on it. Use the command “yum install python” for this.
8. Install “openssl” and “openssh” using the command “yum install openssl” which will install “openssh” along with “openssl”
9. Install WALinuxagent-1.3.3-1.noarch.rpm using the command “yum localinstall WALinuxAgent-1.3.3-1.noarch.rpm”
10. Run the following command sequence to deprovision the VM (equivalent so sysprep of Windows):
waagent –force –deprovision
export HISTSIZE=0
logout
Since user information is removed, shutdown the VM from the Hyper-V toolbar of the VM
11. Upload the VHD to Windows Azure Storage using the following Powershell command:
Add-AzureVhd -Destination https://<your_storage_account_name>.blob.core.windows.net/vhds/oralinux64.vhd -LocalFilePath <e.g. C:\vhds\Oracle_Linux_6_4.vhd> -NumberOfUploaderThreads 5
12. Follow the sequence below to create an “image” from the uploaded VHD on the portal:
VIRTUAL MACHINES (left hand nav bar) --> IMAGES (top tool bar) --> CREATE (footer
You have to give the full URL of the vhd file name stored on the Azure storage account during the image creation. Upon successful creation, the image is available for VM creation using the menu sequence “VIRTUAL MACHINES --> NEW (footer) --> FROM GALLERY (popup) --> MY IMAGES (wizard)
The Resources
Technorati Tags: Oracle Linux,Linux,Red Hat,Azure,Windows Azure,IaaS,Windows Azure Virtual Machines,cloud,cloud computing
Comments
- Anonymous
December 12, 2013
Thanks for great post, really useful one!