VMware Cloud Community
kilavan
Contributor
Contributor

[Complete Guide] How to Increase space on Linux vmware

The steps below is taken from : Extending partitions on Linux VMware virtual machines | TechRepublic . To view the pictures mentioned in the step, please go to the site, i have modified the step from that site, as some steps were not clearly explained and missing:

  1. Shutdown the VM
  2. Right click the VM and select Edit Settings
  3. Select the hard disk you would like to extend
  4. On the right side, make the provisioned size as large as you need it
  5. Click OK
  6. Power on the VM
  7. Connect to the command line of the Linux VM via the console or putty session
  8. Log in as root
  9. The fdisk command provides disk partitioning functions and using it with the -l switch lists information about your disk partitions.  At the command prompt type fdisk -l
  10. The response should say something like Disk /dev/sda : xxGB. (See Figure A)
  11. At the command prompt type fdisk /dev/sda. (if dev/sda is what was returned after step 10 as shown in Figure A)
  12. Type p to print the partition table and press Enter (also shown in Figure A)
  13. Type n to add a new partition
  14. Type p again to make it a primary partition
  15. Type: 3 (partition number)
  16. Type: t (type)
  17. Type the default numbers you see on the line. in other words select default first available cylinder to the default last cylinder. In Figure A the default last is 2610 so you type 2611 in that case.
  18. Type 3 (partition Number)
  19. Type: 8e (set type to LVM)
  20. Type w to save these changes
  21. reboot
  22. Log back in as root
  23. At the command prompt type fdisk -l. You’ll notice another partition is present.  In Figure B it is listed as sdaX.
  24. Type: pvcreate /dev/sdaX (where X i the number you see on step 23. to initialize this new partition as a physical volume s
  25. Now you’ll add the physical volume to the existing volume group using the vgextend command. First type df -h to find the name of the volume group.  In Figure C, the name of the volume group is vg_root (for me it was: . Now type vgextend [volume group] /dev/sdaX. (ex: vgextend vg_root /dev/sda4). in my case it was something like: vgextend VolGroup00 /dev/sda3
  26. Type: lvextend -l +100%FREE /dev/VolGroup00/LogVol00 to Extend the logical volume
  27. Type: resize2fs -p /dev/mapper/VolGroup00-LogVol00 to expand the ext3 file system in the logical volume
  28. You can now run the df command to verify that you have more space–df -h

Thats all Smiley Happy

Ref:

VMware and LVM – Increasing disk space within a Linux-based virtual machine | Jared Evans ...

http://www.techrepublic.com/blog/smbit/extending-partitions-on-linux-vmware-virtual-machines/286

6 Replies
muddin
Contributor
Contributor

It works fine.

Reply
0 Kudos
sh1sh1n11
Contributor
Contributor

Thank you so much @kilavan! It (still) works!

Reply
0 Kudos
thepiethief
Contributor
Contributor

I appreciate this article was written a long time ago but some of the steps appear to need updating.

In step 25 i did not see the Volume Group name with df. Instead i found a command called vgdisplay which showed it was called 'turnkey' in my case.

I would suggest seperating the two commands in step into two different numbered actions. i.e. 

25a Run vgdisplay and note Volume Group name

25b vgextend <Volume Group name> <Partition name> eg. vgextend turnkey /dev/sda3

Reply
0 Kudos
thepiethief
Contributor
Contributor

Also in step 26 it is not clear how you found the VolGroup name. What i did was ls /dev/mapper/turnkey* (i.e. the Volume Group) and found there was a /dev/mapper/turnkey-root and /dev/mapper/turnkey-swap_1. I used the turnkey-root at it worked

Reply
0 Kudos
Promenak
Contributor
Contributor

Hi,
when I do the step 8, /dev/sda does not show up and when I do the step 11, it throws an error:
This disk is currently in use - repartitioning is probably a bad idea. It's recommended to umount all file systems, and swapoff all swap partitions on this disk.

How can I fix this?

Tags (1)
Reply
0 Kudos
jihwang
Contributor
Contributor

Thanks for the guide. I just googled around and found this page on top.

After reading your post, considering it's written in 2013 (now is 2024), it was best practice back then.

But I would like to suggest my method.

TDLR: if anyway you have to reboot, I would boot to ubuntu live cd, then use "gparted" to resize the partition.

Details.

1. Up to step 5, it's same.

2. boot using ubuntu installer CD, choose (I just want to try ubuntu) - This will let you use gui environment.

3. Once the desktop appears, find gparted in the apps.

4. select the disk, use the handle to extend the size of your partition.

5. save & apply & reboot to your original disk.

 

Reply
0 Kudos