Increasing or Decreasing the Size of Static Partition in Linux(RHEL8). i.e. How to resize Partition on RHEL

Priyanka Hajare
4 min readNov 12, 2020

--

We know how we can extend and reduce the partitions on the fly using LVM but here I am going to show how to increase the size of static partition dynamically without losing any data.

Prerequisites :

  1. Linux O.S (in my case I have used Redhat version 8)
  2. Attach one more Hard disk (size whatever you want)

Let’s start

For this task I have root H.D of 10 GB and I have attached one more hard disk i.e. of size 12GB

We can see available disks using command : #fdisk -l

Create static Partition of attached disk.

In my case I will create first partition of size 4GB on disk named /dev/sdb

steps for creating partition.

  1. fdisk /dev/sdb: to go inside the disk
  2. n : for new partition
  3. p : for primary partition
  4. w: to save the created partition.

Now format and mount the partition.

I will format partition using following command

#mkfs.ext4 /dev/sdb1

Then I will mount that formatted partition on mount point or directory named /priyanka

#mount /dev/sdb1 /priyanka

for this I have created directory named priyanka using command

#mkdir /priyanka

  • we can see that partition has mounted by using following command

#df -h

Now create file in created folder.

In my case I have created file named static.txt inside the folder named priyanka.

Now let’s see how to increase the static partirtion

To increase the size of static partition we have to unmount and delete the created partition

Unmount the partition

I unmounted using following command

#umonunt /dev/sdb1

Now partition has unmounted we can verify also

Delete the partition

d : it is for deleting partition

w : to save the changes

Now I want to increase size of static partitions by 2Gib so I have to create new partition of 6gb

Create new partition

I will create new partition of size 6GB

In this previous we already formatted the partition1 it is asking to remove or save the ext4 signature in my case I am not removing the ext4 signature.

Here “N” is for don’t remove the ext4 signature.

and finally save the changes using #w

  • now partition of 6gb has created

Now format the extended part of partition.(Not whole new created partition )

  1. Examine filesystem for errors

command : #e2fsck -f /dev/sdb1

  1. to format the extended part :

command : #resize2fs /dev/sdb1

Again Mount the created partitions on the same folder which we created previously

and after mounting partition check by using #df -h whether size has increased or not

In my case partition has mounted of size nearly about 6GB

✅Check if previously created file i.e. static.txt is exist or not

First go inside the directory where we created file previously

#cd /priyanka

now using #ls command we can see that file static.txt is exist which I created previously before increasing partition size

We have seen that we have increased the size of previously created static partitions without losing any data

Thank you for reading !🤩🤗

Thank you Mr.Vimal Daga sir…! for teaching such teachnological things.🤩🤗

--

--