Increasing or Decreasing the Size of Static Partition in Linux(RHEL8). i.e. How to resize Partition on RHEL
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.
- Linux O.S (in my case I have used Redhat version 8)
- Attach one more Hard disk (size whatever you want)
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.
- fdisk /dev/sdb: to go inside the disk
- n : for new partition
- p : for primary partition
- w: to save the created partition.
✅Now format and mount the partition.
I will format partition using following command
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
- we can see that partition has mounted by using following command
✅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
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 )
- Examine filesystem for errors
command : #e2fsck -f /dev/sdb1
- 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
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.🤩🤗