Way To Increase or Decrease The Size Of Static Partition in Linux

Akanksha Chhattri
4 min readNov 22, 2020

Hey Everyone !!!

I am here to Demonstrate How we can Increase Or Decrease the size of Static Partition. For that we need a attached storage device to OS, let we attach Hard Disk of 8 GiB to OS

To List all the storage devices attached to OS Command is :

fdisk -l

we can see the Additional H.D attached /dev/sdb of size 8 GiB

First we are going to create the partitions of disk of size 4 GiB, for that we have to follow this steps :

  1. create Physical Partition using fdisk command :

fdisk <device_name>

fdisk is a individual program for creating partitions so follow this steps to create 4 GiB partition:

In Above image : n is used to create new partition , p is used to describe the type of partition which is primary, w is to save the changes

Using lsblk command we can see the newly created partition :

lsblk

2. Format the partition.

mkfs.ext4 <device_name>

3. Mount the partition

mount <device_name> <folder>

to check the mount point of device we have a cmd

df -h

we have created the partition of 4GiB Successfully!!!

Increasing the size of static partition :

Now we will increase the size of partition /dev/sdb1 from 4Gib to 6Gib for that we have to follow some steps:

  1. unmount the partition

umount /dev/sdb1

2. Delete the previous partition and create a new partition of increased size

For example we name to increase the size of partition by 2GiB, so we are deleting the 4GiB’s partition and create the new partition of 6GiB

d is used to delete the partition and we want the data of deleted partition to be saved then its important to not to remove Signature by putting N

3. Format the increased partition which is 2GiB command is :

resize2fs /dev/sdb1

4. mount the partition again on same folder

Now we can see the partition size is increased using cmd

df -h

Decreasing the size of static partition :

Now we want to decrease the size partition from 6GiB to 3GiB for doing this we have some steps :

1 Unmount the partition

umount /dev/sdb1

2. Scan the file system using e2fsck command

e2fsck -f /dev/sdb1

3. Format partition using resize2fs command, this will reduce the size of partition. It will format only that part which is given

resize2fs /dev/sdb1 3G

4. mount the partition to folder

mount /dev/sdb1 /bhai

Now we can see the size of partition is decreases to 3GiB

Thus, we have successfully increased and decrased the size of static partition.

— — — — — — — — — — — — !!! Thank you !!! — — — — — — — — — — — —

This article comes under ARTH — the School of Technologies #Task 7.1 Special Thanks to @vimal daga sir

--

--