Linux使用LVM邏輯卷擴容
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.
Linux使用LVM邏輯卷擴容