vCloud Automation Center: vCAC 6.0: Configuring Linux Logical Volumes (LVM) using the vCAC 6.0 Linux Guest Agent
More and more frequently I get asked about support for configuring LVM(Logical Volumes) in Linux guests provisioned by vCAC. The short answer is the guest
From the archive. Originally published on dailyhypervisor.com on June 19, 2014.
More and more frequently I get asked about support for configuring LVM(Logical Volumes) in Linux guests provisioned by vCAC. The short answer is the guest agent by default will partition a disk as a standard Linux partition. However because the guest agent allows us to execute scripts we can overcome this and configure LVM volumes within the guest. In this article I''m going to to walk you through just how to do that.
Using the Linux Guest Agent to config LVM
- To begin we need a working vCAC environment that can provision Linux VM''s with a working Linux Guest Agent. You can find information on all the needed topics to install and configure vCAC 6 here.
- Next we need a script that we will use to setup the LVM inside the guest Linux operating system. Below I have a very basic script for this example. This script assumed only one additional hard disk will be added to the VM. Any additional disks will not be included in the LVM.
#!/bin/bash DISK=sdb PSIZE=expr $3 - 2# $1 = Volume Group Name: $2 = Logical Volume Name: $3 = Partition Size of LVMecho -e "o n p 1 1t 8e w" | fdisk /dev/$DISK pvcreate /dev/${DISK}1 vgcreate $1 /dev/${DISK}1 lvcreate -L ${PSIZE}G -n $2 $1 mkfs.ext4 /dev/$1/$2- You can manually test the script by running it on a Linux VM with an UN-partitioned secondary disk by doing the following:
- ./lvmscript.sh {Volume Group Name} {Logical Volume Name} {Disk Size} *Note – Do not use the {}.
- Once we have a template with the guest agent installed and script included we will need to have a blueprint that can use that template. For information on how to create a vSphere Clone Blueprint.
- For the next part we can create a Build Profile that contains all the needed properties to tell vCAC to use the guest agent as well as the properties needed to execute and pass to the script. Below is a list of the properties and values that need to be put in the Build Profile.
- Property: VirtualMachine.Admin.UseGuestAgent Value: True Property: VirtualMachine.Customize.WaitComplete Value: True Property: VirtualMachine.Software0.Name Value: LVMscript Property: VirtualMachine.Software0.ScriptPath Value: (path to script on filesystem)/lvmscript.sh {Volume Group Name} {Logical Volume Name} {VirtualMachine.Disk1.Size} *Note the {} are needed here. Replace items in BOLD as part of the value with the desired names.
- *Don’t forget to add the appropriate Virtual Center GuestOS property required by vCAC. I.E. Property: VMware.VirtualCenter.OperatingSystem Value: rhel6_64Gust
- Once created attache the build profile to the blueprint that was created for the template that includes the guest agent.
- *Make sure when requesting the machine to add a second disk. This script makes the assumption that thee is only a second disk being added and will not configure any additional disks that may be added.
- What happens once a machine is requested:
- Machine is deployed form template.
- Guest customization will run.
- Guest agent will run and execute the script as outlined in the properties.
- Provisioning is finished.