Increase & Decrease the Size of Static Partition in Linux

For the previous blog in this series, refer — https://archis60-ag.medium.com/integrating-lvm-with-hadoop-and-providing-elasticity-to-datanode-storage-79b4d8b38e6f

First of all, we need to attach a volume (virtual hard disk) with our VM on which we will be creating partitions.

Now, let’s get going.

Initial Creation of Partition

We will create a partition of 2Gb and then we will format it.

Next, we will mount the partition to a folder called ‘fs’ that we have created on our OS.

As we see, we have created and stored a text file ‘hello.txt’.

Increase Size of Static Partition

Now, let’s see how to increase the size of this static partition.

Let’s create a new partition of a larger size. We will create a partition of 5Gb.

Now let’s run the fsck command on the filesystem & resize the filesystem with the resize2fs command.

  • The e2fsck is used to check the ext2/ext3/ext4 family of file systems.
  • The resize2fs is a command-line utility that allows us to resize ext2, ext3, or ext4 filesystems.

As we can see, the previously created file is still accessible.

Decrease Size of Static Partition

Now, let’s see how to decrease the size of this static partition.

Again, we have to run the fsck command on the filesystem & resize the filesystem with the resize2fs command.

Finally, our job is done.

Hope it was useful.

Thank you for reading.

A final year engineering undergrad with a curious mind and filled with positivity. Always open-minded, ready to learn new skills and explore new domains.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store