Increase or Decrease the size of Static Partition in Linux

Increase or Decrease the size of Static Partition in Linux

Hey, Everyone today we will change the size of the static partition in Linux. So, this will be a step to step guide how can you change the size of the partition and in your Linux system.

Here I will create a partition of a smaller size and then mount it to a folder and then extend it to a larger partition.

Pre-requisite:

  1. A system with Linux installed in your system.
  2. Space in your drive to which you want to extend the partition.

STEP 1: First we have to check the disk partition of the system

# fdisk -l
No alt text provided for this image

As I have a drive of 3 GiB attached to my system I will use it to create a partition of smaller space 1GiB which I will extend further.

STEP 2: Now to create a partition of 1GiB I will use fdisk command to create the partition

# fdisk /dev/<name_of_the_drive>

Then " n " to create a new partition

Then we have to enter the partition number, here the default is 1 so I will go with the default.

Now we have to select the size of the partition and from what sector it should start and at what sector it should end I will choose the default 2048 for the starting of the partition and +1G to create a partition size of 1 GiB.

Lastly, we have to press " w " and hit Enter key to write the changes.

No alt text provided for this image

STEP 3: Formatting the partition which will make the inode table for the size of 1GiB

# mkfs.ext4 /dev/<name_of_the_drive>
No alt text provided for this image

STEP 4: Create a directory where we will mount the partition

# mkdir <name_of_the_folder>
No alt text provided for this image

I have created a folder by name mount_here there I will mount the partition of 1GiB

STEP 5: Mounting the partition to the directory

First, we will run the command

# df -hT

to check all the mounting directories of the drives

No alt text provided for this image

We can see that the newly created partition is not mounted anywhere

Now we will mount the partition to the directory

# mount /dev/<drive_name> /<directory_location>
No alt text provided for this image

STEP 6: Creating data inside the directory.

No alt text provided for this image

STEP 7: Creating a partition of 2GiB

No alt text provided for this image

STEP 8: Formatting the newly created partition

# mkfs.ext4 /dev/<drive_name>
No alt text provided for this image

STEP 9: Mounting the newly created partition

First, we have to unmount the previous partition

# umount /dev/<partition_name>
# mount /dev/<partition name> /<mounting folder>
No alt text provided for this image


#

要查看或添加评论,请登录

社区洞察

其他会员也浏览了