VMware Cloud Community
agbiront
Contributor
Contributor

Using LVM with Linux Guest Agent

I was researching how to use LVM for the Linux blueprints with the Guest Agent. I didn't find anything, actually, on how to achieve this.

But searching for the scripts inside the gugent I found one named "_30_DiskSetupLVM.sh"

I proceeded to replate the standard script with this one, so I simply renamed the script to "30_DiskSetup.sh" which is what the gugent actually calls when Customizing the VM.

It actually works!

Now when a Linux VM is created and an additional Disk is requested, it will extend the VG with the new disk. It will also mount it as requested with the filesystem formated as requested.

I don't know if this common knowledge but I hope someone find this usefull.

The only issue I have is that it extends the root VG, and does not create a new one. We usually have a second VG with all the data and one VG for the OS. We could live with two separate VGs, even though we sometimes need more than 2 VGs.

Does anyone know how to do this? Creating a second VG and adding the disks provisioned at request time to this VG would be exactly what we need.

I'll attach the script. I'm not proficient in linux nor scripting, but it looks like it lists the available VG and extend it. I don't know what would happen if there were more than 1 VG.

Thanks in advance.

Tags (2)
Reply
0 Kudos
3 Replies
eoinbyrne
Expert
Expert

We have implemented a Linux Blueprint for a customer which sets up the additional disk as a separate VG. The blueprint was cloning from a Linux template which already had LVG setup for the root disk.

To get the second disk properly setup for LVG we used the GuestAgent to run the commands (i.e., VirtualMachine.Software<N>.ScriptPath)

Commands were similar to the below

# pvcreate /dev/sdg (or whatever the device id should be)

# vgcreate extravg /dev/sdg

# lvcreate -l 20 -n uservol extravg

There should be no need to update the content of the gugent scripts here (+ this is possibly a risk to any support from VMware as you've modified the product....).

Reply
0 Kudos
agbiront
Contributor
Contributor

I thought about doing it with the Gugent running manual scripts, but it wouldn't be dynamic as the VMware script, or it would require a lot of effort.

Most of the work has alredy been done: the script that comes with the Guest Agent add the new disks to the VG, it formats the disks (ext3 or ext4), and then mount them on the path that the user requested. The user can request any number of new volumes this way.

Reply
0 Kudos
agbiront
Contributor
Contributor

Well, I've found a workaround that works fine for my needs.

I'll attach the modified script, for anyone who finds it helpful.

With this script, the Disk Label and Logical Volume name will be equal to the name of the mountpoint

/test (LV name would be 'test')

/data/volume1 (LV name would be 'volume1')

The "Label" option in the request will actually create or extend the desired Volume Group. So, if you want to create the logical volumes on a different Volume Group you simply choose the name of the VG using the "Label" string.

Reply
0 Kudos