Resize The Static Partition Without Losing Data

Manali Jain
4 min readNov 10, 2020

--

🔅Increase or Decrease the Size of Static Partition in Linux.

🤔 Dynamic partitioning is very useful right !! Whenever we want we can increase or decrease the size of the hard disk according to our needs. In companies, it is so important. But what if the partition is static and we want to resize it without losing the data.

🤫 In this task, I am going to tell How to Resize the Static Partition without losing the data.

🔰 Partitioning follows 3 steps that is to be done by you or companies will do earlier for you -

1️⃣ Partition

2️⃣ Format

3️⃣ Mount

But today we will add extra features to it by resizing it. So let’s get started !!

PREREQUISITES -

  1. Added one harddisk
  2. Redhat Linux Operating System
  3. Linux Knowledge

_________________________

  1. CHECK THE HARDDISK -

[ fdisk -l ] command helps to see how many hard disks are attached to the operating system.

list the hard disk

_________________________

2. Partition

[ fdisk /dev/nvme0n2 ] is the command to format the harddisk where

[ n ] means create a new partition

[ p ] means create a primary partition

[ w ] means alter the changes

partition

_________________________

3. FORMAT

[ mkfs.ext4 /dev/nvme0n2 ] is the command which is used to format the partition. The format means we usually refer to the concept that removes all data but format creates an Inode Table so that we can track or search easily.

format

_________________________

4. MOUNT

When the partition is created then our ultimate aim is to use that so we mount it to a directory so that we can store files into it permanently.

[ mount /dev/nvme0n2 /resizetask] is the command used to mount the partition with the directory.

[ mkdir /resizetask ] is the command used to create the directory.

[ df -h ] command shows information about which device is mounted on which directory with its size that is used and available.

mount it

_________________________

5. CREATE A FILE IN DIRECTORY

First, change the directory and then create a file into it so that when we increase the size it will not lose it.

create file

_________________________

6. UNMOUNT

[ umount /dev/nvme0n2 ] is the command used to unlink the linked device. It is the same as a pen drive we can attach and detach it without losing our data.

unlink it

_________________________

7. FILE IS NOT PRESENT

where is the file

As we have unlinked the device so we are not able to see the data which was stored in it.

no data

_________________________

8. INCREASED THE HARDDISK SIZE

As manually first I have increased the size from 1 GiB to 2 GiB.

size increased

_________________________

9. CREATE PARTITION

Again create a partition and delete the earlier one.

create partiton

_________________________

10. INCREASED HARD DISK

The size of the hard disk is increased.

Check by [ fdisk -l ] command.

size increased

_________________________

11. CHECK PARTITION DATA

When the system is shut down but not properly we run the [ e2fsck -f /dev/nvme0n2p1 ] command to repair the storage. It is not safe to run this command when the device is mounted.

repair

_________________________

12. RESIZE

Run the [ resize2fs /dev/nvme0n2p1 ] command to resize the partition without losing the data.

resize

_________________________

13. MOUNT IT

Now to see the data is present or not first mount the device with the directory and see the data by [ ls ] command. By using the [ df -h ] command you can see that the size of the mount also increased.

mount
df -h

_________________________

Thank You For Reading This Blog 😇

Have a great Day !!

Keep Sharing ;-)

--

--

Manali Jain
Manali Jain

Written by Manali Jain

You are the only one person who can Change Yourself…

No responses yet