Increase or Decrease the Size of Static Partition in Linux

Increase or Decrease the Size of Static Partition in Linux

Step1: Attach a New Hard disk.

image.png We can also verify by fdisk -l command
image.png

Step2: Create a partition in the new hard disk.

Here the new harddisk is /dev/sdb image.png verify using lsblk command
image.png

Step3: Format the newly created partition.

image.png

Step4: Mount the Partition

image.png It is good practice to verify using df -hT command

Step5: Create a file in the mounted directory

image.png

Increasing the size of the static partition

Step6: To Increase the size of the static partition, First unmount the Partition.

image.png

Step7: Now delete the partition which was previously created.

image.png

Step8: Create a new partition.

image.png Make sure to not remove the signature so that the previous data remains in that partition.

Step9: Use e2fsck command to examine file-system errors.

image.png

Step10: Reformating the disk using resize2fs cmd.

image.png

Step11: Now, again just mount the partition on the same folder.

image.png Hence, we have increased the size of the static partition from 5GiB to 9GiB. image.png And our file is also present there image.png

Reducing the size of the static partition

Step1: Unmount the partition from the folder

image.png

Step2:For reducing the size, we must resize the partition size from 9GiB to 5GiB. While reducing the size of the partition we do not have to delete the partition.

image.png

Step3:Again mount the directory with that partition to use it and we can see that our file is still present there.

image.png Congratulations, you have learned successfully how to Increase or Decrease the Size of Static Partition in Linux