Increasing or Decreasing the Size of Static Partition in Linux [RHEL8] .i.e. How to resize Partition on RHEL
Hasti Vora
|| RHCE Certified || QA Engineer || Automation Enthusiast | Playwright & Robot Framework |
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.
Step1: We have to create partition of disk /dev/xvdf (6GB). The steps that need to follow are:
- fdisk /dev/sdb: to go inside the disk
- n : for new partition
- p : for primary partition
- w: to save the created partition.
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
Step 3: Create Directory task and mount it to disk /dev/xvdf1
Command: mount /dev/xvdf1 /task
Step 4: Creating a file name staticfile.txt. The file size is 184M.
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
?Step 2: Delete the Partition
d: it is for deleting partition
w: to save the changes
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)
Step 4: Cleaning the bad Sector
Command: e2fsk -f /dev/xvdf1
Step 5: Format only extended part
Command: resize2fs /dev/xvdf1
Step 6: Mount partition to directory
Command: mount /dev/xvdf1
Step 7: Let Us check our data. The file is safe! The file size is still 184 M.
THANK YOU SO MUCH !!
Terraform || Openshift(EX180) || AWS(CLF-CO2) || AWS(SAA-C03) Certified
4 年well done Hasti Vora