Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Putting Swap into RAM
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
nekromancer
Apprentice
Apprentice


Joined: 23 Feb 2004
Posts: 158
Location: Niagara, Canada

PostPosted: Thu Nov 13, 2008 7:21 am    Post subject: Putting Swap into RAM Reply with quote

Hi,

I want to be able to put my swap on a fast storage device. First thing I thought of was maybe to mount my swap directly into RAM, I guess as tmpfs since the size if fixed and doesn't grow as opposed to ramfs. Then as I start reading more about these I get a bit lost and I wonder if there are any persons who know how to get this done the proper way?

Thanks in advance.
Back to top
View user's profile Send private message
ToeiRei
Veteran
Veteran


Joined: 03 Jan 2005
Posts: 1191
Location: Austria

PostPosted: Thu Nov 13, 2008 7:25 am    Post subject: Reply with quote

Putting swap into ram is a quite bad idea, as it's like a dog chasing its tail:

If there is not enough RAM, pages are written into the swapfile which would be in your RAM. Depending on your computer, if it's got enough memory, swap gets used hardly anyways - there are even systems out there without swap at all...

Rei
_________________
Please stand by - The mailer daemon is busy burning your messages in hell...
Back to top
View user's profile Send private message
szczerb
Veteran
Veteran


Joined: 24 Feb 2007
Posts: 1709
Location: Poland => Lodz

PostPosted: Thu Nov 13, 2008 7:35 am    Post subject: Reply with quote

If you have enough RAM you might just consider not using swap.
Back to top
View user's profile Send private message
bombcar
Guru
Guru


Joined: 08 Apr 2003
Posts: 453
Location: Wisconsin

PostPosted: Thu Nov 13, 2008 8:17 am    Post subject: Reply with quote

Correct. Linux doesn't map all RAM to swap so just turn it off. I have a machine with 1.5 GB of RAM that has no swap, and when it did have swap it never used it.
Back to top
View user's profile Send private message
nekromancer
Apprentice
Apprentice


Joined: 23 Feb 2004
Posts: 158
Location: Niagara, Canada

PostPosted: Thu Nov 13, 2008 8:49 am    Post subject: Reply with quote

I see, well I got the idea from this posting at KernelTrap http://kerneltrap.org/node/6470
Back to top
View user's profile Send private message
nekromancer
Apprentice
Apprentice


Joined: 23 Feb 2004
Posts: 158
Location: Niagara, Canada

PostPosted: Thu Nov 13, 2008 8:54 am    Post subject: Reply with quote

I won't turn off swap at all on any of my systems just due to what this article has to say about the necessity of using swap http://kerneltrap.org/node/3202
Back to top
View user's profile Send private message
ToeiRei
Veteran
Veteran


Joined: 03 Jan 2005
Posts: 1191
Location: Austria

PostPosted: Thu Nov 13, 2008 8:54 am    Post subject: Reply with quote

did you read the comments there?
_________________
Please stand by - The mailer daemon is busy burning your messages in hell...
Back to top
View user's profile Send private message
nekromancer
Apprentice
Apprentice


Joined: 23 Feb 2004
Posts: 158
Location: Niagara, Canada

PostPosted: Thu Nov 13, 2008 9:10 am    Post subject: Reply with quote

ToeiRei wrote:
did you read the comments there?


yup, and forget about this thread. I get a bit tired of people telling me what to do.
I can read tons of things on the net on why swap should never exist vs why swap must exist.
I just asked on how to get some good tips on implementing swap in ram. But as I read this thread.... I'm better off searching than asking :P

Thanks anyways.
Back to top
View user's profile Send private message
djinnZ
Advocate
Advocate


Joined: 02 Nov 2006
Posts: 4831
Location: somewhere in L.O.S.

PostPosted: Thu Nov 13, 2008 1:04 pm    Post subject: Reply with quote

