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

js to realize a simple advertising window

This article shares the specific code of js to im...

About the selection of time date type and string type in MySQL

Table of contents 1. Usage of DATETIME and TIMEST...

Shell script to monitor MySQL master-slave status

Share a Shell script under Linux to monitor the m...

Vue encapsulation component tool $attrs, $listeners usage

Table of contents Preface $attrs example: $listen...

Detailed explanation of the murder caused by a / slash in Nginx proxy_pass

background An nginx server module needs to proxy ...

Detailed discussion of the differences between loops in JavaScript

Table of contents Preface Enumerable properties I...

JavaScript anti-shake and throttling detailed explanation

Table of contents Debounce Throttle Summarize Deb...

Solution to the error problem of Vscode remotely connecting to Ubuntu

1. Background of the incident: Because of work ne...

Solving problems encountered when importing and exporting Mysql

background Since I converted all my tasks to Dock...

Complete steps to quickly build a vue3.0 project

Table of contents 1. We must ensure that the vue/...

9 Practical Tips for Creating Web Content Pages

Content 1. Give readers a reason to stay. Make the...

How to solve the error "ERROR 1045 (28000)" when logging in to MySQL

Today, I logged into the server and prepared to m...

Several methods to execute sql files under mysql command line

Table of contents The first method: When the MySQ...