Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Slackware This Forum is for the discussion of Slackware Linux.


  Search this Thread
Old 10-19-2004, 03:48 AM   #1
LQ Newbie
Registered: Jun 2003
Posts: 12

Rep: Reputation: 0
swapfile doesn't work

Hi all,

I've created a swapfile, the following shows how i did it:
# cd /mnt
# dd if=/dev/zero of=swapfile bs=1024 count=1048576
# mkswap swapfile
# swapon swapfile

Here is the fstab entry:
/mnt/swapfile none swap defaults 0 0

But when i check ram usage with free -m, it gives the following:

total used free shared buffers cached
Mem:1008 917 90 0 142 276
-/+ buffers/cache: 498 509
Swap: 1023 0 1023

Here is my problem - i think - , although the machine is up at least 24 hours swapfile is never used. Is this a normal situation? I check ram usage, although free ram decreases to 16BM, swapfile is never used.

Thanks for your help.
Old 10-19-2004, 04:09 AM   #2
Senior Member
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 51
/mnt/swapfile none swap defaults 0 0
should be: /mnt/swapfile swap swap defaults 0 0

Btw, if you've created a swap partition this isn't needed.

EDIT: I've just checked man, and it should be none as you put, but well I've always used swap and worked
It should work with the steps you took. This is weird, are you sure the file is there?
Btw, if you modify your swap stuff, just run swapon -a (that will mount the swaps in fstab and skip already mounted ones)

About the swap not being used, well, it's normal if you've enough RAM, my server rarely uses swap and when it does it uses just a few mb. Same happens with my main machine that has plenty of RAM and I use vmware often to test some Windows apps.

Last edited by gbonvehi; 10-19-2004 at 04:16 AM.
Old 10-19-2004, 04:27 AM   #3
Senior Member
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577

Rep: Reputation: 48
your /etc/fstab entry should show where the partition is actually located:

this is mine............
 /dev/hda7   swap    swap     defaults      0    0
my box has 320 megs of RAM and swap is hardly
ever used ........unless I do something graphics intensive like--opening
20 jpg/png windows at the same time...........then it might use
5-8 megs of swap..........

Last edited by 320mb; 10-19-2004 at 04:29 AM.
Old 10-19-2004, 04:49 AM   #4
LQ Newbie
Registered: Jun 2003
Posts: 12

Original Poster
Rep: Reputation: 0
/mnt/swapfile none swap defaults 0 0
should be: /mnt/swapfile swap swap defaults 0 0
As you mentioned, manual of the fstab says if you have a swap, the second field must
be none. In the begining i had added
/mnt/swapfile swap swap defaults 0 0
to fstab but, then changed it to
/mnt/swapfile none swap defaults 0 0

I dont understand when this swap will be used, i can see free ram is 16MB, but still no use of
swapfile. There are lots of apache process running, and lots of emails scanned with qmailscanner
all the time. I think that these processes should be consuming lots of memory. So to me, it is
still weird why swapfile hasnt been used.

your /etc/fstab entry should show where the partition is actually located:

this is mine............


/dev/hda7 swap swap defaults 0 0
Since i dont have a partion for swap above fstab entry doesnt work for me.

Thanks for your suggestions.
Old 10-19-2004, 08:15 AM   #5
Amigo developer
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,874

Rep: Reputation: 554Reputation: 554Reputation: 554Reputation: 554Reputation: 554Reputation: 554
Do swapon -s to see if it is really activated. If you have lots of RAM and are not doing heavy use, Linux will not natably use swap space, but it should be there, even if only the minimum 4K.
Whatever the man pages say, I always use in fstab:
/root/swapfile swap swap defaults 0 0
which is the way it is for zipslack and this also works:
/root/swapfile swap swapfile defaults 0 0
Your problem may be with permissions also. /root is a better place to put your swapfile. Better use of space anyway, as it occupies some of the space allocated to 'root' by default(5%of / partition).
Old 10-19-2004, 10:23 AM   #6
Registered: Oct 2003
Posts: 534

Rep: Reputation: 30
The free command indicates there is swapspace. But I think you have plenty of RAM (1024 MB ??) and there is no need to use the slow swapmemory. The second line of output in free indicates that without buffers and cache you will have about 509 MB RAM available
Old 10-19-2004, 05:01 PM   #7
LQ Newbie
Registered: Jun 2003
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks for answers, i think i was a little bit hurry to panic, now system began to use swapfile, but it still uses little amount of it. Now it seems to be ok. If problem occurs i will try your advices.
Thanks again.
Old 10-20-2004, 01:42 AM   #8
Registered: Oct 2003
Distribution: Ubuntu 7.04
Posts: 889
Blog Entries: 1

Rep: Reputation: 30
Why didn't you use fdisk? It is easier.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I get my swapfile to work? Mr. New Linux - Newbie 2 01-01-2005 12:37 PM
how do i make a swapfile in debian? jogurt666 Debian 9 01-18-2004 10:11 AM
SuSe swapfile Pond247 Linux - Newbie 0 09-19-2003 03:17 PM
command to check swapfile? Scruff Linux - General 5 09-15-2003 10:47 PM
Swapfile Shantesh Linux - Software 2 09-11-2003 09:11 AM > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:25 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration