Sitemap

Increase & Decrease the Size of Static Partition in Linux

3 min readMar 12, 2021
Press enter or click to view image in full size

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

⭐️Create the Partition

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

Press enter or click to view image in full size
Press enter or click to view image in full size

⭐️Mount the Partition

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

Press enter or click to view image in full size

⭐️Create a New File

Press enter or click to view image in full size

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.

⭐️Unmount the Partition

Press enter or click to view image in full size

⭐️Delete the created partition

Press enter or click to view image in full size

⭐️Create a new partition of larger size

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

Press enter or click to view image in full size

⭐️Configure Filesystem

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.
Press enter or click to view image in full size

⭐️Remount the Extended partition

Press enter or click to view image in full size

⭐️Check if ‘hello.txt’ is present

Press enter or click to view image in full size

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.

⭐️Unmount the partition

Press enter or click to view image in full size

⭐️Delete the created partition

Press enter or click to view image in full size

⭐️Create a new partition of smaller size

Press enter or click to view image in full size

⭐️Configure Filesystem

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

Press enter or click to view image in full size
Press enter or click to view image in full size

⭐️Remount the Extended partition

Press enter or click to view image in full size

Finally, our job is done.

Hope it was useful.

Thank you for reading.

--

--

Archishman Ghosh
Archishman Ghosh

Written by Archishman Ghosh

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.

No responses yet