Increase or Decrease the Size of Static Partition Without Losing Any Data

Hello everyone, today I am going to explain to you how to increase/decrease the size of the static partition without losing any data in Linux.

  1. I already have a static partition (/dev/sdb1) with some data.

The size of external storage is 8GB.

Size of static partiton (/dev/sdb1) is 4GB.

2) First I umount the attached drive using umount -l /dev/sdb1

Then we enter inside the disk using fdisk /dev/sdb

3) Now, First I am going to delete the created partition, then I create a new partition of size 6GB

4) Then, I see that our partition (/dev/sdb1) has created, we save it by pressing w.

5) Now, I am going to check the filesystem using e2fsck -f /dev/sdb1.

Then, we format the unformatted part using resize2fs /dev/sdb1

6) Now, we mount it on the pre-created folder.

Now, as we can see that our partition size has increased to 6GB.

7) Now, as we can see that our data is already there.

1 ) To decrease the size, first, we have to umount using umount -l /dev/sdb1

Then we are going to check the filesystem, using e2fsck -f /dev/sdb1 then we resize it to the 1GB by resize2fs /dev/sdb1 1G

2) Now we enter inside the disk using fdisk /dev/sdb, then we delete the pre-created partition then we create a new partition of 1GB

3) Now, here we say No to the signature.

4) Here, we see that a new partition of 1GB has created then we save it by w.

then we resize it by resize2fs /dev/sdb1

5) Here, we can see that our partition size has been decreased to 1GB and data is also present.

Conclusion

Hurray, we increased as well as decreased the static partition without losing the data inside the mount point easily.

I am a blogger. Check my blog → technicalej.in