Increase OR decrease the size of the static partition in linux>-

Static V/S Dynamic Partitioning
šš»āāļøIn most cases, we can use dynamic partitioning. It provides us a lot of flexibility. The following table will help you understand the difference between Static and dynamic partitioning.

For all the concepts of LVM do refer to my previous blog also: https://gulshachawla.medium.com/integration-of-lvm-with-hadoop-cluster-using-aws-cloud-66edc98992cd
Letās move towards the practical partšš»
Firstly we will add a new external hard disk of letās say 20GB
To add an external H.D go to
Settings=>Storage=>Add hard disk

Then click here

Then tap next

Again tap next

Now give a name to your new H.D & specify a size you wish for it.
Here our H.D is created but still, it is not attached to our VM or RHEL8 O.S.

To attach just click on choose thatās it our H.D name & size you specified will pop-up there tap ok! as you can see in above snapshot.
Now itās time to go inside o.s & do this taskš
Step 1: Check & verify new H.D attached or not
We will check & verify by using : #fdisk -l

Step 2: To create a partition, format & mount.
For partition, we will go inside this H.D so we will use: #fdisk /dev/sdd here to create a new partition press n then as we are first time creating partition i.e primary partition press p hit enter size letās say of 10GB and to save it press w thatās it our partition of 10GB /dev/sdd1 is created.

Now as we are using RHEL8 O.S we need to load a driver so that user can interact with this H.D storage by using: #udevadm settle
Then we need to format this partition using: #mkfs.ext4 /dev/sdd1

After this, we will mount this partition
Firstly we will create a directory or folder using: #mkdir /folder-name
So to mount we will use: #mount /partition-name /folder-name
Then using: #df -h or #lsblk command we can verify it is successfully mounted.

Step 3: Increase OR Decrease the size of the static partition in Linux
Here before I do partition I will make text files to prove that after I increase or decrease my partition storage it wonāt lose my data.

Now we will do unmount of folder we created earlier to increase its storage i.e static storage using command #umount /gc_LVM
Then we will delete the partition by pressing d using the command
: #fdisk /hard-disk-name

For creating a partition of 15GB, I am increasing storage by 5GB more here n is for the new partition and to save it press w.

Have you noticed??š Before increasing static partition it asked me Yes Or No? & it is telling partition #1 contains an ext4 signature what does it mean??š§
šSo, the signature of partition is basically a mark/beacon there is something there, and it is not empty. It may also identify a partition.
šIt is useful in the context of several utilities/OS to tell the partition has already data there.
šMoving a partition size/recreating a partition is usually a non-destructive operation up to the point before formatting it.
šSo a signature warning is signaling you āThere is already data here!ā¦are you sure you want to go ahead?ā
šEach disk and partition has some sort of signature and metadata/magic strings on it. The metadata is used by an operating system to configure disks or attach drivers and mount disks on your system.
šAs for removing it or not, it depends on whether you are for instance resizing a partition or creating a new partition. If you are creating a new partition, obviously you may want to remove the signature, if you are resizing a partition you surely want to keep it so I pressed here w to keep this signature as it contains my data i.e text files we created earlier.
But here a challenge comes in scenarioš¤ I know I have somewhere my data files but how to retrieve them back?š¤Ø
So for that, I repaired my partition table or inode table i.e Clean & Scan if any badly corrupted files, dataā¦etc it will remove using command :#e2fsck -f /dev/sdd1 here full form of this command is extended to(2) file system clean check & -f means forcefully clean it.

As we had earlier formatted 10GB now letās re-format this 5GB more data by using command #resize2fs /dev/sdd1 here we didnāt use mkfs.ext4 to re-format it will lose my data and so I used resize2fs as it is part of ext4 format-type also it wonāt lose my data. In ext4 format type, we can extend & reduce the size of the partition.

Sometimes we have big commands we need to again & again manually run them but here I have some small trick or wayš” without manually typing within a go we can run that big command so go to history=>check command line-number=>!command-number run it! thatās it we again ran the same big command without more typingā¦here I did re-mount using #mount /partition-name /folder-name.

As we can see in the above snapshot our static partition is successfully increased from 10GB to nearly 15GB using command #df -h
Now letās check do I got or have my data still or not?š§
Oh! Yes itās still there hence proved though we resized my partition our data wonāt be lost by using the command: #ls

Finally, our task 7.1.B Increase OR Decrease the size of the static partition in Linux is accomplished!
Thank you for reading my articleš¤
Keep Learningš«Keep Sharingš¤š»
Good Day!