4 创建一个150M大小的逻辑卷
[root@www ~]# lvcreate -n vo -L 150M storage
Rounding up size to full physical extent 152.00 MiB
Logical volume "vo" created.
[root@www ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
vo storage -wi-a----- 152.00m
5 把生成号的逻辑卷进行格式化,然后挂载使用.
[root@www ~]# mkfs.xfs /dev/storage/vo
meta-data=/dev/storage/vo isize=256 agcount=4, agsize=9728 blks
= sectsz=512 attr=2, projid32bit=0
data = bsize=4096 blocks=38912, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0
log =internal log bsize=4096 blocks=1200, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@www ~]# mount /dev/storage/vo /soft/
[root@www ~]# ls /soft/
[root@www ~]#
永久挂载,重启后生效,这里可以使用/dev/storage/vo也可以使用uuid推荐使用后者.
UUID="645e5ca4-d564-425b-ad50-a9d43536951f" /soft xfs defaults 0 0
可以使用umount /soft卸载,再使用mount -a检查一下有没有挂载成功.使用df -h查看分区情况
[root@www ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 1.7G 16G 10% /
tmpfs 490M 0 490M 0% /dev/shm
/dev/sda1 190M 59M 122M 33% /boot
/dev/mapper/storage-vo
148M 7.8M 140M 6% /soft
扩容逻辑卷
这里使用lvextend -l 50指定200M大小的逻辑卷,计算方法为4M*50.
[root@www ~]# lvextend -l 50 /dev/storage/vo
Size of logical volume storage/vo changed from 152.00 MiB (38 extents) to 200.00 MiB (50 extents).
Logical volume vo successfully resized.
[root@www ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
vo storage -wi-a----- 200.00m
新硬盘加入vg卷组
[root@www ~]# pvcreate /dev/sde
Physical volume "/dev/sde" successfully created
[root@www ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb storage lvm2 a--u 1020.00m 820.00m
/dev/sdc storage lvm2 a--u 1020.00m 1020.00m
/dev/sdd storage lvm2 a--u 1020.00m 1020.00m
/dev/sde lvm2 ---- 1.00g 1.00g
[root@www ~]# vgextend storage /dev/sde
Volume group "storage" successfully extended
[root@www ~]# vgs
VG #PV #LV #SN Attr VSize VFree
storage 4 1 0 wz--n- 3.98g 3.79g
[root@www ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb storage lvm2 a--u 1020.00m 820.00m
/dev/sdc storage lvm2 a--u 1020.00m 1020.00m
/dev/sdd storage lvm2 a--u 1020.00m 1020.00m
/dev/sde storage lvm2 a--u 1020.00m 1020.00m
从vg卷组移除一块硬盘
[root@www ~]# vgreduce storage /dev/sde
Removed "/dev/sde" from volume group "storage"
[root@www ~]# vgs
VG #PV #LV #SN Attr VSize VFree
storage 3 1 0 wz--n- 2.99g 2.79g
[root@www ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb storage lvm2 a--u 1020.00m 820.00m
/dev/sdc storage lvm2 a--u 1020.00m 1020.00m
/dev/sdd storage lvm2 a--u 1020.00m 1020.00m
/dev/sde lvm2 ---- 1.00g 1.00g