• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to Create and Remove Swap Memory in CLI on Oracle Linux 8.6

  • 00:43 cat /etc/os-release
  • 01:04 top
  • 01:15 lsblk
  • 01:27 fdisk /dev/sdb
  • 02:22 mkswap /dev/sdb1
  • 02:36 swapon /dev/sdb1
  • 02:50 vi /etc/fstab
  • 03:36 mount -a
  • 04:40 swapoff /dev/sdb1
{{postValue.id}}

To Create and Remove Swap Memory on Oracle Linux 8.6

Introduction:

Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM.

Procedure:

Step1: Check the OS version by using the below command

[root@linuxhelp linuxhelp]# cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="8.6"

Step 2: Check the available swap memory by using the below command

[root@linuxhelp linuxhelp]# top

snap1

Step 3: List the Disk by using the below command

[root@linuxhelp linuxhelp]# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    0   20G  0 disk
├─sda1        8:1    0    1G  0 part /boot
└─sda2        8:2    0   19G  0 part
  ├─ol-root 252:0    0   17G  0 lvm  /
  └─ol-swap 252:1    0    2G  0 lvm  [SWAP]
sdb           8:16   0    5G  0 disk
sr0          11:0    1 1024M  0 rom  

Step 4: create partions on /dev/sdb disk by using the below command

[root@linuxhelp linuxhelp]# fdisk /dev/sdb


Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xa3db419a.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-10485759, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-10485759, default 10485759): +2G

Created a new partition 1 of type 'Linux' and of size 2 GiB.

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): l
Hex code (type L to list all codes): 82
Changed type of partition 'Linux' to 'Linux swap / Solaris'.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Step 5: Format the partition /dev/sdb1 to the swap file system by using the below command
[root@linuxhelp linuxhelp]# mkswap /dev/sdb1
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=d83656e3-bd5c-4bdd-8cc7-3653a4c8001c

Step 6: Turn on the swap memory by using the below command

 [root@linuxhelp linuxhelp]# swapon /dev/sdb1

Step 7: Make fstab entry for swap partition by using the below command

 [root@linuxhelp linuxhelp]# vi /etc/fstab
/dev/sdb1  swap       swap    defaults     0 0

Step 8: Make permanent mounts of all entries in fstab by using the below command

[root@linuxhelp linuxhelp]# mount -a
mount: /mnt/raid0: can't find UUID=43b2f1de-bebe-412b-bc2a-645e86dfb8c5.

Step 9: Check the swap memory by using the below command


[root@linuxhelp linuxhelp]# top

snap2

Step 10: Turn Off the swap memory by using the below command

[root@linuxhelp linuxhelp]# swapoff /dev/sdb1

Step 11: Remove the fstab entries for /dev/sdb1 partition by using the below command

 [root@linuxhelp linuxhelp]# vi /etc/fstab

Step 12: Delete the /dev/sdb1 partition by using fdisk

 [root@linuxhelp linuxhelp]# fdisk /dev/sdb


Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

Conclusion: We have reached the end of this article. In this guide, we have walked you through the steps required to Create and Remove Swap Memory in CLI on Oracle Linux 8.6 . Your feedback is much welcome.

Tags:
liam
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

How to view available swap memory?

A

To view available swap memory use the command "swapon –s".

Q

How to deactivate the swap?

A

To deactivate the swap use "swapoff " command.

Q

What is the HEX code of Snap?

A

The hex code for SWAP is 82.

Q

How to update the partition table?

A

Update the partition table by using "partx –a" command.

Q

When swap memory is used?

A

Swap memory is mainly used when physical memory or RAM is fully occupied, Sometimes to increase performance RAM or physical memory is better used for disk cache than to store program memory, So Swap Memory is also used when program data are transferred from Physical memory then the remaining free RAM or physical memory is effectively used for disk cache though it increases performance.

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help David Lopez Guillen ?
Ayuda urgente instale SSL para servidor Opensuse y ahora no funciona tengo servicio web

hola segui este tutorial para tener un certificado ssl y ahora no se ve mi app en la red, espero alguien pueda ayudarme, tengo M9oodle en3.5 en un servidor open suse y ahora no funciona por favor ayuda.

https://www.linuxhelp.com/how-to-create-ssl-certificate-in-opensuse

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.