[root@rac01 ~]# vgdisplay VolGroup
--- Volume group ---
VG Name VolGroup
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 49.51 GiB
PE Size 4.00 MiB
Total PE 12674
Alloc PE / Size 7680 / 30.00 GiB
Free PE / Size 4994 / 19.51 GiB
VG UUID HYL3bE-tccs-SUil-i75E-qUqG-d6dD-6jzj2u
这里看到swap对应的逻辑卷组还有多余的19G空间,所以我们可以直接扩容swap分区
2)卸载swap分区
[root@rac01 ~]# swapoff /dev/mapper/VolGroup-lv_swap
3)扩展swap逻辑卷
[root@rac01 ~]# lvextend -L +6GB /dev/mapper/VolGroup-lv_swap
Size of logical volume VolGroup/lv_swap changed from 10.00 GiB (2560 extents) to 16.00 GiB (4096 extents).
Logical volume lv_swap successfully resized.
[root@rac01 ~]# fdisk -l /dev/mapper/VolGroup-lv_swap
Disk /dev/mapper/VolGroup-lv_swap: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
4)格式化新swap分区
[root@rac01 ~]# mkswap /dev/mapper/VolGroup-lv_swap
mkswap: /dev/mapper/VolGroup-lv_swap: warning: don't erase bootbits sectors
on whole disk. Use -f to force.
Setting up swapspace version 1, size = 16777212 KiB
no label, UUID=5cef886d-5537-4aa0-88d8-f4ce92e01698
5)重新挂在swap分区
[root@rac01 ~]# swapon /dev/mapper/VolGroup-lv_swap
[root@rac01 ~]# free -g
total used free shared buffers cached
Mem: 15 8 7 0 0 8
-/+ buffers/cache: 0 15
Swap: 15 0 15
至此swap分区扩容完毕,但如果我们卷组容量不够的情况下如何扩展呢?首先肯定是扩展卷组,然后再重复上面的步骤。下面将扩展卷组的方法在下面补充
磁盘添加
[root@rac02 ~]# fdisk -l |grep sd
Disk /dev/sda: 53.7 GB, 53687091200 bytes
/dev/sda1 * 1 64 512000 83 Linux
/dev/sda2 64 6528 51915776 8e Linux LVM
Disk /dev/sdb: 107.4 GB, 107374182400 bytes
Disk /dev/sdc: 8589 MB, 8589934592 bytes
Disk /dev/sdd: 5368 MB, 5368709120 bytes
/dev/sdd1 1 652 5237158+ 83 Linux
Disk /dev/sdf: 107.4 GB, 107374182400 bytes
/dev/sdf1 1 13054 104856223+ 83 Linux
Disk /dev/sde: 5368 MB, 5368709120 bytes
/dev/sde1 1 652 5237158+ 83 Linux
Disk /dev/sdg: 10.7 GB, 10737418240 bytes
/dev/sdg1 1 1305 10482381 83 Linux
6)创建新的物理卷
[root@rac02 ~]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created
7)扩展逻辑卷组