Linux: Resizing Swap Online

Hi all!
Quick one to resize swap online:

[root@server-db ~]# swapon -s
Filename                                Type            Size    Used    Priority
/dev/mapper/rootvg-lvswap              partition       5242872 373624  -1
[root@server-db ~]# vgs
VG                #PV #LV #SN Attr   VSize   VFree
[...]
rootvg              1   6   0 wz--n- 135.69G 5.69G
[...]
[root@server-db ~]# lvextend -L +2048M /dev/mapper/rootvg-lvswap
Extending logical volume lvswap to 7.00 GB
Logical volume lvswap successfully resized
[root@server-db ~]# vgs
VG                #PV #LV #SN Attr   VSize   VFree
[...]
rootvg              1   6   0 wz--n- 135.69G 3.69G
[...]
[root@server-db ~]# mkswap /dev/mapper/rootvg-lvswap
Setting up swapspace version 1, size = 7516188 kB
[root@server-db ~]# swapoff /dev/mapper/rootvg-lvswap
[root@server-db ~]# swapon /dev/mapper/rootvg-lvswap
[root@server-db ~]# swapon -s
Filename                                Type            Size    Used    Priority
/dev/mapper/rootvg-lvswap              partition       7516188 373624  -1

See ya!
Matheus.

One comment

  1. Anonymous

    This is not “online” swap resizing… you can’t mkswap a partition currently in use:
    mkswap: error: /dev/mapper/rootvg-lvswap is mounted; will not make swapspace
    You have to swapoff; mkswap; swapon, and that’s not very “online”.

Leave a Reply to AnonymousCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from grepOra

Subscribe now to keep reading and get access to the full archive.

Continue reading