CentOS 6
查看
fdisk -l
扩容根分区至45G
# 命令格式
# lvextend -L{扩容至目标大小} {扩容的卷名}
lvextend -L45G /dev/mapper/vg_centos6-LogVol03
应用扩容
# 命令格式
# resize2fs {扩容的卷名}
resize2fs /dev/mapper/vg_centos6-LogVol03
CentOS 7 (xfs文件系统)
fdisk -l
扩容opt至30G
# 命令格式
# lvextend -L{扩容至目标大小} {扩容的卷名}
lvextend -L30G /dev/mapper/centos-opt
应用扩容
xfs_growfs /dev/mapper/centos-opt
扩容根目录
查看磁盘信息
fdisk -l
# 获得要空闲的空间标识 /dev/vdb
新增分区
fdisk /dev/vdb
...
Building a new DOS disklabel with disk identifier 0x232defba.
Command (m for help): **p**
...
Device Boot Start End Blocks Id System
Command (m for help): **n**
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): **p**
Partition number (1-4, default 1): **1**
First sector (2048-209715199, default 2048): **{回车}**
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): **{回车}**
...
Partition 1 of type Linux and of size 100 GiB is set
Command (m for help): **t**
Selected partition 1
Hex code (type L to list all codes): **L**
...
1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT
1e Hidden W95 FAT1 80 Old Minix
Hex code (type L to list all codes): **8e**
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): **p**
...
/dev/sdb1 2048 209715199 104856576 8e Linux LVM
Command (m for help): **w**
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
创建物理卷
pvcreate /dev/vdb1
查看物理卷信息
pvdisplay
获得目录分区标识 查看卷组信息
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 49.51 GiB
PE Size 4.00 MiB
Total PE 12674
Alloc PE / Size 12664 / 49.47 GiB
Free PE / Size 10 / 40.00 MiB
VG UUID aN2D2P-Rk1y-wGFz-5l2I-5CcD-7s88-Z8czc7
将新增加的分区/dev/sdb1加入到根目录分区centos_mb-centos7中
vgextend centos /dev/vdb1
重新查看卷组信息
vgdisplay
进行卷扩容
lvextend -l +100%FREE /dev/mapper/centos-root
应用扩容
xfs_growfs /dev/mapper/centos-root
最后,查看磁盘信息可以看出根目录分区大小已成功扩容
df -h