存在多个物理硬盘
可以理解为linux下的物理磁盘或者磁盘分区,如/dev/sdb(磁盘)、/dev/sdb1(磁盘分区,通过fdisk对/dev/sdb进行操作划分出来的磁盘分区,类似于windows下的C、D、E盘),但是和物理磁盘以及磁盘分区不同的是,物理卷含有和 LVM相关的参数
以下案例均是/dev/sda 为系统盘,/dev/sdb 为数据盘
- 创建物理卷
pvcreate /dev/sdb
$ pvcreate /dev/sdb
$ Physical volume "/dev/sdb" successfully created.
- 查看物理卷
pvdisplay
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos
PV Size 9.51 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 2434
Free PE 10
Allocated PE 2424
PV UUID P6xf6f-NPgl-s3Dm-123h-B5e3-NJBh-GbNM1n
"/dev/sdb" is a new physical volume of "30.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb
VG Name
PV Size 30.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID eCPH0s-ptje-nqgd-42jW-e2c5-iay3-rRw2hY
- 查看lv的信息
lvdisplay
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID 9SLqUm-dXfi-bNle-wdX1-cnZQ-HCun-nGWdXk
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2016-06-28 02:34:19 +0800
LV Status available
# open 2
LV Size 1.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID J3ANyS-BTG5-YJ8M-2Zsq-sBUo-YVWg-jyFmvA
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2016-06-28 02:34:19 +0800
LV Status available
# open 1
LV Size <8.47 GiB
Current LE 2168
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
- 查看系统中的卷组,,查看VG Name,检查 VG Size/ Free PE / Size原大小
物理块(PE,physical extent)
每个物理卷被分为若干个物理块,是LVM寻址中的最小单元,有唯一编号,可以设置大小,默认为4MB
vgdisplay
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size <9.51 GiB
PE Size 4.00 MiB
Total PE 2434
Alloc PE / Size 2424 / <9.47 GiB
Free PE / Size 10 / 40.00 MiB
VG UUID OyB5dN-0LOk-6vb1-Qmtu-1EQp-1GtB-Szuco0
- 添加到卷组 centos 中,并查看
vgextend centos /dev/sdb
[root@localhost ~]# vgextend centos /dev/sdb
Volume group "centos" successfully extended
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 2 2 0 wz--n- 79.50g <70.04g
- 为根目录进行扩容(+10G,+100%FREE )
lvextend -L +10G /dev/centos/root
[root@localhost ~]# lvextend -L +10G /dev/centos/root
Size of logical volume centos/root changed from <8.47 GiB (2168 extents) to <18.47 GiB (4728 extents).
Logical volume centos/root successfully resized.
- 刷新文件系统
resize2fs /dev/centos/root
[root@localhost ~]# resize2fs /dev/centos/root
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/centos/root
Couldn't find valid filesystem superblock.
如果出现,Bad magic number in super-block 当尝试打开 /dev/centos/root 时 找不到有效的文件系统超级块.
请使用xfs_growfs /dev/centos/root
- 查看文件系统/挂载点的存储使用情况
df -Th
文章来源:https://www.cnaaa.net,转载请注明出处:https://www.cnaaa.net/archives/4217