Increase or Decrease the size of Static Partition in Linux

Increase or Decrease the size of Static Partition in Linux

The steps to Increase the Size of Static Partition in Linux are as follows.

Step1: Create a partition (say of 2Gb)

Step2: Format(ext4) it and mount a folder (say lw) to it

Step3: Create file and store in that partition.

Step4: Unmount folder

Step5: Delete the created partition and save the settings

 Step6: Create new partition of size bigger than that of previous one(say 4Gb)

Step7: Now use “e2fsck -f /dev/sdb1”

This command checks the filesystem(ext2,ext,3,ext4), if error is there like OS shutdown abruptly then, it will resolve it by replaying the committed transactions in the journal. Hence our transaction of creating a file will be redone. 

Step8: Now use “resize2fs /dev/sdb1”

This command format(create filesystem like ext4) the remaining volume added to the partition i.e. 4-2=2.

Step9: Now mount the previously mounted folder i.e. lw.

We will see that our previously created file and its data is present in it!!!

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

The steps to decrease the Size of Static Partition in Linux are as follows.

Step1: Create a partition (say of 4Gb)

Step2: Format(ext4) it and mount a folder (say aaa) to it

Step3: Create file and store in that partition.

Step4: Unmount folder

Step5: use "e2fsck -f " on partition(eg. e2fsck -f /dev/sdb1)

this command will basically clear all the garbage/bad blocks from inode table

Step6: use "resize2fs" command to reformat the partition with new size(say 2Gb) and not loosing the data. Basically we are just updating the inode table (eg. resize2fs /dev/sdb1 2G)

Step7: again mount the partition

We will see our data is not lost!!!

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Thank You
















To view or add a comment, sign in

More articles by Aswathy S

Others also viewed

Explore content categories