LVM是逻辑盘卷管理(Logical VolumeManager)的简称,它是Linux环境下对磁盘分区进行管理的一种机制,LVM是建立在硬盘和分区之上的一个逻辑层,来提高磁盘分区管理的灵活性。通过LVM系统管理员可以轻松管理磁盘分区,如:将若干个磁盘分区连接为一个整块的卷组(volumegroup),形成一个存储池。管理员可以在卷组上随意创建逻辑卷组(logicalvolumes),并进一步在逻辑卷组上创建文件系统。管理员通过LVM可以方便的调整存储卷组的大小,并且可以对磁盘存储按照组的方式进行命名、管理和分配
查看磁盘空间
[root@ywcsb ~]# fdisk -l
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000b7e20
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 209715199 103808000 8e Linux LVM
Disk /dev/sdb: 966.4 GB, 966367641600 bytes, 1887436800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos_bgd--ngnix1-root: 102.1 GB, 102131302400 bytes, 199475200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos_bgd--ngnix1-swap: 4160 MB, 4160749568 bytes, 8126464 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
创建物理卷
[root@ywcsb ~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
查看物理卷
[root@ywcsb ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos_bgd-ngnix1
PV Size <99.00 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 25343
Free PE 1
Allocated PE 25342
PV UUID vr9DRr-mwG8-89Vm-LmoV-Bqel-Ykga-HM5HLg
"/dev/sdb" is a new physical volume of "900.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb
VG Name
PV Size 900.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID fhbfRd-x6qx-KVCd-3SBF-5lXN-Z81W-SIrRQz
查看当前卷组
[root@ywcsb ~]# vgdisplay
--- Volume group ---
VG Name centos_bgd-ngnix1
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 <99.00 GiB
PE Size 4.00 MiB
Total PE 25343
Alloc PE / Size 25342 / 98.99 GiB
Free PE / Size 1 / 4.00 MiB
VG UUID BFGY1M-PHqr-RBnE-87t2-bhYC-n7PX-idg4R1
扩展卷组,将/dev/sdb物理卷加到VG中
[root@ywcsb ~]# vgextend centos_bgd-ngnix1 /dev/sdb
Volume group "centos_bgd-ngnix1" successfully extended
查看逻辑卷
[root@ywcsb ~]# lvdisplay
--- Logical volume ---
LV Path /dev/centos_bgd-ngnix1/root
LV Name root
VG Name centos_bgd-ngnix1
LV UUID 2SnPdf-1zdM-lM5G-4fJz-oGve-JC2Z-fkTGUL
LV Write Access read/write
LV Creation host, time bgd-ngnix1, 2018-11-21 13:08:20 +0800
LV Status available
# open 1
LV Size <95.12 GiB
Current LE 24350
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
--- Logical volume ---
LV Path /dev/centos_bgd-ngnix1/swap
LV Name swap
VG Name centos_bgd-ngnix1
LV UUID l8jyte-4j0X-00Am-ich0-9qen-QLaW-LWTSHI
LV Write Access read/write
LV Creation host, time bgd-ngnix1, 2018-11-21 13:08:21 +0800
LV Status available
# open 2
LV Size <3.88 GiB
Current LE 992
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
将VG空间划分到LV
[root@ywcsb ~]# lvextend -l +100%FREE /dev/centos_bgd-ngnix1/root
Size of logical volume centos_bgd-ngnix1/root changed from <95.12 GiB (24350 extents) to <995.12 GiB (254750 extents).
Logical volume centos_bgd-ngnix1/root successfully resized.
# 或者只添加100G
[root@ywcsb ~]# lvextend -L 100G /dev/centos_bgd-ngnix1/root
重定义空间大小
[root@bgd-mysql3 ~]# resize2fs /dev/centos_bgd-ngnix1/root
meta-data=/dev/mapper/centos_bgd--ngnix1-root isize=512 agcount=4, resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/ubuntu-vg/root is mounted on /; on-line resizing required
old_desc_blocks = 7, new_desc_blocks = 13
The filesystem on /dev/ubuntu-vg/root is now 51989504 (4k) blocks long.
# 或者使用xfs_growfs
[root@ywcsb ~]#xfs_growfs /dev/centos_bgd-ngnix1/root
发表评论
共 0 条评论
暂无评论