vCloud Automation Center – vCAC 6.0 – Configuring Linux Logical Volumes (LVM) using the vCAC 6.0 Linux Guest Agent

Caution: Articles written for technical not grammatical accuracy, If poor grammar offends you proceed with caution ;-)

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

  1. 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.
  2. 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.

  3. #!/bin/bash
    DISK=sdb
    PSIZE=expr $3 - 2

    # $1 = Volume Group Name, $2 = Logical Volume Name, $3 = Partition Size of LVM

    echo -e "o\nn\np\n1\n1\n\nt\n8e\nw" | 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 utilize 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:

    1. Machine is deployed form template.
    2. Guest customization will run.
    3. Guest agent will run and execute the script as outlined in the properties.
    4. Provisioning is finished.

3 Replies to “vCloud Automation Center – vCAC 6.0 – Configuring Linux Logical Volumes (LVM) using the vCAC 6.0 Linux Guest Agent”

  1. Hey Sid, This is what exactly I was looking for. I did mimic these steps exactly but for some reason I see Machine cltest214: InstallSoftware : Failure executing script ’10_InstallSoftware.sh’ in the “Recent Events” tab. The changes are made to the machine and I do see the new volume group created as below.. I’m not a linux guy but learning as vRA is forcing me to.. 🙂

    [root@cltest214 ~] vgs
    VG #PV #LV #SN Attr VSize VFree
    centos 1 6 0 wz–n- 15.27g 0
    vg_apps 1 0 0 wz–n- 16.00g 16.00g
    [root@cltest214 ~] pvs
    PV VG Fmt Attr PSize PFree
    /dev/sda2 centos lvm2 a– 15.27g 0
    /dev/sdb1 vg_apps lvm2 a– 16.00g 16.00g

    Did you encounter anything similar?

    Pardha.

Leave a Reply