9

For some reason on my Ubuntu 9.04 desktop, swap memory is turned off. How can I turn it back on?

4
  • Did you installed with Ext4 as filesystem? I read it somewhere that with ext4 and enough ram it's not necessary to have a swap partition anymore. Can't find the link now though.
    – Decio Lira
    Aug 13 '09 at 2:59
  • How would a file system be able to avoid swapping?
    – innaM
    Aug 13 '09 at 6:17
  • 1
    How do you know that "swap memory is turned off"?
    – innaM
    Aug 13 '09 at 6:18
  • the filesystem used and the need of swap is hardly much related Aug 13 '09 at 9:19
14
  • Check that you have a swap partition defined in /etc/fstab.

    $ grep swap /etc/fstab
    UUID=14a0f7b9-dabb-4296-b0e7-013527a7d82d none swap sw 0 0

  • Check that it is being used by the system

    $ swapon -s
    Filename Type Size Used Priority
    /dev/sda6 partition 1004020 215532 -1

  • If it isn't, check that it is formatted as a swap partition.

    $ sudo fdisk -l /dev/sda
    [..snipped..]
    /dev/sda5 3842 6595 22121473+ 83 Linux
    /dev/sda6 6596 6720 1004031 82 Linux swap / Solaris

  • If it is a swap partition, ready it for use and turn it on. At this point, you might see any errors that prevented its use.

    sudo mkswap /dev/sda6
    sudo swapon /dev/sda6

  • Check that the partition is now being used using the swapon -s command from #2.

  • Add an entry to /etc/fstab to have this swap partition loaded at bootup. You can replace the "UUID=xxx" part from above with "/dev/sda6" so the entry looks like this.

    /dev/sda6 none swap sw 0 0

If you didn't define a swap partition earlier, then you'd have to create one, or point swap to a regular file (less efficient).

5

If you have a swap partition defined in /etc/fstab already then sudo swapon -a

If you don't have the swap partition listed in /etc/fstab then sudo swapon device

1

A really easy way to do it is with these scripts, or even easier still with:

sudo apt install swapspace -y

Which is a dynamic swapping daemon

0

Use Disks (gnome-disk-utility) application. Select the partition formatted as swap and push the button.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.