扩大磁盘分区
扩展逻辑卷mylv大小至700M
[root@server0 ~]# fdisk /dev/vdb ////进入/dev/vdb磁盘
Command (m for help): n ////创建分区
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): e ////选择e,创建逻辑分区
Partition number (2-4, default 2):
First sector (1026048-20971519, default 1026048):
Using default value 1026048
Last sector, +sectors or +size{K,M,G} (1026048-20971519, default 20971519): ////将剩下的所有空间全部划给逻辑分区
Using default value 20971519
Partition 2 of type Extended and of size 9.5 GiB is set
Command (m for help): n ////创建分区
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l ////选择l,从逻辑分区中创建一个扩展分区
Adding logical partition 5
First sector (1028096-20971519, default 1028096):
Using default value 1028096
Last sector, +sectors or +size{K,M,G} (1028096-20971519, default 20971519): +600M ////设置该扩展分区大小600M
Partition 5 of type Linux and of size 600 MiB is set
Command (m for help): t ////修改分区类型
Partition number (1,2,5, default 5): 5
Hex code (type L to list all codes): 8e ////83为linux类型、8e为linux LVM类型,82为swap类型
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): w ////保存退出
[root@server0 ~]# partprobe /dev/vdb ////确认磁盘
[root@server0 ~]# pvcreate /dev/vdb5 ////创建物理卷
Physical volume "/dev/vdb5" successfully created
[root@server0 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/vdb1 myvg lvm2 a-- 496.00m 196.00m
/dev/vdb5 lvm2 a-- 600.00m 600.00m
[root@server0 ~]# vgextend myvg /dev/vdb5 ////将物理卷/dev/vdb5扩展至卷组myvg
Volume group "myvg" successfully extended
[root@server0 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
myvg 2 1 0 wz--n- 1.07g 792.00m
[root@server0 ~]# lvextend -L +400M /dev/myvg/mylv ////扩展逻辑卷mylv,扩大400M
Extending logical volume mylv to 700.00 MiB
Logical volume mylv successfully resized
[root@server0 ~]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
mylv myvg -wi-ao---- 700.00m
[root@server0 ~]# resize2fs /dev/myvg/mylv ////确认扩展
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/myvg/mylv is mounted on /mnt/ceshi; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 6
The filesystem on /dev/myvg/mylv is now 716800 blocks long.
[root@server0 ~]# df -h