DEV Community

Salah Ud Din
Salah Ud Din

Posted on

1

Safely Extend Volume Size of VMware, Linux.

Goal:
I have a VMware, increased the size of this machine from VMware GUI but still the free space is unusable in Ubuntu machine. In this tutorial will see how we can safely extend/increase the size of partition with no space. In short we will add 18 GB of space to the 100% full partition.

We can see the Root partition is full:

df -h

Root Partitions

Let’s see available free space. We can see the total size of /dev/sda below image. So Size is changed. Linux will add this free space by itself. Now we will create another partition and then add it to the partition which is 100% full.

sudo fdisk -l

fdisk

(Optional)

sudo lsblk

lsblk

Select partition:

sda3 is partion of disk sda.

Enter root : sudo -s

fdisk /dev/sda

fdisk

Enter “m” to list all commands:

fdisk options

Enter F:
To check free space, Here we have 11G (11 GBs) free space. Unpartitioned.

Free space

Let’s create a partition,

Enter n, Press Enter after it to select default max values. We can see partition is now created.

fdisk options

(Optional) In above it new partition it already selected the “Linux filesystem”. Just in case you want to change type in future partitions.

Enter Command n:
it will select the new partition automatically, You can also specify it. Enter L for the list.

partition type

I will select option 20: Linux file system. Press q to exit list.

fdisk filesystem

now, Enter 20

fdisk filesystem

Save changes:

Enter w:
write changes.

fdisk

Reboot:

shudown -h now

Linux shutdown

SSH or login again,

We can see the new partition is added.
sudo fdisk -l

fdisk

Now, Create Physical volume: /dev/sda4

sudo pvcreate /dev/sda4

pvcreate

We can see the volume size, and free size.

sudo vgdisplay

vgdisplay

Extend:

Here we will extend, or add the new partition /dev/sda4 to VG NAME : ubuntu-vg. See the vg name in above image.

sudo vgextend ubuntu-vg /dev/sda4

vgextend

We can see the Volume size, and free space is changed but Alloc size is still same. Now we need to use this free space.

vgdisplay

sudo pvscan

pvscan

Get Lv path of this volume group:

sudo lvdisplay

lvdisplay

Time to Extend it:

+100%FREE mean use all the free space. You can also specify as much you want change command little bit sudo lvextend -L +10G /dev/ubuntu-vg/ubuntu-lv. This will extend 10Gb space.

sudo lvextend -l +100%FREE <Logical Volume path>

sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

lvextend

At this point we have increased the size of the block volume where your root filesystem resides, but we still need to extend the filesystem on top of it.

df -h

size check

Resize it:

sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

resize2fs
Now, we are good. The free space is added successfully.

df -h
size

Thank you for reading, and understanding it. I hope it have helped you. 😎

Top comments (0)

Billboard image

Try REST API Generation for Snowflake

DevOps for Private APIs. Automate the building, securing, and documenting of internal/private REST APIs with built-in enterprise security on bare-metal, VMs, or containers.

  • Auto-generated live APIs mapped from Snowflake database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️