Increase or Decrease the Size of Static Partition in Linux.

Deepak
Nov 13, 2020

--

Everyone think that a static partition cannot be increased but there's a trick to do it

So here I'm gonna use REDHAT operating system you can use any Linux as per your convince .

so I have attached a HDD named as /dev/xvdb

I'm gonna create a partition of 5GiB. To know how to make a partition in HDD attached you can follow this link

to use it now we have to format so that it make a FileSystem with help of mkfs command

I made ext4 filesystem you can use any and mounted it to static named directory

To check its mounted or not you can use df command. you will seeits mounted .

Here I made file mac.txt and wrote hello inside the file. Now remember the file name and the content inside.

we will unmount the partition using command

umount /dev/xvdb1

now we deleted the earlier partition and created a new partition of increased size 10GiB . Now if you know we cannot run the mkfs command because it will create a new inode table and we will lose our data and we could also not directly mount it to the directory because it needs a FileSystem. Now what we do??

we use e2fsck command to fix our inode table that will make our file available back again

e2fsck -f /dev/xvdb1

it will prompt you with y to fix it

after this just mount to the directory and you will see your file is still there

you can see the file content is still there “hello”

--

--

Deepak
Deepak

Written by Deepak

RHEL8 | AWS | Ansible | Docker| K8s | Jenkins

No responses yet