Why my swap-space is so low

Asked by Shirish Agarwal

I had a unable to find swap-on signature bug. So I searched & came onto this forum post.

http://sudan.ubuntuforums.com/showthread.php?t=381696

Seeing that did the following operations.

shirish@Mugglewille:~$ sudo mkswap -cv1 /dev/sdb3
[sudo] password for shirish:
Setting up swapspace version 1, size = 2056314 kB
no label, UUID=ddb44b87-2d55-4c5c-b06c-173da65a017c
shirish@Mugglewille:~$ sudo leafpad /etc/fstab
shirish@Mugglewille:~$ sudo swapon /dev/sdb3

Then just to check if the swap has been turned on or not did this.

shirish@Mugglewille:~$ free -m
            total used free shared buffers cached
Mem: 622 440 181 0 2 111
-/+ buffers/cache: 327 294
Swap: 1961 0 1961

Now this is where its starts to itch me. I have a /dev/sdb3 at 300 MiB/312 MB or thereabouts free but it never goes beyond this 1961, what is this 1961 ?

A cursory look at /dev/sdb3 gives this :-

shirish@Mugglewille:~$ df -h /dev/sdb3
Filesystem Size Used Avail Use% Mounted on
udev 312M 80K 312M 1% /dev

Why doesn't it use the rest?

Also there is something in the manual of mkswap which is bothering me.

To setup a swap file, it is necessary to create that file before initializing it with mkswap , e.g.
       using a command like

              # dd if=/dev/zero of=swapfile bs=1024 count=65536

       Note that a swap file must not contain any holes (so, using cp(1) to create the file is not accept‐
       able).

Now in our scenario above we haven't done that, would doing that make things easier? Also any idea if the bs & count should be same or should they be made any different?

Comments, suggestions all are welcome.

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu util-linux Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Helton Dória (helton-doria) said :
#1

Hi Shirish,

The Gentoo Linux community has an excellent material about manual disk partitioning and swap creation. You can take a look at http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=4#doc_chap4

Hope that helps,

Helton

Revision history for this message
Shirish Agarwal (shirishag75) said :
#2

Aha,
 Thanx Helton, Did it through fdisk & things look fine atm.

shirish@Mugglewille:~$ free -m
             total used free shared buffers cached
Mem: 622 609 12 0 3 107
-/+ buffers/cache: 498 123
Swap: 290 29 260

Although if one looks at swap & adds 260+29 it comes to 289 & not 290, where did the 1 go?

shirish@Mugglewille:~$ df -h /dev/sdb3
Filesystem Size Used Avail Use% Mounted on
udev 312M 80K 312M 1% /dev

This is curious, df -h still shows 1% as being in use, don't understand this bit.

Largely though my problem is solved as swap size shows as what it should have been showing in the free place.

Revision history for this message
Helton Dória (helton-doria) said :
#3

Hi Shirish,

This information resolve your problem? If yes, could you please mark the issue as solved? If not, what more can we do for help you in this matter?

Cheers,

Helton

Revision history for this message
Shirish Agarwal (shirishag75) said :
#4

Helton,
 I just want to know if the behavior outlined above is ok or not? Can u paste me the output of

df -h <your swap space mounted partition> & free -m. As I said I find what it outputs as 2 different things.

Revision history for this message
Adam Caldwell (adam-caldwell-deactivatedaccount) said :
#5

Your swap space is only used when the computer runs out of free RAM, so seeing that it is only 1% used makes sense.

The best way to see the status of your swap is to open a terminal and run top. It will show the size and usage of your swap most accurately.

Revision history for this message
Helton Dória (helton-doria) said :
#6

Shirish,

Adam is right. Follow his instructions and you will be able to see your correct swap statistics.

Can you help with this problem?

Provide an answer of your own, or ask Shirish Agarwal for more information if necessary.

To post a message you must log in.