How to use ramdisk as SWAP space?

How to use ramdisk as SWAP space?

Post by Mohd Hanafiah Abdull » Sun, 25 Aug 2002 02:46:48



Since RAM is cheap I was thinking of using 64MB of my 256MB RAM as swap space
probably by means of ramdisk.  This is especially beneficial when used on a
diskless client to avoid using the inefficient NFS-SWAP.

How do I then configure the RAM to turn some portion of it into ramdisk for
this purpose?

Thanks.

Napi
--
http://www.cs.indiana.edu/hyplan/napi.html

 
 
 

How to use ramdisk as SWAP space?

Post by The.Central.Scrutinizer.wakaw.. » Sun, 25 Aug 2002 02:49:51


| Since RAM is cheap I was thinking of using 64MB of my 256MB RAM as swap space
| probably by means of ramdisk.  This is especially beneficial when used on a
| diskless client to avoid using the inefficient NFS-SWAP.

| How do I then configure the RAM to turn some portion of it into ramdisk for
| this purpose?

Use ram to simulate a disk simulating ram?
That's *retarded*.

Just use it as normal memory.

 
 
 

How to use ramdisk as SWAP space?

Post by Peter T. Breue » Sun, 25 Aug 2002 02:57:42



Quote:> Since RAM is cheap I was thinking of using 64MB of my 256MB RAM as swap space
> probably by means of ramdisk.  This is especially beneficial when used on a

It's not sensible.

Quote:> diskless client to avoid using the inefficient NFS-SWAP.

You'd do just as well by not using swap at all. Then your ram would only
be used for what it needed to be used for. And net swap (not nfs swap,
of course) is not entirely silly, since the netork is as fast as a
disk.

Quote:> How do I then configure the RAM to turn some portion of it into ramdisk for

Eh? You start a ramdisk, format it, and mount it. "man ram".

Quote:> this purpose?

Peter
 
 
 

How to use ramdisk as SWAP space?

Post by Mohd Hanafiah Abdull » Sun, 25 Aug 2002 03:10:03




>| Since RAM is cheap I was thinking of using 64MB of my 256MB RAM as swap space
>| probably by means of ramdisk.  This is especially beneficial when used on a
>| diskless client to avoid using the inefficient NFS-SWAP.

>| How do I then configure the RAM to turn some portion of it into ramdisk for
>| this purpose?

>Use ram to simulate a disk simulating ram?
>That's *retarded*.

>Just use it as normal memory.

In a diskless Linux PC it is required to have some SWAP space.  Otherwise, the
system hangs when it runs out of memory.  The presence of SWAP space avoids
this problem, so a workaround is to use ramdisk for SWAP space since there's
no local hard drive.  How to do this, anyone?

Napi

--
http://www.cs.indiana.edu/hyplan/napi.html

 
 
 

How to use ramdisk as SWAP space?

Post by Grant Edwar » Sun, 25 Aug 2002 03:23:50



>>That's *retarded*.

>>Just use it as normal memory.

> In a diskless Linux PC it is required to have some SWAP space.

Nonsense.  I run systems with no swap all of the time.

Quote:> Otherwise, the system hangs when it runs out of memory. The
> presence of SWAP space avoids this problem,

No it doesn't [Not if the swap is RAM].

The system fails when

  RequiredVM > (swap + RAM)

If you've got 256M of RAM with no swap:

  RequiredVM > (0 + 256M)
  RequiredVM > 256M

If you allocate 64M of RAM for swap, then failure occurs when:

  RequiredVM > (64M + 192M)
  RequiredVM > 256M

The only difference is that using RAM for swap is a _lot_
slower than just using it as normal paged memory, and there's a
bit of a net memory loss due to the data structures involved in
swapping.

Quote:> so a workaround is to use ramdisk for SWAP space since there's
> no local hard drive. How to do this, anyone?

Doing so is nonsensical.

If you use RAM for swap, you actually _lose_ VM due to the
overhead involved in swapping.

--
Grant Edwards                   grante             Yow!  I want to dress you
                                  at               up as TALLULAH BANKHEAD and
                               visi.com            cover you with VASELINE and
                                                   WHEAT THINS...

 
 
 

How to use ramdisk as SWAP space?

Post by Lew Pitch » Sun, 25 Aug 2002 04:03:33


On Fri, 23 Aug 2002 18:10:03 +0000 (UTC), in comp.os.linux.misc,



>>| Since RAM is cheap I was thinking of using 64MB of my 256MB RAM as swap space
>>| probably by means of ramdisk.  This is especially beneficial when used on a
>>| diskless client to avoid using the inefficient NFS-SWAP.

>>| How do I then configure the RAM to turn some portion of it into ramdisk for
>>| this purpose?

>>Use ram to simulate a disk simulating ram?
>>That's *retarded*.

>>Just use it as normal memory.

>In a diskless Linux PC it is required to have some SWAP space.

No, it isn't.

Quote:>  Otherwise, the system hangs when it runs out of memory.

Think about what you've just said.

