[root@nagios_client1 ~]# lvs #View logical volumes
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 #Check volume group
VG #PV #LV #SN Attr VSize VFree
VolGroup 1 2 0 wz - n- 9.51g 0
[root@nagios_client1 ~]# pvs #Check physical volume
PV VG Fmt Attr PSize PFree
/dev/sda2 VolGroup lvm2 a-- 9.51g 0
View host bus number
[root@nagios_client1 ~]# ls /sys/class/scsi_host/
host0 host1 host2
Rescan the SCSI bus to add devices
[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
Use fdisk /dev/sda to partition, and create a sda3 primary partition with the remaining space. The ID format is 8e, after creating the partition, press t and then press 8e to set
Partprobe can modify the partition table in the kernel, so that the kernel can re-read the partition table.
[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
Using partprobe to reload partitions can only take effect in time for different hard disks. For the same hard disk, after modifying the partition information, you must restart the system to make the modified partition information take effect.
[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 #Newly created (PV) physical volume
#View the original VG volume:
[root@nagios_client1 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup 1 2 0 wz - n- 9.51g 0
The volume group VolGroup adds a new physical volume sda3 to increase the capacity of the volume group:
[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.