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

Nginx memory pool source code analysis

Table of contents Memory Pool Overview 1. nginx d...

Uniapp WeChat applet: Solution to key failure

uniapp code <template> <view> <ima...

MySQL Error 1290 (HY000) Solution

I struggled with a problem for a long time and re...

Mysql8.0 uses window functions to solve sorting problems

Introduction to MySQL Window Functions MySQL has ...

A brief discussion on how to write beautiful conditional expressions in JS

Table of contents Multiple conditional statements...

VMware Workstation 12 Pro Linux installation tutorial

This article records the VMware Workstation 12 Pr...

Pure CSS to achieve click to expand and read the full text function

Note When developing an article display list inte...

MySQL database basic syntax and operation

MySQL database basic syntax DDL Operations Create...

Detailed explanation of computed properties in Vue

Table of contents Interpolation Expressions metho...

How to understand JS function anti-shake and function throttling

Table of contents Overview 1. Function debounce 2...

Detailed steps to install Docker mongoDB 4.2.1 and collect springboot logs

1: Install mongodb in docker Step 1: Install mong...

Docker image optimization (from 1.16GB to 22.4MB)

Table of contents The first step of optimization:...