How is 256M (all memory) - 64M (ramdisk) + 64M (ramdisk swapspace)
more than 256M? 256 - 64 + 64 = 256.

Or, to put it another way, you want to take 64M away from your memory in
order to add it (64M) back as swapspace.

You're not going to gain anything; you still have 256M memory, just split
up as 192M memory and 64M swap.

Quote:>  The presence of SWAP space avoids this problem,
> so a workaround is to use ramdisk for SWAP space since there's
> no local hard drive.

No. There's no workaround because there's no problem.

Lew Pitcher, Information Technology Consultant, Toronto Dominion Bank Financial Group

(Opinions expressed are my own, not my employer's.)

 
 
 

How to use ramdisk as SWAP space?

Post by Christopher Brown » Sun, 25 Aug 2002 04:24:16



Quote:> Since RAM is cheap I was thinking of using 64MB of my 256MB RAM as swap space
> probably by means of ramdisk.  This is especially beneficial when used on a
> diskless client to avoid using the inefficient NFS-SWAP.

> How do I then configure the RAM to turn some portion of it into ramdisk for
> this purpose?

Simple answer: That's one of the dumbest ideas going.

You would be _MUCH_ beter off not bothering with the exercise, so that
the 64MB could be used to _eliminate_ the need for swap space.

The reason to want to have a "ramdisk" _at all_ is if you actually
want to put _FILES_ onto a medium with pretty much zero I/O time.

That's useful if you have some files that you want to do really a lot
of updates to in rapid succession.  Such as if you're collecting
statistics into a DBM file, and doing _huge_ numbers of updates.

If you do this on a "ramdisk," you wind up getting all those benefits,
and at the end of the process, the data is sitting out on "pseudo
disk."  You'd then detach the process, and copy the file out to a real
disk.

Otherwise, you'd MUCH rather have more actual memory than to pretend
it's swap.
--

http://www3.sympatico.ca/cbbrowne/finances.html
Who wants to remember  that escape-x-alt-control-left shift-b puts you
into super-edit-debug-compile mode?  (Discussion in comp.os.linux.misc
on the intuitiveness of commands, especially Emacs.)

 
 
 

How to use ramdisk as SWAP space?

Post by Christopher Brown » Sun, 25 Aug 2002 04:24:17





>>| Since RAM is cheap I was thinking of using 64MB of my 256MB RAM as swap space
>>| probably by means of ramdisk.  This is especially beneficial when used on a
>>| diskless client to avoid using the inefficient NFS-SWAP.

>>| How do I then configure the RAM to turn some portion of it into ramdisk for
>>| this purpose?

>>Use ram to simulate a disk simulating ram?
>>That's *retarded*.

>>Just use it as normal memory.

> In a diskless Linux PC it is required to have some SWAP space.
> Otherwise, the system hangs when it runs out of memory.

Nonsense.

Quote:> The presence of SWAP space avoids this problem, so a workaround is
> to use ramdisk for SWAP space since there's no local hard drive.

If there _WAS_ such a problem, the "faking swap from ramdisk" strategy
would merely  make it occur earlier.

Think about it.

Supposing your system has 256MB of RAM, and when you run out of VM
(which is nonsense), the system will hang.

Alternative #1.  All 256MB of RAM being treated as "real memory."

The system would "fall over" when 256MB of RAM got used up.

Alternative #2:  128MB of RAM gets turned into a "ramdisk" used as
swap space.

Total virtual memory will be 128MB (the amount left) + slightly less
than 128MB of RAM (because there's overhead in creating a ramdisk).

Again, the system has 256MB of virtual memory (128MB + 128MB), and the
system would "fall over" when 256MB of RAM got used up.

The two alternatives don't differ.  

Supposing there _were_ a "system hangs when it runs out of memory"
problem, you haven't provided a strategy that does anything to help.
In fact, the system will be working harder under Alternative #2
(because it's jumping through added hoops to treat the ramdisk as
"pretend VM"), and would hang _earlier_.
--

http://cbbrowne.com/info/sgml.html
"For systems, the analogue of a face-lift is to add to the control
graph an edge that creates a cycle, not just an additional node."
-- Alan Perlis

 
 
 

How to use ramdisk as SWAP space?

Post by Steve Wolf » Sun, 25 Aug 2002 04:41:24


Quote:> Use ram to simulate a disk simulating ram?
> That's *retarded*.

> Just use it as normal memory.

 From Alan Cox:

"The behaviour it provides is correct and intentional. The documentation
is also quite plain on the fact you need swap for mode 3.

Since the kernel needs memory for its own purposes you cannot run
swapless with no overcommit and allow user space all of memory."

steve

 
 
 

How to use ramdisk as SWAP space?

Post by cybea » Sun, 25 Aug 2002 05:30:34



>> Use ram to simulate a disk simulating ram?
>> That's *retarded*.

>> Just use it as normal memory.

>  From Alan Cox:

> "The behaviour it provides is correct and intentional. The documentation
> is also quite plain on the fact you need swap for mode 3.

> Since the kernel needs memory for its own purposes you cannot run
> swapless with no overcommit and allow user space all of memory."

> steve

I think you need to send the link to were you got this from so we can see
the context. I ran for quite some time without swap and had no problems.
 
 
 

How to use ramdisk as SWAP space?

Post by Grant Edward » Sun, 25 Aug 2002 05:38:26



>> How do I then configure the RAM to turn some portion of it into ramdisk for
>> this purpose?

> Simple answer: That's one of the dumbest ideas going.

Or one of the better trolls I've seen in a while...  ;)

Quote:> The reason to want to have a "ramdisk" _at all_ is if you actually
> want to put _FILES_ onto a medium with pretty much zero I/O time.

> That's useful if you have some files that you want to do really a lot of
> updates to in rapid succession.  Such as if you're collecting statistics
> into a DBM file, and doing _huge_ numbers of updates.

> If you do this on a "ramdisk," you wind up getting all those benefits, and
> at the end of the process, the data is sitting out on "pseudo disk." You'd
> then detach the process, and copy the file out to a real disk.

Even then, you're likely better off letting the buffer cache do it
automagically.  It's certainly less work that way (and I'm awfully lazy).

--
Grant Edwards                   grante             Yow!  I'm having a BIG
                                  at               BANG THEORY!!
                               visi.com            

 
 
 

How to use ramdisk as SWAP space?

Post by Paul Hughet » Sun, 25 Aug 2002 06:00:31



: In a diskless Linux PC it is required to have some SWAP space.  Otherwise, the
: system hangs when it runs out of memory.  The presence of SWAP space avoids
: this problem, so a workaround is to use ramdisk for SWAP space since there's
: no local hard drive.  How to do this, anyone?

Not exactly.  The OS starts killing processes when it runs out of
memory *plus* swap.  If you have 256M RAM as memory plus 0M as swap,
the OS runs into trouble when the total memory requirements exceed
256MB.  If you have 128M RAM as memory plus 128M as swap, the OS runs
into trouble a little bit *before* memory requirements exceed 256MB
because some of the data is duplicated while in transit between main
memory and swap.

If you really insist on doing this, you can configure a ramdisk and
set it up as a swap partition, but you will *lose* useful memory
rather than gaining it.

Paul Hughett

 
 
 

How to use ramdisk as SWAP space?

Post by wb » Sun, 25 Aug 2002 06:16:13




> : In a diskless Linux PC it is required to have some SWAP space.
Otherwise, the
> : system hangs when it runs out of memory.  The presence of SWAP space
avoids
> : this problem, so a workaround is to use ramdisk for SWAP space since
there's
> : no local hard drive.  How to do this, anyone?

> Not exactly.  The OS starts killing processes when it runs out of
> memory *plus* swap.  If you have 256M RAM as memory plus 0M as swap,
> the OS runs into trouble when the total memory requirements exceed
> 256MB.  If you have 128M RAM as memory plus 128M as swap, the OS runs
> into trouble a little bit *before* memory requirements exceed 256MB
> because some of the data is duplicated while in transit between main
> memory and swap.
>>>>> Killing processes when running out of memory is a terrible

             behavior IMO ... I hope it doesn't kill tasks that are doing
actual work.

             Keep all your memory as VM and add a NFS swap device.
             When the performance starts to degrade your know why looking at
             swap activity and cure the problem in whatever means necessary.

//

 
 
 

How to use ramdisk as SWAP space?

Post by Peter T. Breue » Sun, 25 Aug 2002 06:07:30



Quote:>> Use ram to simulate a disk simulating ram?
>> That's *retarded*.

>> Just use it as normal memory.
>  From Alan Cox:
> "The behaviour it provides is correct and intentional. The documentation
> is also quite plain on the fact you need swap for mode 3.

Mode 3? I saw something about a mode 2/mode 3 bug under overcommit a
couple of days ago on l-k. Anyone know what they are talking about?

Quote:> Since the kernel needs memory for its own purposes you cannot run
> swapless with no overcommit and allow user space all of memory."

Umm. Well, turn on overcommit then! Why wouldn't you do so, since you
have no real swap?

And he's not even counting the fact that you need buffers to send
swap over the net, and you only swap when you are out of memory ..

Peter

 
 
 

How to use ramdisk as SWAP space?

Post by Peter T. Breue » Sun, 25 Aug 2002 06:10:13



Quote:> In a diskless Linux PC it is required to have some SWAP space.  Otherwise, the

No it isn't.

Quote:> system hangs when it runs out of memory.  The presence of SWAP space avoids

Yes and so what? It hangs or goes into OOM killing frenzy when it runs
out of memory ANYHOW. Being diskless has nothing to do with it. Many
people run swapless. Me too.

Quote:> this problem, so a workaround is to use ramdisk for SWAP space since there's

No it does not avoid the problem, it postpones it.

Quote:> no local hard drive.  How to do this, anyone?

Don't do it. It's crazy. And so are you if you don't spot the logical
flaw in your arguments. Using a ramdisk reduces the amount of memory
available, thus forcing you into swap earlier.

Peter