Check out current size of volume group - is there enough space to extend the swap?
[root@sbt-centos ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_sbtcentos 1 3 0 wz--n- 99.51g 0
No free space on the VG. So add another disk to the VG:-
[root@sbt-centos ~]# vgextend vg_sbtcentos /dev/sdb
No physical volume label read from /dev/sdb
Physical volume "/dev/sdb" successfully created
Volume group "vg_sbtcentos" successfully extended
Check space has been added:-
[root@sbt-centos ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_sbtcentos 2 3 0 wz--n- 100.50g 1020.00m
Check current swap size:-
[root@sbt-centos ~]# free -m
total used free shared buffers cached
Mem: 1878 523 1354 0 28 184
-/+ buffers/cache: 310 1568
Swap: 4031 0 4031
Turn off the swap device:-
[root@sbt-centos ~]# swapoff -v /dev/vg_sbtcentos/lv_swap
swapoff on /dev/vg_sbtcentos/lv_swap
Resize the LV that the swap lives on:-
[root@sbt-centos ~]# lvresize -L +512M /dev/vg_sbtcentos/lv_swap
Extending logical volume lv_swap to 4.44 GiB
Logical volume lv_swap successfully resized
Recreate the swapspace on the extended swap LV (note the UUID has changed, if you use UUID in /etc/fstab you'll have to amend accordingly):-
[root@sbt-centos ~]# mkswap /dev/vg_sbtcentos/lv_swap
mkswap: /dev/vg_sbtcentos/lv_swap: warning: don't erase bootbits sectors
on whole disk. Use -f to force.
Setting up swapspace version 1, size = 4653052 KiB
no label, UUID=3e5bd2cf-048e-4c8b-a631-a00ef6a5664a
And turn the swap device back on:-
[root@sbt-centos ~]# swapon -va
swapon on /dev/mapper/vg_sbtcentos-lv_swap
swapon: /dev/mapper/vg_sbtcentos-lv_swap: found swap signature: version 1, page-size 4, same byte order
swapon: /dev/mapper/vg_sbtcentos-lv_swap: pagesize=4096, swapsize=4764729344, devsize=4764729344
And finally, show the new swap space:-
[root@sbt-centos ~]# free -m
total used free shared buffers cached
Mem: 1878 523 1354 0 28 184
-/+ buffers/cache: 310 1568
Swap: 4543 0 4543
Alternatively, if there's spare space on an LV it could be reduced and allocated to the swap LV. See here http://linuxscrapbook.blogspot.co.uk/2014/02/reduce-lv-and-file-system.html
No comments:
Post a Comment