1 月 032014
 

增加物理卷(PV),可以使用整个磁盘(/dev/sda),也可以使用某一个分区(/dev/sda3)

使用fdisk /dev/sda创建新分区

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 8355 66595840 8e Linux LVM
 /dev/sda3 8355 16709 67106178+ 83 Linux

创建新分区后重启系统

创建物理卷

[root@www ~]# pvcreate /dev/sda3
 Physical volume "/dev/sda3" successfully created
[root@www ~]#

查看当前卷组大小

[root@www ~]# vgs
 VG #PV #LV #SN Attr VSize VFree
 vg_production 1 3 0 wz--n- 63.51g 0
[root@www ~]#

扩展卷组,将新创建的物理卷加入卷组

[root@www ~]# vgextend vg_production /dev/sda3
 Volume group "vg_production" successfully extended
[root@www ~]#

查看扩展后卷组大小

[root@www ~]# vgs
 VG #PV #LV #SN Attr VSize VFree
 vg_production 2 3 0 wz--n- 127.50g 64.00g
[root@www ~]#

查看卷组详细信息及空闲可用磁盘容量

[root@www ~]# vgdisplay
 --- Volume group ---
 VG Name vg_production
 System ID
 Format lvm2
 Metadata Areas 2
 Metadata Sequence No 5
 VG Access read/write
 VG Status resizable
 MAX LV 0
 Cur LV 3
 Open LV 3
 Max PV 0
 Cur PV 2
 Act PV 2
 VG Size 127.50 GiB
 PE Size 4.00 MiB
 Total PE 32641
 Alloc PE / Size 16258 / 63.51 GiB
 Free PE / Size 16383 / 64.00 GiB
 VG UUID QF7YRT-rgDz-4Qdu-dYQH-P60A-ATlr-hASaIG

[root@www ~]#

扩展现有逻辑分区的大小

[root@www ~]# lvextend -L +62G /dev/vg_production/lv_root
 Extending logical volume lv_root to 112.00 GiB
 Logical volume lv_root successfully resized
[root@www ~]#

扩展逻辑分区后更新文件系统信息

[root@www ~]# resize2fs /dev/vg_production/lv_root
 resize2fs 1.41.12 (17-May-2010)
 Filesystem at /dev/vg_production/lv_root is mounted on /; on-line resizing required
 old desc_blocks = 4, new_desc_blocks = 7
 Performing an on-line resize of /dev/vg_production/lv_root to 29360128 (4k) blocks.
 The filesystem on /dev/vg_production/lv_root is now 29360128 blocks long.

查看磁盘分区及逻辑卷大小

[root@www ~]# df -h
 文件系统 容量 已用 可用 已用%% 挂载点
 /dev/mapper/vg_production-lv_root
 111G 3.4G 106G 4% /
 tmpfs 1.9G 0 1.9G 0% /dev/shm
 /dev/sda1 485M 34M 426M 8% /boot
 /dev/mapper/vg_production-lv_home
 12G 157M 11G 2% /home
 [root@www ~]#