How to resize/increase VMWare Hard Drive (HD) of an existing virtual machine/vm
How to resize/increase VMWare Hard Drive (HD) of an existing virtual machine/vm.
In this example we are using RedHat 6 and VMWare ESX 5.1. we actually used the paid for esx but it should work in ESXi no problem. The HD was ext4
1. Shut down the VM
2. Resize the volume using VSphere. The size field is greyed out if there are any snapshots defined so make sure to delete them.
3. Start the virtual machine
4. Run #cfdisk to create a new logical partition. Once you run this a gui type interface will run so just allocate the free space and make sure you enable it for boot.
5. Reboot the VM
6. Create a physical volume:
# pvcreate /dev/sda3
Physical volume “/dev/sda3” successfully created
If you are not sure what sda you are using you can run #fdisk –l
7. Use lvdisplay to look up the name of the volume group currently in use:
— Logical volume —
LV Name /dev/mongo1/root
VG Name mongo1
LV UUID wi9dRo-fS0C-xSCd-fbei-el9R-llBn-0QEiIR
LV Write Access read/write
LV Status available
# open 1
LV Size 15,29 GiB
Current LE 2379
Read ahead sectors auto
– currently set to 256
Block device 251:0
8. Add the physical volume to the volume group found in the field ‘VG Name’:
# vgextend mongo1 /dev/sda6
Volume group “mongo1” successfully extended
10. Now you can try to extend the existing logical volume (as named in field ‘LV Name’ above). If the given size increase (20GB in this example) is more than is available in the disk group, the error message will indicate the number of blocks available:
# lvextend -L +20G /dev/mapper/mongo1-root
Extending logical volume root to 29,29 GiB
Insufficient free space: 5120 extents needed, but only 5119 available
Retry with the number of blocks taken from this error message:
# lvextend -l +5119 /dev/mapper/mongo1-root
Extending logical volume root to 29,00 GiB
Logical volume root successfully resized
11. Resize the filesystem:
# resize2fs //dev/vg_templaterhel6/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at //dev/vg_templaterhel6/lv_root is mounted on /; on-line resizing required
old desc_blocks = 3, new_desc_blocks = 8
Performing an on-line resize of //dev/vg_templaterhel6/lv_root to 30476288 (4k) blocks.
The filesystem on //dev/vg_templaterhel6/lv_root is now 30476288 blocks long.
Filesystem Size Used Avail Use% Mounted on
115G 2.7G 106G 3% /
12. After this run #df –h and see that your boot partition increased
In addition to being the premier Denver Computer and IT services organization in Denver we also try to help out the IT community. We at NOYNIM hope to give back to the community our experience to help mentor other companies and individuals in providing high end technical services.
Please provide us feedback if these articles are helpful for you.