Extend Swap in Oracle Linux   Recently updated !


The client has also configured a small Swap mountpoint, when looking at all memory available on the server. Oracle documentation says this:

The VM has 116GB memory, and 32GB reserved for HugePages. The actual swap mountpoint is 4GB big and, based on the Oracle Server Configuration Checklist for 19c, the swap mountpoint should be in this case 16GB.

I’m using Oracle Linux 9, xfs filesystems. I’ll increase the swap mountpoint online, with the databases running.

Please check the previous two posts for information on Extending other partitions types:

Increase swap mountpoint from 4GB to 16GB

The current status can be checked using both parted and lsblk. Parted uses base10 units which shows the as 831GB big, while lsblk uses base2 units, showing the /dev/sda as 774GiB big. From this only ~84GB are mapped (“End” of parted output). This means we have a lot of free disk, no action is needed in VMWare (see Part 1 blog post for more on this).?

[root@vmware-vm01 ~]# parted /dev/sda print
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 831GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                  Flags
 1      1049kB  263MB   262MB   fat16        EFI System Partition  boot, esp
 2      263MB   1337MB  1074MB  xfs
 3      1337MB  84.0GB  82.7GB                                     lvm

[root@vmware-vm01 ~]# lsblk -p /dev/sda
NAME                                         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
/dev/sda                                       8:0    0   774G  0 disk 
├─/dev/sda1                                    8:1    0   250M  0 part /boot/efi
├─/dev/sda2                                    8:2    0     1G  0 part /boot
└─/dev/sda3                                    8:3    0    77G  0 part 
  ├─/dev/mapper/ol_vmware-vm01-root          252:0    0    10G  0 lvm  /
  ├─/dev/mapper/ol_vmware-vm01-swap          252:1    0     4G  0 lvm  [SWAP]
  ├─/dev/mapper/ol_vmware-vm01-var_log_audit 252:2    0     1G  0 lvm  /var/log/audit
  ├─/dev/mapper/ol_vmware-vm01-u01           252:3    0    50G  0 lvm  /u01
  ├─/dev/mapper/ol_vmware-vm01-home          252:4    0     5G  0 lvm  /home
  ├─/dev/mapper/ol_vmware-vm01-var_log       252:5    0     2G  0 lvm  /var/log
  └─/dev/mapper/ol_vmware-vm01-var           252:6    0     5G  0 lvm  /var

The Swap mountpoint is in the /dev/sda3 partition, which have several logical volumes. I need first to increase the size of this partition at least by 12GiB (about 13GB) to hold a bigger swap mountpoint.

[root@vmware-vm01 ~]# parted /dev/sda "resizepart 3 100G"                     
Information: You may need to update /etc/fstab.

[root@vmware-vm01 ~]# lsblk -p /dev/sda                 
NAME                                         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
/dev/sda                                       8:0    0   774G  0 disk 
├─/dev/sda1                                    8:1    0   250M  0 part /boot/efi
├─/dev/sda2                                    8:2    0     1G  0 part /boot
└─/dev/sda3                                    8:3    0  91.9G  0 part 
  ├─/dev/mapper/ol_vmware-vm01-root          252:0    0    10G  0 lvm  /
  ├─/dev/mapper/ol_vmware-vm01-swap          252:1    0     4G  0 lvm  [SWAP]
  ├─/dev/mapper/ol_vmware-vm01-var_log_audit 252:2    0     1G  0 lvm  /var/log/audit
  ├─/dev/mapper/ol_vmware-vm01-u01           252:3    0    50G  0 lvm  /u01
  ├─/dev/mapper/ol_vmware-vm01-home          252:4    0     5G  0 lvm  /home
  ├─/dev/mapper/ol_vmware-vm01-var_log       252:5    0     2G  0 lvm  /var/log
  └─/dev/mapper/ol_vmware-vm01-var           252:6    0     5G  0 lvm  /var

And resize the Physical Volume:

[root@vmware-vm01 ~]# pvresize /dev/sda3
  Physical volume "/dev/sda3" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized

Next, it is needed to deactivate temporarily swap. This should not be a problem when we have enough free memory. This operation takes a while.

[root@vmware-vm01 ~]# swapoff -a

[root@vmware-vm01 ~]# free -h
               total        used        free      shared  buff/cache   available
Mem:           114Gi        39Gi       1.5Gi       561Mi        74Gi        74Gi
Swap:             0B          0B          0B

Now that swap mountpoint is not used, I can extend the size of the logical volume.

[root@vmware-vm01 ~]# lvextend --size +12G /dev/mapper/ol_vmware-vm01-swap
  Size of logical volume ol_vmware-vm01/swap changed from 4.00 GiB (1024 extents) to 16.00 GiB (4096 extents).
  Logical volume ol_vmware-vm01/swap successfully resized.

[root@vmware-vm01 ~]# lsblk -p /dev/sda
NAME                                         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
/dev/sda                                       8:0    0  774G  0 disk 
├─/dev/sda1                                    8:1    0  250M  0 part /boot/efi
├─/dev/sda2                                    8:2    0    1G  0 part /boot
└─/dev/sda3                                    8:3    0 91.9G  0 part 
  ├─/dev/mapper/ol_vmware-vm01-root          252:0    0   10G  0 lvm  /
  ├─/dev/mapper/ol_vmware-vm01-swap          252:1    0   16G  0 lvm  
  ├─/dev/mapper/ol_vmware-vm01-var_log_audit 252:2    0    1G  0 lvm  /var/log/audit
  ├─/dev/mapper/ol_vmware-vm01-u01           252:3    0   50G  0 lvm  /u01
  ├─/dev/mapper/ol_vmware-vm01-home          252:4    0    5G  0 lvm  /home
  ├─/dev/mapper/ol_vmware-vm01-var_log       252:5    0    2G  0 lvm  /var/log
  └─/dev/mapper/ol_vmware-vm01-var           252:6    0    5G  0 lvm  /var  

And finally I can enable swap again. This means, assign the logical volume to swap usage:

[root@vmware-vm01 ~]# mkswap --label SWAP /dev/mapper/ol_vmware-vm01-swap
mkswap: /dev/mapper/ol_vmware-vm01-swap: warning: wiping old swap signature.
Setting up swapspace version 1, size = 16 GiB (17179865088 bytes)
LABEL=SWAP, UUID=98a8b003-d33e-4c28-b1db-13b98b95ff4c

[root@vmware-vm01 ~]# swapon -a

Final result is here:

[root@vmware-vm01 ~]# free -h
               total        used        free      shared  buff/cache   available
Mem:           114Gi        39Gi       1.9Gi       561Mi        74Gi        74Gi
Swap:           15Gi          0B        15Gi

[root@vmware-vm01 ~]# lsblk -p /dev/sda
NAME                                         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
/dev/sda                                       8:0    0  774G  0 disk 
├─/dev/sda1                                    8:1    0  250M  0 part /boot/efi
├─/dev/sda2                                    8:2    0    1G  0 part /boot
└─/dev/sda3                                    8:3    0 91.9G  0 part 
  ├─/dev/mapper/ol_vmware-vm01-root          252:0    0   10G  0 lvm  /
  ├─/dev/mapper/ol_vmware-vm01-swap          252:1    0   16G  0 lvm  [SWAP]
  ├─/dev/mapper/ol_vmware-vm01-var_log_audit 252:2    0    1G  0 lvm  /var/log/audit
  ├─/dev/mapper/ol_vmware-vm01-u01           252:3    0   50G  0 lvm  /u01
  ├─/dev/mapper/ol_vmware-vm01-home          252:4    0    5G  0 lvm  /home
  ├─/dev/mapper/ol_vmware-vm01-var_log       252:5    0    2G  0 lvm  /var/log
  └─/dev/mapper/ol_vmware-vm01-var           252:6    0    5G  0 lvm  /var

Leave a comment

Your email address will not be published. Required fields are marked *