Increasing or decreasing static partition size in Linux
Increasing or decreasing static partition size in Linux
1. Create a static partition. Here I have created a partition of 5Gb.
2. Now, create a partition. Here I am creating a sub-partition of 1Gb.
3. Now, format and mount the partition.
I am creating a folder with the name static and mounting the partition sdd1 to it.
mkfs.ext4 /dev/sdd1--> For formatting
mkdir /static
mount /dev/sdd1 /static --> For mounting
4. Now, Create a file in /static.
Go to static using cd /static.
5. In order to increase the size of a static partition, we need to unmount it and also delete the existing partition.
unmount /dev/sdd1 --> For unmounting
fdisk /dev/sdd1
and then use 'd' for deleting the partition and 'w' to save the changes.
6. Create a new partition and enter the desired size you want the partition to have.
I am not entering any size here, So it will take all the 5Gb from the partition I created of 5Gb i.e., /dev/sdd
7. Here, we can clearly see that the size is now 5Gb.
10. Now, check if the previously created file exists or not.
To check the file, go to cd /static -->ls -->cat file.txt
11. In the above following we have increased the size of the static partition, to decrease we need to follow the same step until resizing.
Here, I am reducing my size to 3Gb.
So, I have to use the following commands in order to achieve that.
e2fsck -f /dev/sdd1--> To examine the filesystem
resize2fs /dev/sdd1 3G
In the above command of resizing, 3G means to resize the inode table for the size of 3Gb partition.
12. Now, again delete the existing partition, create a new partition of 3Gb, save the changes.
Comments
Post a Comment