1、查看磁盘空间
[root@bgd-mysql3 ~]# 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
2、创建物理卷
[root@bgd-mysql3 ~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
3、查看物理卷
--- 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
4、查看当前卷组
[root@bgd-mysql3 ~]# 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
5、扩展卷组,将/dev/sdb物理卷加到VG中
[root@bgd-mysql3 ~]# vgextend centos_bgd-ngnix1 /dev/sdb
Volume group "centos_bgd-ngnix1" successfully extended
6、查看逻辑卷
[root@bgd-mysql3 ~]# 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
7、将VG空间划分到LV
[root@bgd-mysql3 ~]# 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.
8、重定义空间大小
[root@bgd-mysql3 ~]# xfs_growfs /dev/centos_bgd-ngnix1/root
meta-data=/dev/mapper/centos_bgd--ngnix1-root isize=512 agcount=4, agsize=6233600 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=24934400, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=12175, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 24934400 to 260864000
以上是OS7的命令,OS6的命令如下
resize2fs /dev/mapper/centos-root ---centos
9、查看空间
[root@bgd-mysql3 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos_bgd--ngnix1-root 996G 1.7G 994G 1% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 8.8M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 184M 831M 19% /boot
tmpfs 783M 0 783M 0% /run/user/0