Big Data Hadoop & Spark

How to Increase Memory on VMWare Virtual Machine

VMWare Virtual Machine

We all get out of memory after using the VM for some time. If it is true, you are at right place. VM is short form of Virtual Machine in which is a software build to run multiple Operating systems inside existing operating system. It shares the same physical hardware of primary OS and gives the user to experience the multiple platforms in a single shot. In this blog, we will show you, how to increase primary memory in centOS running inside VMware Virtual Machine.
Sometime after installation of VM. IF you are a frequent user of VM, you will generate a lot of data inside VM. And at some point later you will be out of storage memory.
Recently I faced the same and following is the solution to it. If you follow the exact 8-steps you can fix your query within minutes.
Let’s start with VM settings.Refer the below screenshot. Go to the settings and click on HardDisk. Now find Expand option and click on it.
We also see the capacity section which gives information like current size of OS, maximum size,


We will see a window prompt with the option to increase the size. Press up arrow to increase size.
Do not increase a lot at once. As it will take a lot of time to convert the primary memory to virtual memory.Then hit Expand. My recommendation is 15GB, in my case have done 30 GB.
You can increase anytime you want later again.

Once the expansion finishes. We will find a prompt message displayed below:

Now we can see the virtual maximum memory increased in the settings.

Now boot the OS and login to root user. If not in root user you can switch inside with below command.



[[email protected] ~]$ su
[[email protected] acadgild]#

Once in root user, give below command followed by few options. Please NOTE all commands are listed in red color. Give the exact options shown below respectively.

[[email protected] acadgild]# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It’s strongly recommended toswitch off the mode (command ‘c’) and change display units to sectors (command ‘u’).
Command (m for help): n
Command action
e extended
p primary partition (1-4)
Partition number (1-4): 4
First cylinder (2611-6657, default 2611):(press enter)
Using default value 2611(press enter)
Last cylinder, +cylinders or +size{K,M,G} (2611-6657, default 6657):
Using default value 6657
Command (m for help): t
Partition number (1-4): 4
Hex code (type L to list codes): 8e
Changed system type of partition 4 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
[[email protected] acadgild]#

Once Over with this step, you OS will recognize the memory. Hence needed a reboot.


Again after login come to the root user. Follow the commands listed below to see the details for your memory.

[[email protected] ~]$ su
[[email protected] acadgild]# fdisk -l
Disk /dev/sda: 54.8 GB, 54760833024 bytes
255 heads, 63 sectors/track, 6657 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000bb81e
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2611 20458496 8e Linux LVM
/dev/sda4 2611 6657 32500832+ 8e Linux LVM
Disk /dev/mapper/VolGroup-lv_root: 18.8 GB, 18798870528 bytes
255 heads, 63 sectors/track, 2285 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_swap: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


We will increase the volume group so to include the new physical volume we created.

[[email protected] acadgild]# pvcreate /dev/sda4
Physical volume “/dev/sda4” successfully created


Now we will see how much space we have free in the volume group.

[[email protected] acadgild]# vgextend VolGroup /dev/sda4
Volume group “VolGroup” successfully extended


We can check the free space with the below command.
Note: the option free is in uppercase F. lowercase won’t work.
The result means there is 30.99 GB or 7934 extends free. This will vary from the system to system.

[[email protected] acadgild]# vgdisplay | grep Free
Free PE / Size 7934 / 30.99 GiB


This step includes extending of the logical volume.
Note: the command has option L in lower case, many make mistake by taking as 1(one).
Note: The numbers after -l is the exact same number we got by the previous command.will vary system to system.

[[email protected] acadgild]#  lvextend -l+7934 /dev/VolGroup/lv_root
Size of logical volume VolGroup/lv_root changed from 17.51 GiB (4482 extents) to 48.50 GiB (12416 extents).
Logical volume lv_root successfully resized.


Now we will stretch/resize the filesystem to include the new space.And we are done already.

[[email protected] acadgild]# resize2fs /dev/VolGroup/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 4
Performing an on-line resize of /dev/VolGroup/lv_root to 12713984 (4k) blocks.
The filesystem on /dev/VolGroup/lv_root is now 12713984 blocks long.

This last step will verify we have done things correctly.

[[email protected] acadgild]# df -h
Filesystem         Size  Used Avail Use% Mounted on
48G   17G   29G  36% /
tmpfs              939M  228K  939M   1% /dev/shm
/dev/sda1          477M   79M  373M  18% /boot
.host:/            932G  237G  696G  26% /mnt/hgfsl

We can see the total memory by adding various nodes inside CentOS is aprox 50 GB. Few extra memory is reserved as security.
To leave the root user.
[[email protected] acadgild]#exit
Now are done with the extending the OS memory inside VM. Keep visiting for more trending technical blogs.


An alumnus of the NIE-Institute Of Technology, Mysore, Prateek is an ardent Data Science enthusiast. He has been working at Acadgild as a Data Engineer for the past 3 years. He is a Subject-matter expert in the field of Big Data, Hadoop ecosystem, and Spark.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Articles