Just to be clear.
Using ram for swap is absolutely unuseful but using not mapped ram for swap and tmp in order to use some strange configuration of the the hight memory support on a 32 bit cpu with 2-4 GB ram is a resonable idea, generally no, but for a dedicated server or better for test (I have used sometimes for it[/glsa][/glep]), can be do.
You must simply create a file on the tmp/ramfs mounted, format it with mkswap and activate with swapon /.../swapfile. Exactly what is the problem?
Note than if there is no swap set the kernel will create files in tmp.
_________________
scita et risus abundant in ore stultorum sed etiam semper severi insani sunt:wink:
mala tempora currunt...mater stultorum semper pregna est :evil:
Murpy'sLaw:If anything can go wrong, it will - O'Toole's Corollary:Murphy was an optimist :wink:
Back to top
View user's profile Send private message
keet
Guru
Guru


Joined: 09 Sep 2008
Posts: 571

PostPosted: Thu Nov 13, 2008 4:33 pm    Post subject: Reply with quote

I have 4GB of RAM, and my system absolutely never uses swap. No matter what I'm doing or compiling, my resource monitor always says that 0 bytes of my swap partition are being used. Why would you want to use valuable RAM as well in the first place? You only need a swap file if you lack sufficient RAM, and by switching RAM to swap, you're just reducing the amount of RAM that you have available.
Back to top
View user's profile Send private message
ToeiRei
Veteran
Veteran


Joined: 03 Jan 2005
Posts: 1191
Location: Austria

PostPosted: Fri Nov 14, 2008 7:18 am    Post subject: Reply with quote

To get back to the topic instead of trolling around - you could use the memory of your video card for swapping by creating a block device in memory as modern cards already got plenty of it - but I guess the same thing would work on RAM too...

Here's a german howto: http://my.stargazer.at/2006/04/10/graphikspeicher-als-storage-verwenden/
I guess google translation should do the trick for you

Rei
_________________
Please stand by - The mailer daemon is busy burning your messages in hell...
Back to top
View user's profile Send private message
fuzzykiller
n00b
n00b


Joined: 09 Nov 2008
Posts: 44
Location: Karlsruhe, Germany

PostPosted: Fri Nov 14, 2008 8:12 am    Post subject: Reply with quote

djinnZ wrote:
Note than if there is no swap set the kernel will create files in tmp.
What do you mean by that?
Back to top
View user's profile Send private message
djinnZ
Advocate
Advocate


Joined: 02 Nov 2006
Posts: 4831
Location: somewhere in L.O.S.

PostPosted: Fri Nov 14, 2008 2:24 pm    Post subject: Reply with quote

fuzzykiller wrote:
djinnZ wrote:
Note than if there is no swap set the kernel will create files in tmp.
What do you mean by that?
sorry, little mistake... i have try do do many things at same time and I have wrote nonsense.

"Note than if there is no swap partition set or if the swap will be full, in the old unix systems, files in tmp for swap was created, nothing strange."
There are an historycal note, sorry if my english is bad but I have learn it at school (and obliviously i hate to speak and/or write it :twisted: ).

As I see with "modern" (the M$ systems or the old vms uses to create files in /tmp more than using the swap by example) systems as linux and with the actual hardware the swap is more useful as security measure to prevent the memory exaustion than really used or to extend the ramdisk in order to use the swap space (normally located at the start area of the disks, you can use this trick to compile via tmpfs something big as OOo).

By example if you have two separate bank of ram one slower than the other, put a static ramdisk on the second and use as first swap the entire space will be a solution to use the slower memory for paging waiting processes (but i am not sure than will increase the speed). Or the trick reported by ToeiRei is in fact unuseful on a normal desktop but if you use a common desktop pc as server, without monitor connected, why waste the ram on the video card onboard?

All can be done, if is ufeful or not depend by the single situation, thats are the two cents of mine.
_________________
scita et risus abundant in ore stultorum sed etiam semper severi insani sunt:wink:
mala tempora currunt...mater stultorum semper pregna est :evil:
Murpy'sLaw:If anything can go wrong, it will - O'Toole's Corollary:Murphy was an optimist :wink:
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum