LVM扩容

LVM扩容

八月 08, 2019

LVM扩容

目录

[隐藏]

  • [1格式化pv分区
  • [2显示PV分区情况
  • [3显示LVM卷组的信息
  • [4添加sdb1分区加入到VolGroup组
  • [5显示LVM卷组的信息
  • [6查看/www的容量情况
  • [7在线扩展逻辑卷/dev/mapper/VolGroup-LogVol02的空间大小为3T
  • [8增加未加载的ext4文件系统的大小

格式化pv分区[编辑]

1
2
[root@localhost /]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created

显示PV分区情况[编辑]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[root@localhost /]# pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name VolGroup
PV Size 263.05 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 67341
Free PE 1681
Allocated PE 65660
PV UUID Rkl9Mj-4HRj-wyN8-JSjy-3yp1-ODYk-ntKfeU

"/dev/sdb1" is a new physical volume of "3.64 TiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 3.64 TiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID rDjtHR-6cKJ-5jmG-KiJd-1rwT-p70J-gTvMTL

显示LVM卷组的信息[编辑]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@localhost /]# vgdisplay
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 8
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 4
Open LV 4
Max PV 0
Cur PV 1
Act PV 1
VG Size 263.05 GiB
PE Size 4.00 MiB
Total PE 67341
Alloc PE / Size 65660 / 256.48 GiB
Free PE / Size 1681 / 6.57 GiB
VG UUID UFyIpG-nG1e-oudK-zKkh-qR3O-NFue-Nyom9s

添加sdb1分区加入到VolGroup组[编辑]

1
2
[root@localhost /]# vgextend  VolGroup /dev/sdb1
Volume group "VolGroup" successfully extended

显示LVM卷组的信息[编辑]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@localhost /]# vgdisplay
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 9
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 4
Open LV 4
Max PV 0
Cur PV 2
Act PV 2
VG Size 3.90 TiB
PE Size 4.00 MiB
Total PE 1021068
Alloc PE / Size 65660 / 256.48 GiB
Free PE / Size 955408 / 3.64 TiB
VG UUID UFyIpG-nG1e-oudK-zKkh-qR3O-NFue-Nyom9s

查看/www的容量情况[编辑]

1
2
3
4
5
6
7
8
9
10
11
[root@localhost /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol00
39G 3.5G 33G 10% /
/dev/sda1 190M 60M 121M 34% /boot
/dev/mapper/VolGroup-LogVol02
165G 115G 42G 74% /www
/dev/mapper/VolGroup-LogVol03
40G 766M 37G 3% /data0
/dev/mapper/VolGroup-LogVol01
9.5G 451M 8.6G 5% /opt

在线扩展逻辑卷/dev/mapper/VolGroup-LogVol02的空间大小为3T[编辑]

1
2
3
[root@localhost /]# lvextend -L +3000G /dev/mapper/VolGroup-LogVol02
Size of logical volume VolGroup/LogVol02 changed from 167.66 GiB (42920 extents) to 3.09 TiB (810920 extents).
Logical volume LogVol02 successfully resized

增加未加载的ext4文件系统的大小[编辑]

1
2
3
4
5
6
[root@localhost /]# resize2fs /dev/mapper/VolGroup-LogVol02
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-LogVol02 is mounted on /www; on-line resizing required
old desc_blocks = 11, new_desc_blocks = 198
Performing an on-line resize of /dev/mapper/VolGroup-LogVol02 to 830382080 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-LogVol02 is now 830382080 blocks long.

查看扩容后/www的容量情况[编辑]

1
2
3
4
5
6
7
8
9
10
11
[root@localhost /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol00
39G 6.2G 31G 17% /
/dev/sda1 190M 60M 121M 34% /boot
/dev/mapper/VolGroup-LogVol02
3.1T 135G 2.8T 5% /www
/dev/mapper/VolGroup-LogVol03
40G 768M 37G 3% /data0
/dev/mapper/VolGroup-LogVol01
9.5G 454M 8.6G 5% /opt