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
⭐️Create the Partition
We will create a partition of 2Gb and then we will format it.
⭐️Mount the Partition
Next, we will mount the partition to a folder called ‘fs’ that we have created on our OS.
⭐️Create a New File
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
⭐️Delete the created partition
⭐️Create a new partition of larger size
Let’s create a new partition of a larger size. We will create a partition of 5Gb.
⭐️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.
⭐️Remount the Extended partition
⭐️Check if ‘hello.txt’ is present
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
⭐️Delete the created partition
⭐️Create a new partition of smaller size
⭐️Configure Filesystem
Again, we have to run the fsck command on the filesystem & resize the filesystem with the resize2fs command.
⭐️Remount the Extended partition
Finally, our job is done.
Hope it was useful.
Thank you for reading.