Linux add a new hard disk, add to the existing logical volume expansion

After partitioning the logical volume, we are just for dynamic expansion. We just encountered such a problem today, so let’s write about the operation process.

After adding the hard disk, use the following command to directly display and read without shutting down

echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan
 

1. First add the hard disk, then format, remember to select dynamic logical volume 8e, the details are as follows

2. Format the hard disk, CentOS7 is generally xfs, use the following command mkfs.xfs /dev/sdb1

3. Create pv

pvcreate /dev/sdb1

There will be an alarm here, just confirm with Y

Then use pvdisplay to see the new pv

4. Extend vg. Here we want to expand to the above centos. The vg command is as follows

vgextend centos /dev/sdb1

Confirm that the capacity of vg has been up

Two different PVs in the same vg

5. Expand the corresponding lv, which is centos because we want to expand the home

Add sdb1 to the home directory

lvextend /dev/mapper/centos-home /dev/sdb1

6. Reactivate the partition table

Because we are xfs here, the command is

xfs_growfs /dev/mapper/centos-home

If it is not xfs, use the following command

 resize2fs /dev/mapper/centos-home

If the following error is reported, the command is wrong, just find out how to reactivate the corresponding format

Guess you like

Origin blog.csdn.net/zetion_3/article/details/103922074