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

A guide to writing flexible, stable, high-quality HTML and CSS code standards

The Golden Rule Always follow the same set of cod...

WeChat applet implements user login module server construction

I chose node.js to build the server. Friends who ...

How to install pyenv under Linux

Prerequisites Need to install git Installation St...

JavaScript imitates Xiaomi carousel effect

This article is a self-written imitation of the X...

Cross-browser local storage Ⅰ

Original text: http://www.planabc.net/2008/08/05/...

Making a simple game engine with React Native

Table of contents Introduction Get started A brie...

10 reasons why Linux is becoming more and more popular

Linux has been loved by more and more users. Why ...

VMware virtual machine to establish HTTP service steps analysis

1. Use xshell to connect to the virtual machine, ...

Some references about colors in HTML

In HTML, colors are represented in two ways. One i...

Teach you how to use MySQL8 recursive method

I have previously written an article about recurs...

How to use Vue-router routing

Table of contents 1. Description 2. Installation ...

Analysis of two implementation methods for adding static routing in Linux

Command to add a route: 1.Route add route add -ne...

Django+vue registration and login sample code

register The front-end uses axios in vue to pass ...