LVM扩展文件系统
1. 总体流程
- 创建块设备(fdisk格式化创建分区,并调整为8e)
- 创建pv
- 扩展vg
- 扩展lv
- 扩展文件系统
2. 创建块设备
流程:
-
fdisk /dev/sdb
-
n一路回车格式化分区
-
t:修改分区类型
-
8e:修改分区ID为linux LVM
-
w:保存退出
3. 创建pv
[root@6-93 ~]# pvscan
PV /dev/sda2 VG centos lvm2 [<99.00 GiB / 4.00 MiB free]
Total: 1 [<99.00 GiB] / in use: 1 [<99.00 GiB] / in no VG: 0 [0 ]
[root@6-93 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- <99.00g 4.00m
[root@6-93 ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
[root@6-93 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- <99.00g 4.00m
/dev/sdb1 lvm2 --- <300.00g <300.00g
4. 扩展vg
[root@6-93 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 3 0 wz--n- <99.00g 4.00m
[root@6-93 ~]# vgextend /dev/centos /dev/sdb1
Volume group "centos" successfully extended
[root@6-93 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 2 3 0 wz--n- 398.99g 300.00g
5. 扩展lv
[root@6-93 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home centos -wi-ao---- <41.12g
root centos -wi-ao---- 50.00g
swap centos -wi-ao---- <7.88g
[root@6-93 ~]# lvs /dev/centos/root
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 50.00g
[root@6-93 ~]# lvextend -l +100%FREE /dev/centos/root
Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 350.00 GiB (89600 extents).
Logical volume centos/root successfully resized.
[root@6-93 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home centos -wi-ao---- <41.12g
root centos -wi-ao---- 350.00g
swap centos -wi-ao---- <7.88g
6. 扩展文件系统
查看文件系统类型:
[root@6-93 ~]# blkid /dev/mapper/centos-root
/dev/mapper/centos-root: UUID="32d999cc-6f98-48e7-b594-676af898d659" TYPE="xfs"
扩展文件系统:
[root@6-93 ~]# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize=512 agcount=28, agsize=3276800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=91750400, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=6400, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
查看:
[root@6-93 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 99G 0 part
├─centos-root 253:0 0 350G 0 lvm /
├─centos-swap 253:1 0 7.9G 0 lvm [SWAP]
└─centos-home 253:2 0 41.1G 0 lvm /home
sdb 8:16 0 300G 0 disk
└─sdb1 8:17 0 300G 0 part
└─centos-root 253:0 0 350G 0 lvm /
sr0 11:0 1 1024M 0 rom