How To Extend swap size in Linux
There could be situations where we need to extend the swap. Here i've a situation to extend the swap volume from 8 GB to 16 GB. Lets see how to do that:
Check the cureent Swap status:
[root@exampleserver ~]# free -m
total used free shared buffers cached
Mem: 515671 3101 512569 0 25 77
-/+ buffers/cache: 2998 512672
Swap: 8191 0 8191
Switch off the Swap.
[root@exampleserver ~]# swapoff -a
Extend the swap volume:
[root@exampleserver ~]# lvextend -L +8G /dev/mapper/vg_root-lv_swap
Size of logical volume vg_root/lv_swap changed from 8.00 GiB (2048 extents) to 16.00 GiB (4096 extents).
Logical volume lv_swap successfully resized
[root@exampleserver ~]#
Now activate the swap space to take added size.
[root@exampleserver ~]# mkswap /dev/mapper/vg_root-lv_swap
mkswap: /dev/mapper/vg_root-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=575854af-d3b0-4aca-926d-484f1ae3655f
[root@exampleserver ~]#
Now Switch on the Swap
[root@exampleserver ~]# swapon -a
Now Check Current swap status.
[root@exampleserver ~]# free -m
total used free shared buffers cached
Mem: 515671 3107 512563 0 25 77
-/+ buffers/cache: 3004 512666
Swap: 16383 0 16383
[root@exampleserver ~]#
If you do not have space to extend LV , then you can create a swap file and add it to swap space. Please click here to see the detailed procedure.
There could be situations where we need to extend the swap. Here i've a situation to extend the swap volume from 8 GB to 16 GB. Lets see how to do that:
Check the cureent Swap status:
[root@exampleserver ~]# free -m
total used free shared buffers cached
Mem: 515671 3101 512569 0 25 77
-/+ buffers/cache: 2998 512672
Swap: 8191 0 8191
Switch off the Swap.
[root@exampleserver ~]# swapoff -a
Extend the swap volume:
[root@exampleserver ~]# lvextend -L +8G /dev/mapper/vg_root-lv_swap
Size of logical volume vg_root/lv_swap changed from 8.00 GiB (2048 extents) to 16.00 GiB (4096 extents).
Logical volume lv_swap successfully resized
[root@exampleserver ~]#
Now activate the swap space to take added size.
[root@exampleserver ~]# mkswap /dev/mapper/vg_root-lv_swap
mkswap: /dev/mapper/vg_root-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=575854af-d3b0-4aca-926d-484f1ae3655f
[root@exampleserver ~]#
Now Switch on the Swap
[root@exampleserver ~]# swapon -a
Now Check Current swap status.
[root@exampleserver ~]# free -m
total used free shared buffers cached
Mem: 515671 3107 512563 0 25 77
-/+ buffers/cache: 3004 512666
Swap: 16383 0 16383
[root@exampleserver ~]#
If you do not have space to extend LV , then you can create a swap file and add it to swap space. Please click here to see the detailed procedure.
0 Comments