扩容之前的磁盘状况
[root@localhost ~]# df -h
文件系统 容量 已用 可用已用%%挂载点
/dev/mapper/VolGroup-lv_root 5.3G 2.5G 2.6G 50% /
tmpfs 538M 0 538M 0% /dev/shm
/dev/sda1 485M 30M 430M 7% /boot
[root@localhost ~]# fdisk -l
Disk /dev/sda: 8589 MB, 8589934592 bytes
...............
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 1045 7875584 8e Linux LVM
Disk /dev/mapper/VolGroup-lv_root: 5779 MB, 5779750912 bytes
........
Disk /dev/mapper/VolGroup-lv_swap: 2281 MB, 2281701376 bytes
.........
此次扩容的方案为:
1、加1个5G的空间给/
2、加1个10G的空间给/oracle
(一) 在VM中加一个15G的磁盘
重启后#fdisk –l可以看到新的磁盘已经认出来了。查看磁盘是否已经添加
Disk /dev/sdb: 16.1 GB, 16106127360 bytes
...........................
(二)创建一个物理卷(PV)
1.#pvcreate /dev/sdb
2.查看系统PV的情况:
2.[root@localhost ~]# pvdisplay:查看空间情况
--- Physical volume ---
PV Name /dev/sda2 //原有硬盘上的PV
VG Name VolGroup
PV Size 7.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 1922
Free PE 0
Allocated PE 1922
PV UUID SGH1dY-4tp2-Nr1a-w93Z-V4LA-pQBh-VGzzTH
"/dev/sdb" is a new physical volume of "15.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb
VG Name //新建的PV的VG name是空的,下一步就是把PV加入VG
PV Size 15.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 8TZUlz-YyUp-RBvf-lSzm-7MgG-DSZS-qNqX1Z
查看原VG的情况
[root@localhost ~]#3. vgdisplay
--- Volume group ---
VG Name VolGroup //注意记录此名字,扩容时将新的pv加入指定的名字
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 7.51 GiB
PE Size 4.00 MiB
Total PE 1922
AllocPE / Size 1922 / 7.51 GiB:查看磁盘情况
Free PE / Size 0 / 0
VG UUID FnUsmX-s284-GeRK-hJNJ-BbIG-Vpe7-OuFZE1
4.[root@localhost ~]# vgextend VolGroup /dev/sdb
#扩展卷组,将/dev/sdb物理卷添加到VolGroup卷组中
Volume group "VolGroup" successfully extended
再查看VG情况,可以看到VG大小变化,空余空间。
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name VolGroup
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 22.50 GiB
PE Size 4.00 MiB
Total PE 5761
AllocPE / Size 1922 / 7.51 GiB
Free PE / Size 3839 / 15.00 GiB
VG UUID FnUsmX-s284-GeRK-hJNJ-BbIG-Vpe7-OuFZE1
(四)将新的VG空间划入LV(扩容lv_root)
5.#直接扩展5G给/root分区,不用umount,也不需要重启
# lvextend -L +5G /dev/mapper/VolGroup-lv_root
或者:lvextend -l+5387 /dev/mapper/VolGroup-lv_root
Extending logical volume lv_root to 10.38 GiB
Logical volume lv_root successfully resized
也可以使用命令
# lvextend -l +30%FREE /dev/mapper/VolGroup-lv_root
此时,如果有df命令查看的话,会发现root空间并没有增加的.还需要执行以下两步操作才可以.
5.#检查/root逻辑卷
#e2fsck -f /dev/mapper/VolGroup-lv_root
6.#重新定义分区大小----刷新
#resize2fs /dev/mapper/VolGroup-lv_root
查看/目录大小
原文地址:http://xiang666.blog.51cto.com/10917913/1966952