Operation steps for centos7 to expand the root directory space

Time:2020-5-21

Recently, the company has installed a batch of CentOS 7 servers with additional hard disks, but the space of the root disk is not large.

LVM has been deployed on the server. Due to the business needs, the root disk needs extra space, so we decided to use two additional hard disks to expand the root directory.

1. Create two physical volumes:

pvcreate /dev/sda1
pvcreate /dev/sdb1

(Note: if these mount points already exist, you will be prompted whether to overwrite them. Type Y directly to confirm the overwrite.)

2. Expand CentOS volume group:

vgextend centos /dev/sd{a,b}1

3. Expand logical volume:

lvextend -L+XXXG centos

(Note: XXX is the specific size to be expanded, unit: G)

4. Apply the extended logical volume to the root partition

xfs_growfs /

(Note: the command of CentOS 6 is different from that of CentOS 7. Please use Baidu for specific command)