Ubuntu Linux: How to Enable or Disable Swap Partition
By on June 6th, 2009

In this post we shall discuss how to enable or disable swap partition in Ubuntu Linux. Ubuntu Linux or any Linux operating system can use a swap partition for paging in case if it runs out of physical memory. The swap partition is not a mandatory requirement for using Linux but it is advisable that you have a swap partition setup to avoid memory bottleneck in case you run out of your physical memory.

The aim of this post is explorer the ways in which we can enable or disable swap partitions it is assumed that you have already swap partition created during the Ubuntu Linux installation.

Method 1:

We can use Gparted partition manager to enable or disable a swap partition. If Gparted is not installed in your Ubuntu Linux then use the following command below to install it.

   1: sudo apt-get install gparted

This will install the Gparted partition editor which you can access from System>>Administration>>Partition Editor

screenshot-1

The Gparted will now display all the available partitions in the hard disk that is selected. In this case we have a 14.99GB hard disk that has got a swap partition of 682.42MB.

screenshot-2

To enable the Swap partition:

To enable the swap partitions right click on the swap partition and then select the Swapon’ option to enable the swap partition.

screenshot-3

To disable the Swap partition:

To disable the swap partitions right click on the swap partition and then select the Swapoff’ option to disable the swap partition.

screenshot-4

Method 2:

In this method we shall discuss the enabling and disabling swap partition from terminal.

To enable the Swap partition:

To enable all the swap partitions on your computer you can use the following command.

   1: sudo swapon a

If you would like to enable the swap partition for a particular partition then you can use the following command:

   1: sudo swapon U <uuid>

To find the UUID of all the partitions use this command:

   1: sudo blkid

screenshot-5

In our example the UUID of our swap partition is 39be8652-da3d-4ad0-b11a-adb6c2ba3586 so the command will look like:

   1: sudo swapon U 39be8652-da3d-4ad0-b11a-adb6c2ba3586

To disable the Swap partition:

To disable all the swap partitions on your computer you can use the following command.

   1: sudo swapoff a

If you would like to disable the swap partition for a particular partition then you can use the following command:

   1: sudo swapoff U <uuid>

In our example the UUID of our swap partition is 39be8652-da3d-4ad0-b11a-adb6c2ba3586 so the command will look like:

   1: sudo swapoff U 39be8652-da3d-4ad0-b11a-adb6c2ba3586

That’s it you can enable or disable swap partition either using the Gparted GUI or using the command line.

[This is a guest post by Shivaranjan Bhoopathy. He writes articles on Linux, Windows and freeware softwares. A visit to his Blog is highly recommended. You're sure to find something of interest.]

Tags: , ,
Author: Keith Dsouza Google Profile for Keith Dsouza
I am the editor-in-chief and owner of Techie Buzz. I love coding and have contributed to several open source projects in the past. You can know more about me and my projects by visiting my Personal Website. I am also a social networking enthusiast and can be found active on twitter, you can follow Keith on twitter @keithdsouza. You can click on my name to visit my Google+ profile.

Keith Dsouza has written and can be contacted at keith@techie-buzz.com.
  • http://eldadlevy.wordpress.com/ eldad

    Thanks. Very nice and clear post!

  • nijamudeen

    sir i don’t have swap partition already in ubuntu 10.10.
    so how to create swap partition please help me immediately

    thanks by
    nijam

  • bala

    i have use windows 7 , now i want to install linux , but i want to keep both os’s. . pls help

  • BEoS

    after system restart it is disabled again.. the swap is only activated for that particular session .. how to enable it so its automatically enabled on system boot ? thanks

    • Shize Lu

      The same question with you

 
Copyright 2006-2012 Techie Buzz. All Rights Reserved. Our content may not be reproduced on other websites. Content Delivery by MaxCDN