2.9.3 Extending the Swap Partition

This procedure describes how to extend the size of the swap partition.

Note:

It is recommended to extend the swap partition while the system is running no Oracle databases. Consequently, this procedure requires a maintenance window that allows you to shut down all Oracle databases on the system.

Keep at least 1 GB of free space in the VGExaDb volume group to be used for the Logical Volume Manager (LVM) snapshot created by the dbnodeupdate.sh utility during software maintenance. If you make snapshot-based backups of the / (root) and /u01 directories by following the steps in "Creating a Snapshot-Based Backup of Oracle Linux Database Server", then keep at least 6 GB of free space in the VGExaDb volume group.

  1. Collect information about the current environment.
    1. Use the swapon command to identify the swap partition.
      # swapon -s
      Filename    Type        Size       Used   Priority
      /dev/dm-2   partition   25165816   0      -1
      
    2. Use the lvm lvscan command to display the logical volumes and take note of the logical volume named LVDbSwap1.
      # lvm lvscan
      ACTIVE '/dev/VGExaDb/LVDbSys1' [30.00 GiB] inherit
      ACTIVE '/dev/VGExaDb/LVDbSys2' [30.00 GiB] inherit
      ACTIVE '/dev/VGExaDb/LVDbSwap1' [24.00 GiB] inherit
      ACTIVE '/dev/VGExaDb/LVDbOra1' [103.00 GiB] inherit
      ACTIVE '/dev/VGExaDb/LVDoNotRemoveOrUse' [1.00 GiB] inherit
      
    3. Confirm the association between the swap logical volume (/dev/VGExaDb/LVDbSwap1) and the partition (/dev/dm-2) listed in the swapon command.
      # ls -l /dev/VGExaDb/LVDbSwap1
      lrwxrwxrwx 1 root root 7 Mar 22 15:05 /dev/VGExaDb/LVDbSwap1 -> ../dm-2
    4. Use the vgdisplay command to display the current volume group configuration, which includes information about available free space.
      # vgdisplay
        --- Volume group ---
        VG Name               VGExaDb
        System ID            
        Format                lvm2
        Metadata Areas        1
        Metadata Sequence No  4
        VG Access             read/write
        VG Status             resizable
        MAX LV                0
        Cur LV                3
        Open LV               3
        Max PV                0
        Cur PV                1
        Act PV                1
        VG Size               556.80 GB
        PE Size               4.00 MB
        Total PE              142541
        Alloc PE / Size       39424 / 154.00 GB
        Free  PE / Size       103117 / 402.80 GB
        VG UUID               po3xVH-9prk-ftEI-vijh-giTy-5chm-Av0fBu
      
    5. Use the pvdisplay command to display the name of the physical device created by LVM and used with the operating system.
      # pvdisplay
        --- Physical volume ---
        PV Name               /dev/sda2
        VG Name               VGExaDb
        PV Size               556.80 GB / not usable 2.30 MB
        Allocatable           yes
        PE Size (KByte)       4096
        Total PE              142541
        Free PE               103117
        Allocated PE          39424
        PV UUID               Eq0e7e-p1fS-FyGN-zrvj-0Oqd-oUSb-55x2TX
  2. Shut down all of the Oracle database instances on the server.
  3. Examine the memory and swap status by using the free -m command.
    # free -m
                  total        used        free      shared  buff/cache   available
    Mem:         515116      356670       91593       21777       66853      122728
    Swap:         16383          34       16349

    Examine the output and continue to the next step if the amount of used swap space is small (ideally zero) or much lower than the available memory.

    If the amount of used swap space exceeds the amount of available memory, then examine the system and stop processes that are using the swap space.

  4. Disable the swap partition.
    # swapoff -a
  5. Extend the partition by using the lvextend command.

    In this example, the logical volume is expanded by 10 GB.

    # lvextend -L +10G /dev/VGExaDb/LVDbSwap1
  6. Re-create the swap space.
    # mkswap -L SWAP /dev/VGExaDb/LVDbSwap1
  7. Re-enable the swap partition.
    # swapon -a
  8. View the updated swap details and confirm the updated size.
    # swapon -s
    Filename    Type        Size       Used   Priority
    /dev/dm-2   partition   35651576   0      -1
    
  9. Restart the Oracle database instances on the server.