Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

from my linux machine swap is - 0 why , and how to increase the swap?

  [root@my_small_linux free

             total       used       free     shared    buffers     cached

 Mem:       8172212    2087904    6084308          0     270020    1376776

-/+ buffers/cache:     441108    7731104

Swap:            0          0          0
share|improve this question
Why? As it stands this system is a long way from needing any swap. – symcbean Mar 8 '11 at 11:27
up vote 3 down vote accepted

That means, that no swap partition is available. If you have some unused space on hard drive, you can make it a swap partition (via fdisk). Or you can make swap on file. This creates 2GB swap:

dd if=/dev/zero of=/swap bs=1048576 count=2048
mkswap /swap
swapon /swap

And add it to /etc/fstab to be mounted at boot.

share|improve this answer
I not get anything by swapon -s ? – klod Mar 8 '11 at 11:18
Okay, you did all 3 commands and swapon -s says nothing? Please send result of ls -lh /swap. That will show how the swap file is created. By the way, you have to do this under root or via sudo. – mkudlacek Mar 8 '11 at 11:24
@Mkudlacek how to build disk partition for swap? – klod Mar 8 '11 at 11:26
As MrShunz showed - via fdisk create partition with id "swap". You can use free space or old unused partition. Then execute mkswap on /dev/sd.. and prepare this partition to be a swap. Turn on the swap via swapon /dev/sd.. and add it /etc/fstab as MrShunz showed. – mkudlacek Mar 8 '11 at 11:31
how to uninstall the swap procedure according to your example – klod Mar 8 '11 at 11:43

Could also be that in your /etc/fstab the swap partition is listed by uuid instead of /dev/sd*. If for some reason the uuid changed, it cannot be automatically mounted.

Check with fdisk -l as root/with sudo if it lists some swap partions. My output is:


Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          34      273073+  83  Linux
/dev/sdb2              35        1340    10490445   83  Linux
/dev/sdb3            1341        1449      875542+  82  Linux swap / Solaris <<--- here it is!
/dev/sdb4            1450        9729    66509100   83  Linux

and then check the symbolik link to UUID with: ls -l /dev/disk/by-uuid/. Im my case:

0 lrwxrwxrwx 1 root root 10 2011-03-08 08:39 3565be89-f1fe-478c-9653-a1dbeb9406a9 -> ../../sdb3

So in /etc/fstab I have:

UUID=3565be89-f1fe-478c-9653-a1dbeb9406a9       none            swap    sw              0       0

Disclaimer: i'm under Ubuntu now, so actual paths might be different under other distros.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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