Increase or Decrease The Size Of Static Partition In Linux

Rohit Raut
4 min readDec 15, 2020

Static vs Dynamic Partition

Most of the time we use the dynamic partition. It provides a lot of flexibility. The following table show’s difference between static and dynamic partition.

Static vs Dynamic Partitioning

Let’s move towards practical

Firstly, we need to add external HD to VM

Go to VM settings → Storage

Create New HD

Go next

again Next

Give size as much as you want

The next step is to attach this newly created HD to Virtual Machine

Step1: Check and verify new HD is attached or not

command: fdisk -l

Step2: Create Partition

To create a new partition for we will use

fdisk /dev/sdc
n-->new parition
p--> primary partition
w--> to save changes in partition table

To reload drivers run a command: udevadm settle

Then format this partition using the ext4 format type.

After this, we have to mount this partition

#create folder
mkdir folder_name
#mount partition
mount device_name folder_name
#To see mount points
df -hT

Step3: To increase OR Decrease the size of a static partition

I have created a file to prove that after changing the size of my partition storage it won’t lose data.

To change the size

first, unmount the disk using

umount foldername

The Next Step is to repair the inode table i.e Clean & Scan for any corrupted files, data…etc it will remove using the command.

earlier we have formated with size 10GB and now it's 20GB we need to resize the INODE table by formation the remaining 10GB for this

run command resize2fs.

Formating meaning we are creating a new and clean INODE table. Instead of this, we are adding more +10GB in the previous INODE table using the resize2fs command.

Mount it again

Now let’s check, data is still there or not?

Let’s Decrease the size of the static partition

right now, The status of the sdc1 partition is 20GB.

The Next Step is to repair the inode table i.e Clean & Scan for any corrupted files, data.

here, I am resizing the file system to 5GB size.

Delete the old partition and create a new one with the same size as above.

now we need to check the filesystem is it ok or some errors are there so for this

e2fsck -f “device name”

f is force check

mount the device to the folder. and check for previous data and the new size of partition.

finally, we have completed the task of Increase or Decrease the size of Static Partition.

Thank you for reading!!😀

--

--