• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

Linux enable or disable multiple swap space

August 5, 2013 by Sharad Chhetri Leave a Comment

How to enable or disable multiple swap space in Linux

In this tutorial we will learn how to disable and enable the swap space. In this post we will see different scenario.The practical has been performed in Red Hat based Linux OS and Debian based OS.

Scenraio 1: How to disable and enable all swap space.

For eg. in your system if you have single swap space or multiple swap space follow the given below steps to enable /disable the swap space.

To Disable swap:

swapoff -a

To Enable swap

swapon -a

Scenario 2: If you have multiple swap space but want to enable or disable only particular swap area.

Use the below given syntax for particular swap space to enable or disable it

To enable (swapon), to disable(swapoff)

swapoff 
swapon 
  
swapoff 
swapon 

swapoff        
swapon       

See below example of my system

Note: The command swapon -s with show how many swap space are there and they are created in which device or file

root@ubuntu:/# swapon -s
Filename				Type		Size	Used	Priority
/swapfile-additional                    file		1048572	0	-1
/dev/mapper/ubuntu-swap_1               partition	1044476	0	-2
root@ubuntu:/# 
root@ubuntu:/# swapoff /dev/mapper/ubuntu-swap_1
root@ubuntu:/# 
root@ubuntu:/# swapon -s
Filename				Type		Size	Used	Priority
/swapfile-additional                    file		1048572	0	-1
root@ubuntu:/# 
root@ubuntu:/# swapoff /swapfile-additional
root@ubuntu:/# 
root@ubuntu:/# swapon -s
Filename				Type		Size	Used	Priority
root@ubuntu:/# 
root@ubuntu:/#

Disable Multiple but selective Swap Area: You can select more than one swap device or file, in my case I have now 3 swap space in system, I will disable 2 swap space similarly you can select many swap space as you want.

root@ubuntu:/# swapon -s
Filename				Type		Size	Used	Priority
/dev/mapper/ubuntu-swap_1               partition	1044476	0	-1
/swapfile-additional                    file		1048572	0	-2
/swapfile-2                             file		524284	0	-3
root@ubuntu:/# 
root@ubuntu:/# 
root@ubuntu:/# swapoff /swapfile-2 /dev/mapper/ubuntu-swap_1
root@ubuntu:/# 
root@ubuntu:/# swapon -s
Filename				Type		Size	Used	Priority
/swapfile-additional                    file		1048572	0	-1
root@ubuntu:/# 
root@ubuntu:/# 

Enable Multiple but selective Swap Area:

root@ubuntu:/# swapon -s
Filename				Type		Size	Used	Priority
/swapfile-additional                    file		1048572	0	-1
root@ubuntu:/# 
root@ubuntu:/# swapon /swapfile-2 /dev/mapper/ubuntu-swap_1
root@ubuntu:/# 
root@ubuntu:/# swapon -s
Filename				Type		Size	Used	Priority
/swapfile-2                             file		524284	0	-2
/swapfile-additional                    file		1048572	0	-1
/dev/mapper/ubuntu-swap_1               partition	1044476	0	-3
root@ubuntu:/# 

If you want to know How to create swap file in Linux without reboot,Click Here

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. How to know how many swap space exist in linux system
  2. How to find swap partition or file in linux
  3. Add swap file in linux without reboot after OS installation
  4. Create new swap file on CentOS 7 / RHEL 7
  5. df command not showing correct free space in linux
  6. How to Disable selinux in Red Hat or CentOS
  7. Disable “System Program Problem Detected” on Ubuntu
  8. Disable user self registration in Bugzilla
  9. Convert new line to space by using sed command
  10. fatal error: error writing to /tmp/ccwAjc9Z.s: No space left on device

Filed Under: Linux Tagged With: swap

Reader Interactions

Leave a Reply Cancel reply

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

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

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

How to find swap partition or file in linux

Allow wget and yum in iptable

Forgot root password ,Reset it in Run level 1

How to add/install Ubuntu fonts in CentOS/Red Hat Linux

Nagios HTTP WARNING: HTTP/1.1 403 Forbidden

How to find when Operating system was installed in linux CentOS and Red Hat

Password prompt in single user mode is not secure : CentOS/Red Hat

Explore 90+ Article On "Linux Tips And Tricks"

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy