This article will guide you how you can add the swap space on Oracle Linux 8.x operating system.
In this method we will use the swap file for adding it to the swap memory.
Currently allocated swap memory – 8 GB
New swap memory to be added – 32 GB
[root@racnode1 ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 756G 0 756G 0% /dev tmpfs 756G 4.0K 756G 1% /dev/shm tmpfs 756G 27M 756G 1% /run tmpfs 756G 0 756G 0% /sys/fs/cgroup /dev/mapper/ol-root 100G 2.8G 98G 3% / /dev/sda2 945M 223M 658M 26% /boot /dev/sda1 488M 5.2M 483M 2% /boot/efi /dev/mapper/ol-oracle 500G 3.6G 497G 1% /oracle /dev/mapper/ol-ortrace 500G 3.6G 497G 1% /oracle/trace tmpfs 152G 0 152G 0% /run/user/0 [root@racnode1 ~]#Create swap file with 32GB size:
[root@racnode1 ~]# dd if=/dev/zero of=/root/newswap bs=1M count=32768 32768+0 records in 32768+0 records out 34359738368 bytes (34 GB, 32 GiB) copied, 10.0707 s, 3.4 GB/s [root@racnode1 ~]#Verify the created swap file:
[root@racnode1 ~]# ls /root/newswap /root/newswap [root@racnode1 ~]# ls -l /root/newswap -rw-r--r--. 1 root root 34359738368 Mar 15 13:00 /root/newswap Enable swap file properties on newly created file: [root@racnode1 ~]# chmod 600 /root/newswap [root@racnode1 ~]# mkswap /root/newswap Setting up swapspace version 1, size = 32 GiB (34359734272 bytes) no label, UUID=24da1634-9c5c-41df-a9fb-5e53ff002d49 [root@racnode1 ~]#Add the new swapfile to /etc/fstab for boot persistency:
[root@racnode1 ~]# vi /etc/fstabVerify the newly added swap space:
[root@racnode1 ~]# swapon -sq Filename Type Size Used Priority /dev/dm-1 partition 8388604 0 -2 /root/newswap file 33554428 0 -3 [root@racnode1 ~]# swapon -s Filename Type Size Used Priority /dev/dm-1 partition 8388604 0 -2 /root/newswap file 33554428 0 -3 [root@racnode1 ~]# free total used free shared buff/cache available Mem: 1584370860 1683740 1548134020 26752 34553100 1575477784 Swap: 41943032 0 41943032 [root@racnode1 ~]#Thanks for reading 😊 Regards, ZAHEER
Comments