当时我想拓展 linux中/的挂载点,但是通过 df -h 命令发现已经快满了: df -h found that the disk space was insufficient. As shown below: 然后我用虚拟机管理系统拓展了磁盘容量,不是添加哦,当然添加也是一样的操作方法,但是扩展后发现fdisk -l 有变化,磁盘容量已经变到了200GB, 但是df -h 缺没有变化 Then I went to openstack maintainers to expand the disk capacity. After the expansion, use the df -h command to find that the space has not changed. But after the fdisk -l command is executed, looking at the figure below, the disk capacity has indeed increased by 200 G. 出现这个问题的原因是这个磁盘没有被挂载,也就是说这个磁盘空间没有被利用,所以下面的操作就是要挂载磁盘: What is the reason why the df -h command has not changed? is because this disk is not mounted, which is equivalent to not using the disk. Next, we start to use this disk and mount it. Here are the execution steps:

  1. Execute the fdisk /dev/vda command.
  2. When the prompt in the red box below appears, enter in order: p, n, p
  3. Then there are 3 default options. Enter all, just use the default.
  4. When the following red box prompt appears, enter t first, then use the default 3, then continue to enter l, 8e, w Note: The second letter is L, not the number 1.
  5. Then enter the following commands in sequence: 1).partprobe 2).pvcreate /dev/vda3 3).pvdisplay 4).vgextend centos /dev/vda3 5).lvdisplay 6).vgdisplay 7).lvextend -l +100%FREE /dev/centos/root 8).vgdisplay 9).xfs_growfs /dev/mapper/centos-root
  6. Finally, use the df -h command to take a look, you can see that the expansion has been successful
This article is from: https://www.programmersought.com/article/68045087402/

Other reference:

https://blog.csdn.net/u012599988/article/details/86535278
https://kb.vmware.com/s/article/1006371
https://serverfault.com/questions/938268/how-to-increase-the-size-for-dev-mapper-centos-root
https://www.programmersought.com/article/68045087402/
#########################################################
pvcreate /dev/sdb
     Physical volume "/dev/sdb" successfully created

vgdisplay

vgs
	VG #PV #LV #SN Attr VSize VFree 
	centos 2 2 0 wz--n- 59.50g 20.04g

vgextend centos /dev/sdb

vgs
	VG     #PV #LV #SN Attr   VSize  VFree
	centos   2   2   0 wz--n- 39.50g 20.04g

vgdisplay centos | grep "Free"

lvs 
	LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

  	root centos -wi-ao---- 17.47g                                                   
  	swap centos -wi-ao----  2.00g

lvextend -L +20G /dev/mapper/centos-root
	Size of logical volume centos/root changed from 17.47 GiB (4472 extents) to 37.47 GiB (9592 extents).
	Logical volume root successfully resized

lvscan

xfs_growfs /dev/mapper/centos-root

resize2fs /dev/mapper/centos-root