Cloud OSS - Hyper-V Service Manager | How to Create Guest OS (Linux) Templates in Hyper-V |
---|
Table of Contents
1. Introduction
See also:
This section provides information that will assist you in creating Linux based guest OS templates in Microsoft Hyper-V, that will be used by Interworks Cloud OSS Service Manager during VM provisioning.
This guide will assist you in deploying the following operating systems:
- CentOS 6.5
- Oracle Linux 6.5
In order to follow these instructions successfully, you will need:
- Administrative access to SCVMM Server (via SCVMM Console) and permissions to the Library Objects/Share Folders.
- Adequate ISO images or CD/DVD discs containing the operating systems for the guest OS.
2. Downloading CentOS 6.5 and Oracle Linux 6.5 images
See also:
You can download the CentOS 6.5 ISO image from here. This link contains a number of mirrors with the CentOS images.
For this guide we will be using the CentOS-6.5-x86_64-bin-DVD1.ISO image (not all mirrors contain this ISO so you may need to check a couple of mirrors).
You can download the Oracle Linux 6.5 ISO image from here. You will need to register or sign-in with your existing Oracle account in order to download the ISO.
Later on,the uncompressed .ISO image will have to be uploaded to the SCVMM server where the SCVMM console is hosted.
3. Creating a Virtual Machine
See also:
The first thing we need to do in order to deploy the template is to create a Virtual Machine and install the CentOS 6.5 or Oracle Linux 6.5 Operating System. Once you have downloaded the ISO image, you may proceed with the creation of the Virtual Machine.
1) Log in to SCVMM server and open the SCVMM console. Next, click on Library tab.
Fig 1. SCVMM console Library
2) Right click on Library Servers and create a Library Server. Create a Library Share and name it ISO or choose an alternative name that you prefer.
(You may skip this step if you already have a Library Server and Library Share configured in SCVMM)
Fig 2. Creating a Library Server and Library Share
3) Select the ISO Library Share and click on Import physical resource.
Fig 3. Viewing the contents of selected Library Share
4) Click on "Add resource..." in the appearing window.
Fig 4. Adding a resource to the Library
5) Navigate to the CentOS .ISO image that you have previously uploaded to SCVMM Server and click on Open.
Fig 5. Adding .ISO image to the Library
6) Click on Browse to select the destination for the imported .ISO image.
Fig 6. Browsing for imported resource destination
7) Select the Destination Folder (Library Share) and click on OK.
Fig 7. Selecting imported resource destination
8) Click on Import.
Fig 8. Importing resource
9) Wait until the import process is finished and close the Jobs window that appears.
Fig 9. Running the import process
10) The ISO image should now appear in the folder selected in step 7.
Fig 10. Viewing the ISO image Library Share
11) You will now need to create a Virtual Machine (VM) using the uploaded image. On SCVMM console, click on VMs and Services.
Fig 11. VMs and Services
12) Click on Create Virtual Machine.
Fig 12. Creating a new VM
13) In the appearing window choose "Create the new virtual machine with a blank virtual hard disk" and click on Next.
Fig 13. Creating a new virtual hard disk (VHD) for VM
14) Type in the Virtual machine name, choose Generation 1 and click on Next.
Fig 14. VM name and generation
15) Select "Cloud Capability Profiles"
Fig 15. Cloud Capability Profiles
16) Select Hyper-V.
Fig 16. Cloud Capability profiles (Hyper-V selection)
17) Set the minimum recommended resources for running a Guest OS Template VM (1 processor / 1024 MB Memory / 10 GB hard disk).
Fig 17. Setting CPU resources
Fig 18. Setting Memory resources
Fig 19. Setting Hard Disk resources
18) In Virtual DVD Drive choose "Existing ISO image" and browse for the uploaded .ISO image on the Library Share.
Fig 20. Mounting the .ISO image
19) Select the .ISO Image to be inserted in the Virtual DVD Drive and click on OK.
Fig 21. Selecting .ISO image Fig 22. The .ISO image is selected
20) Select Network Adapter 1 and click Remove. In the appearing window, click on Yes.
Fig 23. Remove Network Adapter 1 Fig 24. Removing Network Adapter
21) Click on New -> Legacy Network Adapter to add a Legacy Network Adapter to the VM template.
Fig 25. Adding a Legacy Network Adapter
22) Select Connect to a VM Network and then click on Browse.
Fig 26. Connect Legacy Network Adapter to a VM Network
23) Select a VM Network and click on OK.
Fig 27. Selecting VM Network
24) Once you finish with Hardware Configuration, click on Next.
Fig 28. Finishing Hardware Configuration
25) In the Select Destination tab, click on Next.
Fig 29. Select Destination Tab
26) Select the Hyper-V Host on which the VM will be created in and click on Next.
Fig 30. Choosing Hyper-V node for VM
27) In the Configure Settings tab, click on Next.
Fig 31. Choosing storage location
28) In the Add Properties tab, choose CentOS Linux 6 (64 bit) on the OS drop-down list and click on Next.
Fig 32. Choosing an Operating System
29) Finally, click on Create in the Summary tab.
Fig 33. Settings confirmation and VM creation
30) Wait until the VM creation is completed and close the Jobs window.
Fig 34. VM creation in progress
31) As soon as the VM is created, it will be listed in SCVMM console as belonging to a Hyper-V Cluster and/or a Hyper-V node.
Fig 35. New VM listed
32) Click on Power On to start the Virtual Machine. Notice that the status of the VM changes to "Starting" and then "Running".
Fig 36. Start the New VM
Fig 37. VM is starting
Fig 38. VM is running
33) Click on Connect or View->Connect via Console in order to connect to the console.
Fig 39. Connect to VM via Console
34) Choose to "Install or upgrade an existing system" and press Enter.
Fig 40. CentOS initial installation screen
35) Choose whether to test or skip testing the media before installation and click on "Next" in the screen that follows.
Fig 41. Install media test dialogue box
36) In the Welcome to CentOS page, click on Next.
Fig 42. Welcome to CentOS page
37) Choose your preferred Language and Keyboard layout. Once you choose, click on Next.
Fig 43. Preferred language Fig 44. Preferred keyboard layout
38) In the Type of Devices page, select "Basic Storage Devices" and click on Next. In the pop-up window, click on "Yes, discard any data".
Fig 45. Installation devices Fig 46. Storage Device Warning
39) Enter the FQDN (Fully Qualified Domain Name) you want to use for this Virtual Machine.
Fig 47. Virtual Machine Template FQDN
40) Click on the "Configure Network" button and edit the "System eth0" network interface. Configure the IPv4 settings so that you can access the template later on.
Fig 48. Network configuration Fig 49. System etho network settings
41) Select the appropriate time zone and click on "Next". In the following screen set a "Root" password.
Fig 50. Time settings Fig 51. Setting root password
42) In the following screen select "Use All Space" and click on "Next". In the pop-up window, click on "Write changes to disk".
Fig 52. Partitioning Fig 53. Write changes to disk
43) Choose installation type (Since this is going to be a server template, we choose the "Basic Server" option). The installation process will begin once we click on "Next".
Fig 54. Installation type Fig 55. Starting installation process
44) When the installation process is over, click on "Reboot".
Fig 56. Rebooting upon successful installation
4. Preparing the Virtual Machine for Template
See also:
45) After the Reboot process is completed successfully, shutdown the Virtual Machine by logging in as root with the password you entered during the installation and run the following command:
- shutdown –h now
Fig 57. Shutting down the Virtual Machine
46) While the Virtual Machine is turned off, go to VMM console, right click on the VM and click on Properties.
Fig 58. Setting VM's Properties
47) Go to Hardware Configuration, click on the "Legacy Network Adapter" and then click on Remove in order to remove it. In the pop-up window click on Yes.
Fig 59. Removing Legacy Network Adapter
48) Click on New->Network Adapter in order to add a "Standard Network Adapter". Click on the Adapter and select Connect to a VM Network, then click on OK.
Fig 60. Adding a Standard Network Adapter Fig 61. Connect to a VM Network
49) Turn the Virtual Machine on and login as root. By default CentOS and Oracle Linux do not enable the network adapter on startup. If you run the command "ifconfig" you will only find the loopback adapter listed.
Fig 62. Running ifconfig
50) Also, by default the first adapter will be eth0. However, if we attempt to enable it by using the "ifconfig eth0 up" command we will receive a "no such device" error message as shown in the figure below:
Fig 63. Attempting to bring etho interface up
51) First, we need to update the configuration file for eth0. In order to do this, we run the following commands:
- cd /etc/sysconfig/network-scripts/
- nano ifcfg-eth0
We should receive a screen similar to the one below:
Fig 64. Updating config file for eth0
52) From the config file, remove the line that starts with HWADDR and set the value for BOOTPROTO=static. Press Ctrl-X + Y + Enter, in order to exit and save your changes.
Fig 65. Updated config file Fig 66. Updated config file is saved
53) Run the following commands in order to remove the network rules and reboot the Virtual Machine:
- rm /etc/udev/rules.d/70-persistent-net.rules –f
- shutdown –r now
Fig 67. Removing Network Rules and Rebooting the VM
54) After rebooting, run the "ifconfig" command to verify that the network is set to eth0 and an IP address is configured.
Fig 68. Verifying eth0 proper state and configuration
You may also ping a public website in order to confirm Internet connectivity.You can now proceed with the required installation/configuration of the Virtual Machine in order to prepare it for template.
55) Hyper-V backup essentials have to be added so that the Virtual Machine will be able to support Live Backup. In order to do this, run the following commands:
- curl –L –o backupessentials.tar.gz https://github.com/LIS/backupessentials/tarball/1.0
- tar –xvzf backupessentials.tar.gz
Fig 69a. Adding backup essentials to the VM
- cd LIS-backupessentials-4e3121f/hv/hv-rhel6.5/rpm/
- chmod +x install.sh
- ./install.sh
- Reboot
Fig 69b. Adding backup essentials to the VM
56) Install the key/value pair (KVP) infrastructure, by running the following command:
- yum install hypervkvpd
When the "Is this ok" question pops up, type "y" and press Enter.
Fig 70a. Installing KVP Fig 70b. Installation of KVP is complete
Accordingly install libvirt, which is the API for managing platform virtualization, by running the following command (when the "Is this ok" question pops up, type "y" and press Enter):
- yum install libvirt
Fig 70c. Installation of libvirt is complete
57) Download the Hard disk extend scripts on your Workstation from here. Unrar the file and extract the scripts to a destination of your preference.
Fig 71. Downloading the Hard disk extend scripts
58) Run the WinSCP or any other SCP client tool. Browse to the destination where you saved rc.local file on your Workstation. Select the file and click on Upload.
Fig 72a. Open WinSCP Fig 72b. Uploading rc.local file
59) Copy and overwrite the rc.local file from the CloudWorks-Linux-ExtendScripts folder to the /etc/ directory on the Linux Operating System. At the Upload pop-up window, type "/etc/" in the remote directory field and click on OK. On the Confirm pop up window click on Yes.
Fig 73a. Copying rc.local Fig 73b. Overwriting rc.local
60) Grant executable permissions to the new rc.local file by running the following command:
- chmod +x /etc/rc.local
Fig 74. Granting executable permissions to rc.local
61) Copy the disk_extend_script1.sh and the disk_extend_script2.sh under the /etc/rc.d/init.d/ directory of the Linux Operating System and grant executable permissions to the scripts by using the following commands:
- chmod +x /etc/rc.d/init.d/disk_extend_script1.sh
- chmod +x /etc/rc.d/init.d/disk_extend_script2.sh
Fig 75a. Upload the disk extend scripts Fig 75b. Copying the disk extend files to /etc/rc.d/init.d/
Fig 75c. Granting executable permissions to the disk extend scripts
62) Remove the wtmp reboot counter with the following command:
- rm –rf /var/log/wtmp
Fig 76. Removing wtmp reboot coonter
63) Add the SCVMM Guest Agent. You can find the SCVMM Agent inside your SCVMM Server under the folder C:\Program Files\Microsoft System Center 2012 R2\Virtual Machine Manager\agents\. You have to find the scvmmguestagent.1.0.2.1014.x64.tar and the install.sh. Copy them on your Virtual Machine with the WinSCP client tool and install them by using the following commands:
- cd /the/directory/you/copy/the/agent/and/the/shell/script
- chmod +x install.sh
- ./install.sh scvmmguestagent.1.0.2.1014.x64.tar
Fig 77a. Adding SCVMM Guest Agent to VM Fig 77b. SCVMM Guest Agent successfully installed
64) The last step before creating the template is to clear network rules once more, so that the new adapter from the Cloud OSS provisioning platform will be added as eth0. In order to do this, run the following command:
- rm /etc/udev/rules.d/70-persistent-net.rules –f
Fig 78. Clearing network rules
65) Shutdown the Virtual Machine by running the following command:
- shutdown –h now
Fig 79. Shutting down VM
5. Creating the Template
See also:
66) In SCVMM console right click on the CentOS-6.5-for-Template VM and choose Create -> Clone.
Fig 80. Creating a clone VM
67) In the Identity tab, Specify machine name for this VM clone and click on "Next".
Fig 81. Specifying clone machine name
68) In the Configure Hardware tab click on Availability below Advanced and check the "Make this Virtual Machine High Available" option. Click on Next
Fig 82. Turning on high availability
69) In the Select Destination tab, select "Place the virtual machine on a Host" and choose your host cluster or standalone server. Click on Next.
Fig 83. Placing the VM on a host Fig 84. Selecting Host
70) Set all other options to default and click on "Create" at the end of this wizard. Wait for the cloning process to be completed.
Fig 85a. Selecting Path Fig 85b. Selecting Network
Fig 85c. Adding Properties Fig 85d. Creating VM clone
Fig 85e. Cloning process
71) Once the VM clone is created, right-click on it and click on Properties.
Fig 86. VM Clone Properties
72) Go to the Hardware Configuration tab, click on the Hard Disk and copy the file location address of this VHD.
Fig 87. Copy VHD location
73) Open File explorer and paste the Iocation of the VHD file of the Virtual Machine. Copy the VHD file.
Fig 88. Copy VHD file
74) Go to VMM, click on Library, then right-click on the Library main folder and click on Explore.
Fig 89. Explore VMM Library
75) Select a Library location and paste the VHD file you copied in step 73.
Fig 90. Paste VHD file
76) Select Library in SCVMM console on the bottom left. On the upper left of the SCVMM console, right click on Templates and choose "Create VM Template".
Fig 91. Creating a VM Template
77) In the Select Source tab, choose "Use an existing VM template or a virtual hard disk stored in the library" and click on Browse.
Fig 92. Selecting source for the new VM Template
78)Select the VHD file you pasted in step 75. Click on OK and then click on Next.
Fig 93. Selecting VHD file from the Library
79) In the Identity tab, specify VM template's name, choose Generation 1 from the drop-down list and click on Next.
Fig 94. Specifying VM Template name and Generation
80) In the Configure Hardware tab, in Cloud Capability Profile section, check Hyper-V.
Fig 95. Select Cloud Capability Profile
81) Set Memory to at least 1024 MB and click on Next.
Fig 96. Specify VM Template Memory
82) In the Configure Operating System Settings tab, select "linux os profile" for "Guest OS profile" and select "CentOS Linux 6 (64 bit)" for "Operating system", in the dropdown menu (for Oracle Linux select "Oracle Linux 6 (64 bit)"). Click on Next.
Fig 97. Specify Operating system
83) In the Select Library Server tab, select the appropriate library server and click on Next. In the Select Path tab, click on Browse to select the path on the Library Server to save the template and click on Next.
Fig 98. Selecting a library to place the VM template Fig 99. Selecting the path to place the VM template
84) View your "Summary" configuration settings and click on "Create".
Fig 100. Creating a VM Template
85) Congratulations! Your Guest OS (Linux) template has been created. You may proceed with creating the Windows Guest OS Templates in Hyper-V for your Cloud Servers.
See also: