Linux-CentOS7-目录空间扩容记录
/data目录空间不够了,如何扩展,实操如下:
查看当前磁盘分区信息。
fdisk -l
lsblk
对vde进行分区(大容量分区parted)
parted /dev/vde1
mklabel gpt
mkpart primary 0 -1
quit
格式化vde分区
mkfs.ext4 -t ext4 /dev/vde1
扩展目录
先看一下卷分组
vgdisplay -v
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Namecentos
--- Logical volume ---
LV Path /dev/vgdata/lvdata
LV Name lvdata
VG Namevgdata
可以看到当前卷分组名为"centos",数据卷分组名为"vgdata"
为之前新增的分区创建物理卷:
pvcreate /dev/vde1
查看结果
[root@space ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos
PV Size 39.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 10114
Free PE 0
Allocated PE 10114
PV UUID BWUVqr-mVpy-x6gX-bqxU-NJP7-l48n-Lrx9Ke
"/dev/vde1" is a new physical volume of "xxxxGiB"
--- NEW Physical volume ---
PV Name /dev/vde1
VG Name
PV Size xxxxx.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID cKQd9i-eDVI-BO2Y-BNCS-Yaxj-ouKo-PPdRQC
已经看到新创建的xxxxG大小的物理卷(/dev/vde1)
扩展卷分组,"vgdata"是vgdisplay命令查到的卷分组名
vgextend centos /dev/vde1
提示成功扩展。
下面查看一下逻辑卷
[root@space ~]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID nVjnIr-3kdo-ncmg-Qoyw-DQeG-F0Lh-cdzVhi
LV Write Access read/write
LV Creation host, time localhost, 2015-03-31 10:58:35 +0800
LV Status available
# open 1
LV Size 35.62 GiB
Current LE 9118
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/vgdata/lvdata
LV Name lvdata
VG Name vgdata
LV UUID o8mQCM-d2oV-IfKN-GJdK-GS31-t0gX-Bx4jfX
LV Write Access read/write
LV Creation host, time host-192-168-64-19, 2019-12-13 13:18:12 +0800
LV Status available
# open 1
LV Size <5.76 TiB
Current LE 2558356
Segments 7
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
可以看到/dev/vgdata/lvdata目前的LV Size是5.76T。
下面扩展逻辑卷/dev/vgdata/lvdata
lvextend -L +3T /dev/vgdata/lvdata
注:+3T是我们新增加的分区大小。
最后一步,同步文件目录大小
resize2fs /dev/mapper/vgdata-lvdata
这里说明一下我遇到的问题,因为之前格式化盘为ext4 格式,所以不能使用xfs_growfs
resize2fs 针对文件系统ext2 ext3 ext4
xfs_growfs 针对文件系统xfs
文档记录的不是很详细,下面是经常使用到的命令,如果不清楚上述文档中的命令请自行搜索。
fdisk -l
lsblk
df -h
转载于:
https://www.jianshu.com/p/c618ccc88425