What is the easiest and cleanest way to increase hard drive space on a Linux virtual machine when LVM is being used?
You could try using http://gparted.sourceforge.net/ after backing up the VM of course.
gparted can't expand LVM disks only non-LVM
Hello,
Check out this link http://vsphere-land.com/tips-tricks/re-sizing-virtual-disks
May help.
Good Luck
This is great info although I don't think any of the methods described at that link apply when LVM is being used though....
You can add space to the disk by editing the VM and increasing the VMDK size. You should then be able to use the LVM tools within the OS to modify the volume.
You can use the tools inside the OS to expand the logical volume, but you can't expand the partition on which the logical volume sits. For example if my logical volume is on dev/sda3, then I have to create a new partition, dev/sda4, add it to the volume group and then expand to include that space. I can't just expand the sda3 partition to include the new size I just added to the virtual disk using "edit settings" on the VM. If I had not used LVM, I could use gparted or another tool to expand sda3 partition to fill the newly expanded virtual disk. If you keep having to add space periodically, you don't want to keep adding more partitions every time you need more space in your logical volume.
Hello,
Two ways exist to extend a volume when LVM is in use. But first answer this question:
Are you comfortable with your backup?
Then:
1) In vSphere change the size of the VMDK to be greater
2) In vSphere add a new VMDK/RDM/vRDM to the VM <=== Recommended over the other if this is the boot volume
Now from within the Linux VM:
1) create LVM partitions on the volumes for all the free space of the virtual disks
2) Use your favorite LVM tool to add the newly created partitions to your LVM volumes.
I use RHEL so use fdisk or gparted then use system-config-lvm but you can also use pv*, lv*, vg* commands as well.
It also may be possible to use vConverter but I have not tested this.
Best regards,
Edward L. Haletky
Communities Moderator, VMware vExpert,
Author: VMware vSphere and Virtual Infrastructure Security,VMware ESX and ESXi in the Enterprise 2nd Edition
Podcast: The Virtualization Security Podcast Resources: The Virtualization Bookshelf
I use the tools inside the OS to expand the logical volume and with all the suggested solution, I sorted everything. I have no difficulties so far and I am looking forward to maintain my performace until the next upgrade
HI ,
Please take the backup priort to increase virtual disk .
This tool is from VMware. It is used for Virtual-disk and VMFS management.
Be aware, always use Virtual Center GUI to create VMFS Volumes. Otherwise you will end up with an unaligned VMFS partition and decreased performance.
vmkfstools VM-Disk and VMFS Management in the console |
vmkfstools -X Extend virtual Disk vmkfstools -X 12G ./testing.vmdk To extend an existing Virtual Disk to 12GB. Instead of G you can use M for Megabytes
vmkfstools -X 4G ./testing.vmdk --force For shrinking on ESX 3.0x use the VMWare Converter (download from the VMware Website for freee). Point the source and destination to the same ESX Host. If you receive an error one parameter was incrorrect the size might be smaller as the original size! If you have blanks in the file or directoryname, mask the full path with ' |
vmkfstools -i To export or clone a virtual disk from VMFS Example: Copy from one vmfs to another: Source=/vmfs/volumes/esxpublic/testvm2.vmdk vmkfstools -i /vmfs/volumes/esxpublic/testvm2.vmdk /vmfs/volumes/production/testvmnew2.vmdk Export to ext3 partition: Source=/vmfs/volumes/esxpublic/testvm2.vmdk vmkfstools -i /vmfs/esxpublic/testvm2.vmdk -d 2gbsparse /vmimages/testvm2.vmdk |
vmkfstools -E Rename files associated with a specified virtual disk
|
vmkfstools -U Delete Virtualdisk |
vmkfstools -c 4000M ./file.vmdk To create a new empty virtual disk vmkfstools -c 300G -a lsilogic /vmfs/volume/vmfslabel/directory/newdisk.vmdk or in current directory vmkfstools -c 300G -a lsilogic ./newdisk.vmdk This command is very useful because you can use user-friendly names for the disks |
Thanks & Regards,
BSR Krishna