2

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 
1
  • Why? As it stands this system is a long way from needing any swap. Commented Mar 8, 2011 at 11:27

2 Answers 2

3

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.

7
  • I not get anything by swapon -s ? Commented Mar 8, 2011 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. Commented Mar 8, 2011 at 11:24
  • @Mkudlacek how to build disk partition for swap? Commented Mar 8, 2011 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. Commented Mar 8, 2011 at 11:31
  • how to uninstall the swap procedure according to your example Commented Mar 8, 2011 at 11:43
0

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:

[snip] 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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.