[root@nagios_client1 ~]# lvs #查看逻辑卷
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv_root VolGroup -wi-ao---- 8.51g
lv_swap VolGroup -wi-ao---- 1.00g
[root@nagios_client1 ~]# vgs #查卷组
VG #PV #LV #SN Attr VSize VFree
VolGroup 1 2 0 wz--n- 9.51g 0
[root@nagios_client1 ~]# pvs #查物理卷
PV VG Fmt Attr PSize PFree
/dev/sda2 VolGroup lvm2 a-- 9.51g 0
查看主机总线号
[root@nagios_client1 ~]# ls /sys/class/scsi_host/
host0 host1 host2
重新扫描SCSI总线来添加设备
[root@nagios_client1 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@nagios_client1 ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
[root@nagios_client1 ~]# echo "- - -" > /sys/class/scsi_host/host2/scan
用fdisk /dev/sda 进行分区,将剩余空间创建一个sda3主分区。ID格式为8e,创建好分区后按t 再按 8e 设置
partprobe可以修改kernel中分区表,使kernel重新读取分区表。
[root@nagios_client1 ~]# rpm -q parted
package parted is not installed
[root@nagios_client1 ~]# yum install parted
[root@nagios_client1 ~]# rpm -q parted
parted-2.1-29.el6.x86_64
使用partprobe重载分区也只能是对不同的硬盘才能及时生效。对于同一块硬盘,修改过分区信息后,必须重启系统才能使修改过的分区信息生效。
[root@nagios_client1 ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
[root@nagios_client1 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 VolGroup lvm2 a-- 9.51g 0
/dev/sda3 lvm2 --- 40.00g 40.00g #新创建出来的(PV)物理卷
#查看原来VG卷:
[root@nagios_client1 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup 1 2 0 wz--n- 9.51g 0
卷组VolGroup添加新的物理卷sda3来增大卷组的容量:
[root@nagios_client1 ~]# vgextend VolGroup /dev/sda3
Volume group "VolGroup" successfully extended
#查看扩展后的VG卷:
[root@nagios_client1 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup 2 2 0 wz--n- 49.50g 40.00g
查看逻辑卷的绝对路径:
[root@nagios_client1 ~]# lvdisplay
--- Logical volume ---
LV Path /dev/VolGroup/lv_root
....
扩展逻辑卷的大小
[root@nagios_client1 ~]# lvextend -l +100%free /dev/VolGroup/lv_root
Size of logical volume VolGroup/lv_root changed from 8.51 GiB (2178 extents) to 48.50 GiB (12417 extents).
Logical volume lv_root successfully resized
最后要使用resizefs2命令重新加载逻辑卷的大小才能生效:
[root@nagios_client1 ~]# resize2fs /dev/VolGroup/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 4
Performing an on-line resize of /dev/VolGroup/lv_root to 12715008 (4k) blocks.
The filesystem on /dev/VolGroup/lv_root is now 12715008 blocks long.