Increase or Decrease the Size of Static Partition Without Losing Any Data

Increase or Decrease the Size of Static Partition Without Losing Any Data

This Article explain how to increase/decrease the size of the static partition without losing data in Linux.

WHAT IS PARTITIONING OF HARD DISK?

It is the concept in which a given hard disk is divided into segments of secondary storage, so that each segment is managed separately. This is also done with a view that if damage is caused to one segment, like in cases of complete deletion of data, the damage is not transferred to the entire disk. It rather remains confined to that particular segment.

MAJOR STEPS INVOLVED IN CREATING A PARTITION

Three major steps are involved are:

  • Create
  • Format
  • Mount

CREATING

You need to have a harddisk attached.

fdisk -l

This command shows you the list of all attached disks.

fdisk <drive_name> , In my case fdisk /dev/sdc

This command creates the partition for you. The ‘n’ in the line 'Command (m for help):n' indicates that we are creating a new partition.

The hard disk is of size 10GB in total, But I want to make use of 3GB so I will input +3G.

w: to save the changes made to the partition.

No alt text provided for this image


FORMATTING

mkfs.ext4 <drive_name>, In my case mkfs.ext4 /dev/sdc1

Above command is used to format the partition.

MOUNTING

Create a new directory , I created /st1.

mount /dev/sdc1 /st1

In order to mount the partition to /st1.

df -hT

To check the successful mounting of the partition.

Within the directory create a file , I created dwi.txt.

No alt text provided for this image

Now comes our main task which is to increase or decrease the size of the static partition.

For accomplishing this task, we need to first unmount it , using command:

umount /st1
No alt text provided for this image

Now delete the partition:

No alt text provided for this image

And create partition again:

No alt text provided for this image

Now:

e2fsck -f /dev/sdc1

This command will check errors and will mark file system as clean.

No alt text provided for this image

Now format the remaining partition i.e. resized partition:

resize2fs /dev/sdc1

and mount to directory

mount /dev/sdc1 /st1
No alt text provided for this image

Here, we can see the previous file exist. so through this method we can increase the size of static partition.

Thank You!


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

Yash Dwivedi的更多文章

  • Web Application for Docker

    Web Application for Docker

    Task: This app will help the user to run all the docker commands of docker using webApp using JavaScript. Solution: for…

    2 条评论
  • Making HTTPD Service Idempotent

    Making HTTPD Service Idempotent

    Description: Restarting HTTPD Service is not idempotence in nature and also consume more resources suggest a way to…

  • Industry Use Cases of Ansible

    Industry Use Cases of Ansible

    Hello, Here in the blog we'll talk something about Ansible and then will know how trivago is using Ansible, so let's…

  • Ansible Automation for Hadoop Cluster

    Ansible Automation for Hadoop Cluster

    Hadoop: Apache Hadoop is an open source framework that is used to efficiently store and process large datasets ranging…

  • Ansible Playbook for Launching Docker

    Ansible Playbook for Launching Docker

    Task: ?? Configure Docker ?? Start and enable Docker services ?? Pull the httpd server image from the Docker Hub ?? Run…

  • Porsche Informatik delivers automotive innovation faster with Red Hat OpenShift

    Porsche Informatik delivers automotive innovation faster with Red Hat OpenShift

    Porsche Informatik, IT service provider for the Volkswagen Group, needed to speed application development and delivery…

  • Network Setup We can Ping Google but not Facebook from Same?System

    Network Setup We can Ping Google but not Facebook from Same?System

    For Network setup we have to setup Routing table. A routing table is a set of rules, often viewed in table format, that…

  • Automating LVM Partition using Python-Script

    Automating LVM Partition using Python-Script

    We can automate LVM through python for automation we have the code link below: GitHub Link:-…

  • Configuring webserver and python inside container.

    Configuring webserver and python inside container.

    ??Configuring Httpd Server on Docker Container ??Setting up Python Interpreter and running Python Code on Docker…

  • Hadoop and LVM Integration

    Hadoop and LVM Integration

    LVM help to provide elasticity to data node and it will solve industry use cases. We can increase or decrease storage…

社区洞察

其他会员也浏览了