LVM的工作方式
LVM管理工具集
[root@wendang ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 50G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 15G 0 part
│ ├─centos-root 253:0 0 13.4G 0 lvm /
│ └─centos-swap 253:1 0 1.6G 0 lvm [SWAP]
└─sda3 8:3 0 10G 0 part
sr0 11:0 1 1024M 0 rom
[root@wendang ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created.
[root@wendang ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- <15.00g 0
[root@wendang ~]# vgextend centos /dev/sda3
Volume group "centos" successfully extended
[root@wendang ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 2 2 0 wz--n- 24.99g <10.00g
[root@wendang ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 13.39g
swap centos -wi-ao---- 1.60g
[root@wendang ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 14G 1.1G 13G 8% /
devtmpfs 908M 0 908M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 8.8M 911M 1% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/sda1 1014M 145M 870M 15% /boot
tmpfs 184M 0 184M 0% /run/user/0
".
[root@wendang ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 14G 1.1G 13G 8% /
devtmpfs 908M 0 908M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 8.8M 911M 1% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/sda1 1014M 145M 870M 15% /boot
tmpfs 184M 0 184M 0% /run/user/0
[root@wendang ~]#
[root@wendang ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 50G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 15G 0 part
│ ├─centos-root 253:0 0 13.4G 0 lvm /
│ └─centos-swap 253:1 0 1.6G 0 lvm [SWAP]
└─sda3 8:3 0 10G 0 part
sr0 11:0 1 1024M 0 rom
[root@wendang ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos
PV Size <15.00 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 3839
Free PE 0
Allocated PE 3839
PV UUID mh1zwp-wM9K-iSCl-5fgJ-evDG-d3zZ-AozMWl
--- Physical volume ---
PV Name /dev/sda3
VG Name centos
PV Size 10.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 2559
Free PE 2559
Allocated PE 0
PV UUID IZJrH3-UswX-QXNe-Twih-oAR5-6cL3-l0LKGI
[root@wendang ~]# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 24.99 GiB
PE Size 4.00 MiB
Total PE 6398
Alloc PE / Size 3839 / <15.00 GiB
Free PE / Size 2559 / <10.00 GiB
VG UUID ZJCdml-lltw-AUau-NBJL-1QH1-2SAn-S5gbUB
[root@wendang ~]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID hp3gdC-nima-jxLh-Be3r-c0dW-6n5S-Whnjfh
LV Write Access read/write
LV Creation host, time wendang, 2019-09-17 00:12:50 +0800
LV Status available
# open 2
LV Size 1.60 GiB
Current LE 410
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 ZbNoyJ-6c9y-APnh-oxYl-clan-KbQN-qAwqo2
LV Write Access read/write
LV Creation host, time wendang, 2019-09-17 00:12:50 +0800
LV Status available
# open 1
LV Size 13.39 GiB
Current LE 3429
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
[root@wendang ~]# lvextend -L +9G /dev/mapper/centos-root
Size of logical volume centos/root changed from 13.39 GiB (3429 extents) to 22.39 GiB (5733 extents).
Logical volume centos/root successfully resized.
[root@wendang ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=877824 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=3511296, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 3511296 to 5870592
[root@wendang ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 23G 1.1G 22G 5% /
devtmpfs 908M 0 908M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 8.8M 911M 1% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/sda1 1014M 145M 870M 15% /boot
tmpfs
184M 0 184M 0% /run/user/0
以下为纯命令
- fdisk /dev/sda 分区
- lsblk 列出分区
- partprobe 刷新分区
- lsblk
- pvcreate /dev/sda3 创建物理卷
- vgs 查看卷组
- vgextend centos /dev/sda3 扩展卷组
- lvs 查看逻辑卷
- df –h 查看挂载
- pvdisplay 显示物理卷
- vgdisplay 显示卷组
- lvdisplay 显示逻辑卷
- lvextend -L +9G /dev/mapper/centos-root 扩展逻辑卷
- xfs_growfs /dev/mapper/centos-root 刷新文件系统容量
- df –h 确认已经扩容
- ls
- pwd