Increasing or Decreasing the Size of Static Partition in Linux [RHEL8] .i.e. How to resize Partition on RHEL

Increasing or Decreasing the Size of Static Partition in Linux [RHEL8] .i.e. How to resize Partition on RHEL

Previously I shared with you how you can reduce or extend the partition using LVM. 

Here I am going to show how to increase the size of the static partition dynamically without losing any data. Firstly I have attached the 6 GB hard disk and I already had 10 GB.

We can see this using fdisk -l command.

No alt text provided for this image

Step1: We have to create partition of disk /dev/xvdf (6GB). The steps that need to follow are:

  1. fdisk /dev/sdb: to go inside the disk
  2. n : for new partition
  3. p : for primary partition
  4. w: to save the created partition.
No alt text provided for this image

Step 2: We can use the lsblk command to list the information of blocks. The next step is to format the partition

Command:- mkfs.ext4 /dev/xvdf1

No alt text provided for this image

Step 3: Create Directory task and mount it to disk /dev/xvdf1

Command: mount /dev/xvdf1 /task

No alt text provided for this image

Step 4: Creating a file name staticfile.txt. The file size is 184M.

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

Now We have to Increase the size of static partitions without losing our data of staticfile.txt

?? Increase The Size ??

Step 1: Unmount the partition. Command: umount /dev/xvdf1 /task

No alt text provided for this image


No alt text provided for this image




?Step 2: Delete the Partition

d: it is for deleting partition

w: to save the changes

No alt text provided for this image

Step 3 :

Increase The Partition with 5GB. Here you will come in front of concept File Signature.

File Signature or Magic Number is a protocol set of constant numerical and text values used to identify file format. In other words, every file type requires a unique signature in order for an operating system to recognize it, classify it and show it to an end user.

In my case I am not removing the ext4 signature. We want our data safe! So, select No. (N)

No alt text provided for this image

Step 4: Cleaning the bad Sector

Command: e2fsk -f /dev/xvdf1

No alt text provided for this image

Step 5: Format only extended part

Command: resize2fs /dev/xvdf1

Step 6: Mount partition to directory

Command: mount /dev/xvdf1

No alt text provided for this image

Step 7: Let Us check our data. The file is safe! The file size is still 184 M.

No alt text provided for this image
THANK YOU SO MUCH !!
Deepak Shah

Terraform || Openshift(EX180) || AWS(CLF-CO2) || AWS(SAA-C03) Certified

4 年

well done Hasti Vora

回复

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

Hasti Vora的更多文章

社区洞察

其他会员也浏览了