How to resize partitions in CentOS7

How to resize partitions in CentOS7

Yesterday, I helped someone install a system and forgot to click on the automatic partitioning. The size of the automatic partition was very unsuitable for daily use.

Execute the command: df -h

You can see that the system automatically allocates all the remaining space to the home partition, but we usually use the space under the root partition, so we must move the excess space under home to the root partition.

First, you need to back up the contents of the home folder. Execute the command: cp -r /home/ homebak/ (If no other accounts are created in the new system, you do not need to back up)

Unmount home: umount /home (If there are processes under home, use fuser -m -v -i -k /home to terminate the processes under home, and finally use umount /home to unmount /home)

Delete the home sector: lvremove /dev/mapper/centos-home

Add 100G to the sector where root is located: lvextend -L +100G /dev/mapper/centos-root

Expand the root file system: xfs_growfs /dev/mapper/centos-root

Recreate home lv: lvcreate -L 64G -n home centos (the 64G here is the original space minus the space moved away, not randomly filled)

Create a file system: mkfs.xfs /dev/centos/home

Mount home: mount /dev/centos/home /home

cp the backed up stuff back to home and delete the backup;

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to add and delete swap partition in Centos7
  • Detailed explanation of adding swap partition in CentOS7 in Linux

<<:  Detailed explanation of mysql download and installation process

>>:  MySQL database 8 - detailed explanation of the application of functions in the database

Recommend

Vue large screen display adaptation method

This article example shares the specific code for...

HTML meta viewport attribute detailed description

What is a Viewport Mobile browsers place web pages...

JS implements a stopwatch timer

This article example shares the specific code of ...

Discuss the application of mixin in Vue

Mixins provide a very flexible way to distribute ...

Issues with using Azure Container Registry to store images

Azure Container Registry is a managed, dedicated ...

Docker Compose one-click ELK deployment method implementation

Install Filebeat has completely replaced Logstash...

How to display TIF format images in browser

The browser displays TIF format images Copy code T...

How to Enable or Disable Linux Services Using chkconfig and systemctl Commands

This is an important (and wonderful) topic for Li...

Use of Linux ipcs command

1. Command Introduction The ipcs command is used ...

MySQL not null constraint case explanation

Table of contents Set a not null constraint when ...

The whole process of implementing the summary pop-up window with Vue+Element UI

Scenario: An inspection document has n inspection...

How to connect idea to docker to achieve one-click deployment

1. Modify the docker configuration file and open ...