Slashdot Mirror


Ask Slashdot: Linux and Swap Optimization?

I found a nameless submission in the submission box that asks a fairly good question: "I'm installing Linux for the first time on Intel hardware (I've installed Linux for PPC and BSD for Intel and 68K) but I am confused on how the swap partition should be handled for optimum performance. The Linux Installation Guide says I should have my swap at least as big as my RAM and that the swap partition should not be bigger than 127MB. Also a "rule of thumb" answer I got from my BSD using friends is that my swap should be twice the size of my RAM. Since I have 128MB of RAM should I have two swap partitions? Also how will swap drive performance affect system performance? Would a Fast SCSI (20MB/s) swap drive be any different than a Wide SCSI (40MB/s) swap drive? There seems to be little information on how to 'tune' Linux swap for machines with 100+ MB RAM."

176 comments

  1. how big of apps by Anonymous Coward · · Score: 0

    is the machine more workstation or server orientied.

    what kind of apps are you (or the person) running.

    that is a very good size of ram. I would personally start out with 127 mb on a HD that the swap would be the primary thing accessed on it with the most BW. Then I would monitor system performance and lead on from there

  2. 2X swap rule by Anonymous Coward · · Score: 0

    The 2X memory swap rule only applies to certain Unix systems which require swap space associated with a give amount of memory. I don't think this is true with Linux which has a different architecture. If drive space is plenty then I suggest making a 127MB partition and being over it unless you see more demand based on your applications.

    1. Re:2X swap rule by Anonymous Coward · · Score: 0

      This is absolutely not OS dependend! The reason that "saves" linux from 2.x is that linux swapping is so slow compared to other OSes that it will bring the system down if it uses only very little swap (see 2. below).

      Some reasons for the 2x (I tend to 2.5x) rule:
      (It's a rule for servers BTW.)

      1.a) Swap space *MUST* be bigger than RAM size to hold a crashdump. If the system ever crashes, a crashdump might give you the answer why it crashed and developers a hint to fix the bug.
      1.b) RAM size tend to increase. What has 128MB now will have (at least) 256MB next year.

      2. A server should always have enough RAM so that it will not page/swap much during normal operations. Giving it 3x as much (virtuell) memory (ie. swap space 2x RAM) should be enough for "bad moments". If the system really uses more than 1xsize of RAM swap space, it will get slower and slower, but no really bad things ("out of virtual memory") happens. This often gives enough time to analyse and fix the problem.

    2. Re:2X swap rule by Anonymous Coward · · Score: 0

      In short you can ignore the 2x swap rule. As stated, you need it to contain a crashdump - except... if you ask the question to begin with, you're not going to be debugging crashdumps. Linux's panic traps are flaky anyway. In the few times I've seen any Linux system crash, it's never caused a kernel panic. There have been mainly hard lockups.

      Swap is not really your friend. The concept was to provide a cheaper alternative to RAM. The crashdump could have easily been dumped in space specificly reserved for it. Either way, if you have 128 megs of RAM + 128 swap or 256 megs of RAM, you're going to run out of virtual memory at just about the same time (and if there is any difference at all, I'd bet the pure RAM solution would edge out). The 127 meg max was a maximum up until just a short while ago (I guess someone figured out that they had been telling everyone "2x RAM" and not really allowing for it feasably) Depending on what you're running on it, you can get away with RAM+swap = 128 for a desktop (that can do pretty much everything), 256 for a low load server and if you're running a high load server, do your buisness/site a favor and hire a technician that knows the answers to these questions already - it'll help a lot when things go sour.

  3. USE SWAP FILE by Anonymous Coward · · Score: 0

    Don't use a swap partition. Very hard to manage if u want to make changes later. Use swap file instead. Same performance. Of course use a seperate physical hd no bigger than 500MB.

    See mkswap man page for details.

    Size? Same as actual RAM.

    1. Re:USE SWAP FILE by Anonymous Coward · · Score: 0

      It has a little more overhead but one advantage is it can run on top of sofware raid.

    2. Re:USE SWAP FILE by Anonymous Coward · · Score: 0

      I would agree with you that managing swap files is easier than swap partitions, but you are wrong to believe that both offer the same performance. When Linux (or any OS for that matter) accesses a swap file it must first go through the standard channels (i.e. - access inodes, and what have you) of disk access to find the file. This additional task of finding the file naturally has an inherent performance hit associated with it. If you set up a swap partition instead, the OS reads and writes raw data to the partition. By doing this it eliminates the overhead of accesing the file system and therefore is faster.

    3. Re:USE SWAP FILE by demon · · Score: 1

      Actually, that is a bad, bad idea. If you allocate away all your system RAM, and only have a swap file, all the paging goes through the VFS layer, which needs memory to do its work. You could (theoretically, I don't know if this is practical or not) introduce a deadlock condition where the code needed to manage VFS and the FS the swap partition can't allocate the memory it needs to do its job. I may be wrong, but it's certainly a possibility...

      --

      Sam: "That was needlessly cryptic."
      Max: "I'd be peeing my pants if I wore any!"
  4. 127 MB limit by Anonymous Coward · · Score: 0

    Hmm. Why is this limit critical? I set mine to 128 MB, and ended up with 133+MB swap. Does this cause a performance problem?

    1. Re:127 MB limit by Anonymous Coward · · Score: 0

      and ended up with 133+MB swap

      Like this:

      Setting up swapspace version 1, size = 136245248 bytes

      136245248/1024/1024 is a little closer to 128 megs. I'm not sure of the technical limit but I had only been able to set 128 meg swaps.

  5. My rule. by Anonymous Coward · · Score: 0

    For a machine that is used, buy a little more memory than you think you will use during heavy usage. Swap is pretty hard to say exactly but make sure you allocate enough. I was running wusage on some site logs and it ran out of memory after 20 hours of cpu time on a machine with only 64 meg mem and 64 meg swap. Not the kind of thing you want to see. If you have lots of processes that may sit around sucking up memory but not active all the time, they can sit in swap. Also if you want to be accessing lots and lots of files (especially from a CD changer), make sure to account for disk cache.

    For multiple swap partitions, set 'pri=1' for all of them in /etc/fstab. The manpage for swapon(2) has more info about the swapping but swaps with equal priority will be interleaved while one with a higher priority will be used before a lower priority. Maybe you could have a swap area on your main disk that is used for emergencies only which would have a low priority.

    Also, I'm pretty sure this problem still exists but if your drive with swap fails and the kernel needs to get that page, the system will crash. For HA systems you may want to use an outboard raid array. I don't believe swap runs on software raid.

  6. Obsolete 128 Mbyte limit by Anonymous Coward · · Score: 0

    The new linux kernels (2.2 and above) do not have
    the 128M size limit. You also need a new version
    of mkswap to allow bigger swap (partitions or files). I don't recall what the new limit is,
    probably around 2G bytes.

    1. Re:Obsolete 128 Mbyte limit by Black+Parrot · · Score: 1

      "man mkswap" says the limit for SWAPSPACE2 is architecture dependent:

      "It is roughly
      2GB on i386, PPC, m68k, ARM,
      1GB on sparc,
      512MB on mips,
      128GB on alpha
      and 3TB on sparc64."

      It also mentions that the kernel grabs two bytes of memory per page of swap, with the result that you might end up using 2Mb of physical for a 2Gb swap file.

      --
      Sheesh, evil *and* a jerk. -- Jade
  7. Re:hmm... by Anonymous Coward · · Score: 0

    note that i use windowmaker and *not* KDE/GNOME and also note that netatalk serving files over afp is not exactly a memory hog. YMMV...

  8. swap death by Anonymous Coward · · Score: 0


    The biggest hassles I've had with linux have been corruption occuring in swap partitions. I put in two now just to give myself room to manuever if the problems begin.

  9. Cheap Thrills by Anonymous Coward · · Score: 0

    Got imagick and a lot of mem stress test the system with 'convert xxx.mpg ppm'. Bring up 'top' and watch the 'magic00xxx' files in /tmp.
    DO NOT DO THIS ON A PRODUCTION SERVER.
    Never thought I'd see 4 127M swap's get eaten up!!! Kinda gives you a feel for the machines swapability factor (which probably varies lots with different ardware mixes).

    ================================================ ==
    Time flies like an arrow, but fruit flies like a banana.
    ================================================ ==

    1. Re:Cheap Thrills by Anonymous Coward · · Score: 0

      Here's another one - cd /usr/src/linux, modify the
      Makefile or say make MAKE=j; no number, just 'j'.

      My dual PPro W/96M+136M[raid0]swap was all allocated in ~30s.
      make proceeded to thrash from that point.

      For what I do(play, just run make or lynx - Netscape dies within 1m regardless of memory availability (usually 40+M)
      I don't usually use the swap. My guess is that for single user systems W/64+M you should be able to get away W/no swap
      YMMV. it's what Linux is about

  10. Re:SWAP FILE (filesystem overhead, fragmentation?) by Anonymous Coward · · Score: 0



    Granted, if you don't expect swapping (like most single user boxes with 128MB) it could very well be worth using a swap file instead of a swap partition for the flexibility, but...

    Doesn't using a swap file instead of a swap partition add the overhead of having to go through the filesystem layer of the kernel instead of going straight to the raw partition though, thereby reducing swap performance?

    If not for Linux, I'm curious about other OSes if anyone else out there knows about whether swap files have to go through the filesystem layer. Recent Solaris, WinNT 4.0, Win 2k, other common OSes?

    Also, what about swap file fragmentation? A heavily fragmented swap file will kill performance. I know this under NT all too well.

    Ironically enough, for that reason I put my pagefiles at work under NT on their own partition (with tmp and browser caches too actually since they fragment the hell out of the hard drive too).
    But then again, if you don't expect to swap...

    strcat!

    "One World, One Web, One Program" - Microsoft Promotional Ad
    "Ein Volk, Ein Reich, Ein Fuhrer" - Adolf Hitler

  11. Re: SWAP FILE (another layer still, even slower?) by Anonymous Coward · · Score: 0

    True, it can then run on top of software raid (which could of course stripe the swap file), but that's yet one more layer (the RAID layer). The flexibility would also be likely lost because RAID0 would be probably be wanted to be used (simple striping) to not incur the overhead of the redundancy (but reliability) of something like RAID5.

    Since most reasonable people wouldn't want to put their important data on a RAID0 set the RAID0 would have to be partitioned off from the rest of the data. So you're back to square one. Seperate partitions.

    I can't remember where, but when I remember when I set up RAID at home I read somewhere that it's more efficient to unleash Linux on multiple partitions with the same priority and let the kernel handle the striping itself instead of RAID.
    It makes sense to me :). I'd be interested in seeing some actual benchmark comparisons of the two setups though.

    strcat!

    "One World, One Web, One Program" - Microsoft Promotional Ad
    "Ein Volk, Ein Reich, Ein Fuhrer" - Adolf Hitler


  12. What about core file? by Anonymous Coward · · Score: 0

    I use another Unix besides Linux, but isn't it usually a good idea to make your swap as big as your physical memory inorder to improve chances of a kernel core fire being written to /tmp which is tied to swap?

    1. Re:What about core file? by Anonymous Coward · · Score: 0

      I use another Unix besides Linux, but isn't it usually a good idea to make your swap as big
      as your physical memory inorder to improve chances of a kernel core fire being written to
      /tmp which is tied to swap?


      Linux doesn't use that tmpfs abortion that Solaris does. /tmp on Linux is a normal file system, and it doesn't eat up your swap.

  13. Re:WindowMaker vs. KDE flame bait... by Anonymous Coward · · Score: 0

    First, Yes, WindowsMaker really is that light. It also does not provide all the same services that KDE or Gnome provide.

    Back to the real issue - what are you doing to swap so much with KDE. I've only got 64meg ram and with KDE, Netscape and SO5.1 I only swap about 16meg.

  14. Re:Swap Drive(s)and SCSI Performance, Swap Priorit by Anonymous Coward · · Score: 0

    Uh... recent drives can transfer twice that. I have a 9LZX LVD SCSI3 device that is on an Ultra Wide chain (not U2W) and it transfers at 19MB/s. The fastest is the Altas 10k which transfers around 22MB/s sustained.

  15. Huh? by Anonymous Coward · · Score: 0

    My KDE desktop is only taking 14meg swap total. And that is because it has a file/web manager running...

  16. Re:Swap Files and Linux... by Anonymous Coward · · Score: 0

    Actually, you're quite wrong on your second point. Linux does memory overcommit (meaning that you can run far more than would actually fit into physical + swap).

    You're right about Solaris not doing memory overcommit though. Couple that with the stupid tmpfs for swap space, and you have to be extra-careful that your swap is big enough under Solaris.

  17. Re:SWAP by Anonymous Coward · · Score: 0

    You might as well be using a 128meg swap partition because that's all that linux will use in a swap partition.

  18. Re: SWAP FILE: BUT.... by Anonymous Coward · · Score: 0

    If the drive your normal swap partition is on dies, your system goes with it! I've had a drive fail under software raid-5 and it dumped an error in the syslog but everything kept running fine. Had it not been for the error, I wouldn't have known the drive went south.

  19. Re:Questions re partition selection. by Anonymous Coward · · Score: 0

    Is it ok to use a logical partition?

    Well, it sounds logical. [Oh god that was bad.. sorry] It really doesn't matter because Linux is just dealing with the drive by cylinders. Primary/extended/logical partitions are just a way to identify the start/stop of each partition and are only used at bootup.

    Should you use a partition allocated near the middle of your drive?

    Humm. I'm not really sure because there are arguments for every which configuration. The main thing I would say is do not add multiple swap partitions with the same priority on the same drive. This will cause the kernel to use them in round-robin mode which will certianly cause performance problems. However if your partitions are on different drives, make sure the priorities are set the same for max performance... unless one drive is used more than another one for some reason, but you get the idea.

  20. excess swap penalty by Anonymous Coward · · Score: 0

    I have 64MB of RAM and 128 swap. I use my machine for development at runlevel 3.
    Even with X, fvwm, 4 xterms, netscape, gcc, rc5des, etc., I hardly ever use more than 200 K of swap. However, I normally use much more RAM than I would if I used 64MB swap. So, using too much swap actually makes my system have to swap more than it should. Am I mistaken ?

  21. Re:Linux and Swap Optimization? by Anonymous Coward · · Score: 0

    According toe the HOWTO, right now the limit is 2GIGs.. hehe most wont need to go that high.. If you do, make another partition..


    2 gig should be enough swap for everyone (in the same tone of.. 640kb should be enough for all)

  22. Swap location by Anonymous Coward · · Score: 0

    You'll always want swap on your fastest drive. This is a _big deal_. Don't just look at Fast SCSI vs. Wide SCSI, though (although this is important). Look at the actual performance stats of the drive. Having swap split up between multiple drives helps a little, but usually not a lot (not enough to merit placing swap on the slower drive). With identical drives, the computer can potentially access both drives at once, for twice the transfer rate at peak. Practically, you're rarely at peak, and you usually only grab data off of one of the drives.

  23. Re:SWAP FILE on NT by Anonymous Coward · · Score: 0

    This is not true. NTFS does fragment. See
    Diskkeeper 3 from Executive Software (Defrag-SW).
    The help file even states what (mulitple -
    reboot) procedures have to be taken for the
    fragmentation of the swap file to be fixed.

  24. Re:Tune to linux-perf by Anonymous Coward · · Score: 0

    Majordomo@www-klinik.uni-mainz.de is addy not

    Majordomo@www.klinik.uni-mainz.de



    subscribe linux-perf

  25. I haven't had much need for extra swap. by Anonymous Coward · · Score: 0

    MemTotal: 38992 kB
    MemFree: 788 kB
    MemShared: 18964 kB
    Buffers: 17892 kB
    Cached: 4132 kB
    SwapTotal: 77416 kB
    SwapFree: 73656 kB

    That's on a p90, actively doing some samba, httpd, ftpd, several irc users, print server, vgetty. (no X, or netscape :) )
    Top says 71 processes. It rarely goes over 4 meg swap. (only when some evil user runs pico on a big file, or trys to email a large file in pine)

    This is one of the reasons I like Linux. Server doing tons of stuff, and very efficient memory useage.

    Does Linux have any per-user resource limit/management ? It would be nice to have a way that the system won't die if some moron runs pico on a 200 meg file. (well, it doesn't die, it just goes nuts) Or protection from a fork 'exploit'. (haven't had a problem with fork exploits, but I tried it out myself, and it brought the system to a crawl)

    1. Re:I haven't had much need for extra swap. by xk · · Score: 2

      /etc/limits is where you can place your system limits.

      You can limit how many processes can be run, how much memory can be used (total I think).

      -xk

  26. Re:Finally an answer... by Anonymous Coward · · Score: 0
    On server level machines, or machines that are to be used as servers, you need to do a little more analysis based on how the machine will be used.

    Yep. I'm using a P200 with 128MB Ram as 13x (virtual) web-, 1x news- and 2x ftp-server. During business hours the stress on all webservers is pretty high, so I started experimenting with kernel settings and swap space. As it looks, using at least 2x RAM as swap space increases response time for connects.

    My private machine is a K6-233 with 224MB Ram and just 128 of swap.
    Running
    • povray for creating images,
    • gimp for modifying them,
    • vi for creating webpages and
    • Netscape and Amaya for viewing them
    at the same time, however, doesn't really use swap at all.
    Oh, I'm running wm2 as my favorite window manager. Maybe that's why. KDE (sucks) and Gnome ARE memory hogs...
  27. Reasons why.. by Anonymous Coward · · Score: 0

    The amount of swap you use *should* be at least equal to the amount of ram you have. The reason for this is because the kernel can be configured to dump its memory contents into the swap partition during a panic. At the next boot up, it would then move the contents of the core dump off to /var/crash, where the core dump can be inspected. The 128 mb swap size limit doesn't exist in Linux 2.x.

  28. swap by Anonymous Coward · · Score: 0

    Swap >= memory. If your machine panics during install, theoretically all of the RAM may be core dumped. So your swap should be able to hold that. Fats swapping is nice when needed. So a separate UW SCSI swap disk would be A Good Thin imo.

    1. Re:SWAP by Anonymous Coward · · Score: 0

      No, a 50-100MB partition is all *you* need. Other people, who do different work and have different amounts of RAM, will need different amounts of swap space.

    2. Re:SWAP by ONOIML8 · · Score: 1

      For some reason I thought that changed with the 2.2 kernel.

      --
      . Quit playing Monopoly with Bill. Switch to one of many non-Microsoft products today.
  29. Re:Put the swap at the beginning of the drive by Anonymous Coward · · Score: 0
    I've always been wondering about where the partition should be... I read Tom's hardware guide to storage and got even more confused :)

    The rule appears to be... it all depends on the low level format of the drive which balances transfer rate and seek time. (remember you may have more than one disk plate)

    Eg0r

  30. Re:Finally an answer... by Anonymous Coward · · Score: 0

    I agree with your comment about what people think of as a "reasonable" machine. I mean, it's great that you can reuse an old 386 with 16MB of RAM on it, but in a corporate setting, Linux is going to run on much hotter machines. At work, I'm the administrator of a Linux server running on a Dell PowerEdge 1300 with dual 400 mhz Pentium II's and 512 MB of RAM; we run Oracle and Apache on it (an intranet application). I dutifully gave it 512MB of swap space (4 x 128 MB partitions - I didn't know the 128 MB limit was gone - aargh!) which I've never seen it use.

    We also have a Dell 6300 with 4 Pentium Pro CPU's and 4GB of internal memory running NT4 and a big Oracle database. We might replace NT in the future with Linux on these big machines; but then how much swap space would we give Linux? 4GB?! (that's how much NT has at the moment on the 6300, but of course, it hardly uses any of it).

  31. Re:Application dependent by Anonymous Coward · · Score: 0

    I thinking the same thing and almost posted
    the same comment. Swap space sure comes in handy for
    those 2Gx2Gx2G nuclear particle simulations
    that are also computational intensive in this
    3D world! This would be one humungous 3D array
    in C. I wonder what's left for the other user?

  32. drive performace and swap partitions by Anonymous Coward · · Score: 0

    I am running a Dual PPro system /w 128mb RAM and have each drive setup with a swap partition of 128mb (located at the end of the drive). However every time I look at the memory utilization, there is less than 16mb of swap being used. This is my primary workstation, and I am running GNOME and KDE interchangably. I also have a PostgreSQL database running on it.

    I have always been under the impression that Linux will do a RAID0 stripping of all available swap partitions, thus boosting the read/write performance of the swap. If this is true, then all swap partitions should be the same size, and you should only put one partition per drive.

    Also, wasn't one of the complaints against the MindCraft benchmark that since Linux and NT were on the same drive, by putting NT on the outer cylinders of the drive, and Linux on the inner cylinders, it was giving NT a big advantage due to the newer drives putting more sectors per track along the outer cylinders??

  33. Maybe I'm crazy... by Anonymous Coward · · Score: 0

    But I only have a 16mb swap partition, and its hardly ever used. I run Netscape, I compile, I play games, sometimes I do it all at once. True I don't run a server, heck, I even disable telnetd, but I've found 192mb of RAM with a 16mb swap is plenty for me.

  34. Re:I don't know much... by Anonymous Coward · · Score: 0

    Actually I have always heard that the best place to make your swap partition is in the middle of the disk.

    The reason is that the heads (which are constantly moving) have less distance to travel when going between the swap partition and your other partitions and that this increases the overall seek performance of the drive.

    It did seem to make a difference on my old Pentium system (which does a lot of swapping)

  35. Re:SWAP FILE Solaris fragmentation.. by Anonymous Coward · · Score: 0

    In Solaris 2.x it uses the UFS (Unix File System) without the use of any third party products (Veritas File System, etc.). It doesn't fragment and you don't defrag your HD. The FS is optimized so that it breaks data up into certain size blocks and has an organized layout so that everything is managed properly. Is slightly slower in respects to a FAT32 OS but you don't have to go down to bring the system to a grinding halt once a week or whatever and defrag... I assume Linux has an highly managed FS also.

  36. RedHat 6.0 by Anonymous Coward · · Score: 0

    I have 128Mb of RAM have never noticed RedHat 6.0 swap on me. I find it frustrating that RedHat insist on you creating a swap partition when installing RedHat 6.0. I would much sooner have a swap file that I can easily change the size of.

  37. Re:I don't need no steenkin' swapspace by Anonymous Coward · · Score: 0

    It may not need swap for performance reasons, true. BUT, you may need it for debugging reasons if your a developer. I am assuming Linux operates on the same principle of Solaris when it comes to Kernel crashes. All memory it dumped to /tmp (which is mounted on swap). When the system encounters a panic signal it dumps the memory stack to /tmp, which you need to be the size of your memory to do this. Upon your next reboot the crash dump is moved to /var/crash/`hostname` and you can run through it with tools like kadb, crash, etc. to see a still shot of what the system looked like upon crash and thus find out why it crashed so you can fix it and not have it happen ever again...

  38. Wrong by Anonymous Coward · · Score: 0

    It doesn't matter how many platters you have. The heads all read from the same place on each platter every time. The first block will be spread over the same physical area on each platter and the drive reads/writes from all platters simultaneously. There is only one beginning.

  39. Hmm. by Anonymous Coward · · Score: 0

    That assumes that swap accesses are usually going to be mixed with other accesses. I don't think that is usually the case. Most of the reads and writes to swap partitions are large, multi-block sequential accesses (i.e. several pages are swapped in at once). This assumes that you are using one application whose data segment fits in RAM while other applications are swapped out and the swap accesses occur when switching apps. In this case you want the swap partition near the beginning of the disk. If this is not the case (i.e. the data segment of the main application doesn't fit into RAM and keeps generating frequent random page faults), then your performance is going to seriously suck no matter where the swap partition resides.

  40. Wrong again by Anonymous Coward · · Score: 0

    There *is* a clearly defined beginning to the disk. The beginning of the disk (sector 0) resides on the outermost track and the end of the disk resides on the innermost track. This is done so the disk fills from the fast end first. The number of sectors per track is greatest on the outer tracks. Since the radial velocity of the platter is the same no matter where the head is positioned, the head will sweep through sectors faster at the outside of the disk. This means that the media->buffer transfer rate is greater at the beginning of the disk and the seek time is less.

    1. Re:Wrong again by periscope · · Score: 1

      untrue

      --
      http://www.jonmasters.org/
  41. Depends by Anonymous Coward · · Score: 0

    If you never use all of your 32MB, then don't increase it. However, some people need a lot more than that depending on the application (editing large images for example). The 2 X RAM rule of thumb is just a suggestion.

  42. Insurance against stupidity! by Anonymous Coward · · Score: 0

    Hard drive space is cheap. Running out of memory is a pain. Someday you will try something "different", and will need all the virtual memory you can find. Then it will probably be too late to go back and change things (unless you want to rebuild the machine). A deep swap area might even give you enough time to control-z when you do something memorable and things start looking really strange.

    Don't pay too much attention to your day to day needs when configuring swap. 2X ram is still a good minimum, even for a single user machine with plenty of ram. Someday you will do something that will use much more memory than you would have thought. Your needs may change so that you will do so repeatedly. Exhausting memory is a double spank hands no-no! If you can configure things so that is is NOT used ordinarily (and so it won't put a performance hit on the other drives in the machine), you can even canabalize an old slow drive (e.g., that 500 MB IDE from your old old machine) as "back-up" swap, to provide insurance against stupidity. Why waste it?

  43. Using Solaris? by Anonymous Coward · · Score: 0

    First of all, in Solaris tmpfs is a variable size RAM disk. /tmp is tied to RAM, not swap. Eventually, if you fill all your RAM, then Solaris will swap the tmpfs to disk as well. The tmpfs in Solaris is actually a really bad idea. It is much better for the OS to map the available physical RAM as a disk cache instead.

  44. Re:I don't know much... by Anonymous Coward · · Score: 0

    Your lucky CL even gives linux support. Your not paying for it. It was mentioned on the box so go away troll boy.

  45. More Solaris misunderstanding by Anonymous Coward · · Score: 0

    This seems to be a common misconception. In Solaris, /tmp is actually not mounted on swap. tmpfs is actually a variable size RAM disk in virtual memory. If you have /tmp mounted on tmpfs, then anything written to it is mapped into virtual memory. If you run out of RAM, then the pages of virtual memory holding /tmp get swapped to disk.

  46. Important /proc files for tuning memory & swap by Anonymous Coward · · Score: 0

    Consult the kernel doc (2.2.9 at least) .../Documentation/sysctl/vm.txt for lots of stuff one can play with to optimize memory and swap behavior of the kernel.

  47. The HOWTO for swap by Anonymous Coward · · Score: 0
    What puzzles me is that noone mations the works in the Linux Documentation Project where a number of documents give in depth description of swap space issues.

    At least one gives a rather in depth description of the issue, the Multi Disk HOWTO which is very much about tuning in general. It is way to big to quote here so I' rather suggest the interested readers look at the following chapters listed below (straight from the Multi Disk HOWTO homepage):

    Note that the swap partiotn limit in old kernels depends on the architecture of the processor, namely if it is a 32- or 64-bits processor.

    If you have any comments to the HOWTO I hope you can take direct contact with the author so more people can benefit from your insight.

  48. Re:killin' da' swap (correction???) by Anonymous Coward · · Score: 0

    by intuition, though, it would seem to me that rm only removes filenames (hardlinks), and that the swapsystem holds a hardlink to the file. thus you'd end up with a file that hasn't got any filename. in that case, if you drop the swap using /sbin/swapoff, the file will be deleted (because no-one will know that file: no directory, no kernel service, no running process).

    it would not be normal to me that the file would only be deleted after a reboot.

  49. Re:Application dependent by Anonymous Coward · · Score: 0

    Isn't there a flag or something for programs that are commonly used by different users at the same time? I remember someone pointing this out to me on SunOS, where a hundred users would be in pine at the same time (this was at a university) but there was really only one copy of pine code loaded in memory.

  50. Re:I don't know much... - tmfs is disk and memory by Anonymous Coward · · Score: 0

    tmpfs is covers the whole swap device. This includes both memory and physical disk on a standard install.

  51. Re:It depends... by Anonymous Coward · · Score: 0

    You can put more than 1 Gig in a PC but the 512meg pieces are very rare and ultra-expensive.
    (There were problems with old Chipsets (LX ?) which couldnt cached more than 512megs or so)

    Also, for Linux on Intel HW Virtual Memory Limit is 2 Gigs.
    If You have 2 Gigs RAM, there is no more room for swap ;-)

    Ciao,
    Frank

  52. Re:There are many beginnings... by Anonymous Coward · · Score: 0

    - snip -
    Actually, your first point is incorrect (unless drive design has changed radically in the last couple of years). Here's an excerpt from my post (the rest is located above, concerning the topic postion on the disk).
    - snip -

    Actually, it's been longer than that. Ever since IDE drive manufacturers had to start using translation (LBA and other methods) to accomodate larger drives they could put how many sectors they wanted on each track. And SCSI HD's have been doing it for longer than that since SCSI controllers have never used C/H/S numbers to access a drive but logical sector numbers and the drive did the translation.

    Besides, it's more cost effective. To get the same number of sectors on each track you either use a variable read/write clock to compensate for the faster rotational speed or you put more dead space between sectors.

    Now put yourself in a HD manufactures shoes: the fixed clock is cheaper and less complex and by getting rid of that dead space (minor tweak in the already existing translation code) I can sell a bigger HD while keeping manufacturing costs THE SAME. Guess what I would do. :)

  53. Re:WindowMaker vs. KDE flame bait... by Anonymous Coward · · Score: 0

    Of course it won't supply the same features as Gnome or KDE. Windowmaker is a window manager, not a widget set and set of associayted programs.

    I can't believe how many people fall into this trap. It's similar to the misconception that "Drivers for Redhat" means that Debian, etc. can't use them.

  54. Speed thrills (farce pest) by Anonymous Coward · · Score: 1

    The faster your swap disk is, the more system performance will be improved when swapping. Splitting your swap between multiple controllers (i.e., if you have two-channel SCSI, put a swap area on one drive of each channel) will also help, particularly with IDE. Several swap areas split between several controllers are better than one big swap area.

    Amount of swap: Disk speed counts here as well. If you have fast disks, swapping does not degrade your performance as much as with slower drives. In any case, if you find that you need 128 MB of swap normally, your real problem is that you don't have enough RAM. Get more. In practice, 64 MB swap should be plenty, but it depends on what the machine does. Even with too much RAM, it will swap out a small amount. This is OK. If you are swapping IN (and out) a lot, you need more RAM.

    If you have two controllers and two disks, go with two 32MB swap areas; if they are greatly different speeds, you may want to give them different priorities, experiment. If you have one controller, use one 64MB swap area. If you're really paranoid about it, add another 64MB swap area on another disk; that much disk space is an insignificant fraction these days.

    1. Re:Speed thrills (farce pest) by Anonymous Coward · · Score: 1

      I would just like to comment on the need for multiple SCSI controllers for the use of multiple swap partitions. If your SCSI controller (or channel) is reaching maximum bandwidth because of multiple devices using it at once, then this is a valid consideration. However, please do not confuse multiple device/channel SCSI performance with IDE performance. There is just no comparison. The maximum theoretical bandwidth of an ultra2 channel is 80MB/sec right? have a look at the faster ultra2 disks out there and you'd be hard pressed to find one over 20MB/sec. What? why have a bus architecture that is capable of 4X the speed of the disks it serves? well, for multiple devices, of course. Theoretically, one ultra2 channel could service 4 ultra2 disks (assuming = 20MB/sec/disk) at each of the disks maximum throughput. So, it may not make a bit of difference to put the second swap partition on a separate SCSI controller/channel.

      by the way, the fastest ultra66 IDE disks I saw couldn't do more than 15MB/sec. considering the huge performance hits 2 devices on one IDE channel, why does ultra66 exist (or ultra33 for that matter)? marketing hype?

      just my $0.02...

      Dave

    2. Re:Speed thrills (farce pest) by Anonymous Coward · · Score: 1

      Quantum has a surprisingly honest discussion on why UDMA disks are not as fast as one may suggest, the 33 MB/s (or recently 66 MB/s) transfer is just a small part of the whole handshaking process that is needed to transfer data, so all in all speed is much, much lower.

      SCSI on the other hand is designed for high speed and efficieny. Also 80 MB/s SCSI is not the fastest, SCSI 160 gives (not entirely surprisingly ) 160 MB/s. Given that the fastest SCSI disks can perform at 40 MB/s SUSTAINED you need only 4 of these in a RAID 0 to saturate the bus. At that point you have already saturated the 132 MB/s PCI bus in its normal configuration (32 bits, 33 MHz). Check the Multi Disk HOWTO for discussions on busses and speeds.

  55. hmm... by Anonymous Coward · · Score: 1

    on a 450MHz system with 20 users acting as an afp file server with light loads :

    MemTotal: 156332 kB
    MemFree: 102704 kB
    MemShared: 13100 kB
    Buffers: 20896 kB
    Cached: 17636 kB
    SwapTotal: 34236 kB
    SwapFree: 28972 kB

    my swap is around 1/4 the total RAM and my machine has never been able to fill it up. When i copy 8GB from one drive to another the RAM often fills with HUGE buffers but the swap seems to remain constant. My advice : use 127 MB of swap if you have it, but you shouldnt need it. normally try for a swap partition which is 1/4 the total RAM size if you have 128+ megs of RAM.

  56. Swap Drive(s)and SCSI Performance, Swap Priorities by Anonymous Coward · · Score: 2


    There are a few things to keep in mind.

    The first and foremost is that no single hard drive can transfer more than about 10meg per second (at least when I last researched it a few months ago, I haven't heard of anything faster than 10k rpm drives so I think it's still accurate).

    So, if using one hard drive the difference between the 20 MB/s and the wide 40 MB/s would make absolutely no difference - the 20 MB/s would never be exceeded.

    That figure (20 MB/s or 40 MB/s) is the capacity of the SCSI bus. SO, if you put three drives in the box, then the possible total transfer rate of 30 MB/s _would_ make start kickin' in.

    So don't waste your money on a Wide controller or Wide drives (40 MB/s) unless you plan to eventually have more than two drives on that controller.


    As far as swap priorities go, use the same priority for multiple swap partions on different drives and different priorities for multiple swap partitions on the same drive.

    For a single swap partition on each of different drives the idea is that with the same priority the kernel is supposed to automatically "stripe" the usage of the partitions (i.e. use all the drives at the same time and make the total transfer rate higher).

    For mutiple swap partitions on the same drive the idea is to have different priorities to different partitions so that it is "guaranteed" not to try to write to the parititions at the same time (since on the same drive it would slow things down overall since the drive can not write to multiple areas of the drive simultaneously).

    For multiple swap partitions on multiple drives you combine the above two. The first swap partition on each of the multiple drives should be given a priority. The second swap partition on each of the multiple drives should be given another priority.

    (And yes if you want more than 128MB of swap space you need to create multiple partitions each of size 128MB or below.)

    Lastly, the rule of thumb "swap >= twice the amount of physical RAM" assumes you'll swap and came about in the golden days when RAM was minimal and expensive.

    If you don't expect to actually be using all of the 128MB you might not even need swap partition(s) at all.

    Good luck,
    strcat!

    "One World, One Web, One Program" - Microsoft Promotional Ad
    "Ein Volk, Ein Reich, Ein Fuhrer" - Adolf Hitler

  57. It depends by Anonymous Coward · · Score: 2

    Don't listen to the morons who tell you 1x memory, 2x memory, etc. It's bullshit. How much swap you want, on any modern OS (Linux, Solaris, etc.) depends on what you're planning to do. With less RAM, you often want more. With more RAM, you often need less.

    Basically, if you're liberal, you'll want to figure out how much memory you'll use at peak, multiply that by 1.5 to be safe, and make sure swap is at least that. More swap never hurts performance, so if you don't care about money, you may as well have an arbitrarily large amount.

    For a (minor) performance benefit, you'll want swap to be the size of the total memory you use at peak, instead of having memory+swap be that size. Linux has fairly aggressive memory management; during idle cycles, it often writes out a copy of a page before it runs out of memory. It keeps a copy in memory and remembers if it's 'dirty.' That way, if it suddenly needs more memory, it can dump those pages from memory instantly without needing to write them out.

    Likewise, if you accidentally allocate too little, you're also not too badly off. Like Windows, Linux supports swap files. Unlike Windows, you can add swap files dynamically as the system is running. Should you ever run out, you just make a swap file, and you're fine.

    If you're conservative, or on a lower-end system, figure out how much memory you'll use at peak, and go with that as a total for memory+swap. Add/increase swap files as you need more.

    Why use swap partitions instead of swap files at all? They're a bit faster than swap files.

    Personally, I have 64mb RAM, 64mb swap, and I've never run out, but I only do e-mail, zephyr and light browsing locally. If you do more, you may want as much as 256mb total. If you do 3d rendering, animation, or work with large graphics, then you probably know how much more you need.

    - pmitros

  58. Re:Tune to linux-perf by Anonymous Coward · · Score: 2

    Majordomo@www-klinik.uni-mainz.de is addy not
    Majordomo@www.klinik.uni-mainz.de

    subscribe linux-perf

  59. Application dependent by Anonymous Coward · · Score: 3

    It would seem to me that the amount of swap
    is really very dependent on the intended
    use of the machine. I administer machines
    being used as multi-user systems by physicists.
    Unfortunately, this means that occasionally, and
    quite unpredictably, I may have a user launch
    a REALLY big job(~350+ MB). Or I may have
    several launch moderately big jobs(10 users x
    ~50 MB). Needless to say the result would
    not be pretty if I followed many of the
    recommendations here.

    What is far more useful than a simple recipe
    would be some reasonable explanation for
    new users of WHAT swap does, how it works
    under linux, what user memory footprints tend to
    be like, and bringing it all together to give
    some notion of what your swap + memory needs
    are.

    For example, typical light users in my
    environments can be expected to be running
    netscape (footprint ~20MB), ghostview (~3MB),
    and some other stray programs (~5 MB). So
    my safe estimate on light usage is a 40MB
    memory footprint per user. It's not
    unusual for my more heavily used machines
    to have 20 such users going at a time, so
    I need to support a ram + swap in the 1 Gig
    range. All of this is based upon a cursory
    examination of the UltraSparcs I deal with.

    What would be helpful would be for someone in the
    linux community to start putting together
    some carefully researched information
    about program and user memory footprints.

    1. Re:Application dependent by warpeightbot · · Score: 1

      Correct me if I'm wrong, but isn't the whole point of shared libraries and such the idea that the second time somebody loads up the 800 pound gorilla app (Netscape, Emacs, GIMP) that they share executable space with the first instance? Now, natch, that doesn't do diddly for the dataspace (like those monster global circulation model datasets with the 192mb initialization files...) but for most "normal people" (whatever that is) this isn't an issue. And those of you running the monster 3d models have NSF grants to get you a few extra sticks for your RAM sockets.

      --
      Poor man's supercomputer: 64-node Beowulf using white box commodity PC's, Node 65 with 19" monitor, 3x24-port switches, wiring, total cost, less than $50k. Less racks and that monster power/cooling requirement. Think about it.

    2. Re:Application dependent by colmore · · Score: 1

      Offtopic: I love it when people don't let the box use wordwrap. It makes there posts look like poems!

      --
      In Capitalist America, bank robs you!
  60. Re:Swap Files and Linux... by J4 · · Score: 1

    /etc/fstab

    You partition the second drive to have a 128 meg swap partition and point the kernel at it in /etc/fstab. Your primary drive on on the first IDE channel would be hda (or sda for the first scsi device) your old drive would be hdb (if its the slave on the first ide chan).
    Lets say you have 64 megs o' swap on the second partition of hda yer /etc/fstab will have an entry
    /dev/hda2 swap swap defaults 0 0
    like so.
    If yer second drive has a 128meg swap on partition 2 youd change /etc/fstab entry to look like
    /dev/hdb2 swap swap defaults 0 0
    You could also just add an entry for the second swap partition then do
    #swapoff
    #swapon
    and that would give you 64+128=192meg

  61. Re:Linux and Swap Optimization? by Jon+Abbott · · Score: 1

    you can grab it here:
    http://www.klomp.org/mod_roaming/

    -- Does Rain Man use the Autistic License for his software?

  62. A bit more about how swap works by DaveTerrell · · Score: 1

    Why should you put any swap space in when you have 128M of RAM? Here's why -- the kernel can agressively swap out programs and use that space for disk cache, which becomes a huge performance boost when your program footprints start approaching your memory size. I have a headless machine that only runs a few services (news, mail, web, etc) with 80M of ram, and it often swaps when I have less than half that RAM taken up by currently running applications. Disk is cheap, burn a little and get a big performance boost.

  63. Swap on soft RAID by demon · · Score: 1

    Actually, it does. Back when I still ran Slack 3.1 on my home box, I used RAID 0 to join 2 partitions on my 2 IDE hard drives (I know, I know) and used that as my swap space. It worked just fine.

    --

    Sam: "That was needlessly cryptic."
    Max: "I'd be peeing my pants if I wore any!"
  64. Re:Swap Files and Linux... by demon · · Score: 1

    Your last comment sounds like a job for swapd. Search freshmeat for it, and give it a spin.

    --

    Sam: "That was needlessly cryptic."
    Max: "I'd be peeing my pants if I wore any!"
  65. Re:I don't know much... by _damnit_ · · Score: 1

    Ok, in Solaris 2.x, most of your 4GB of memory is swap using tmpfs. You're only using the disk when you run out of room in tmpfs.

    And, if you have only 2 drives and 4GB of memory, I suggest you spend a little cash on another drive.


    _damnit_

    --


    _damnit_

    It's my job to freeze you. -- Logan's Run
  66. Rules of thumb. by Kaz+Kylheku · · Score: 1

    First of all, the ``twice the RAM size'' rule is a moronic leftover from operating systems which used swap in a backing storage manner. On these systems, the virtual memory size was equal to the swap size, with RAM serving as a sort of high-speed cache over that without contributing to the amount of swap. Meaning that there *had* to be at least as much swap as RAM for architectural reasons. In Linux, the total space available is the *sum* of the swap size and RAM size, so that rule of thumb, for what it may be worth, needs to be modified to: have as much swap as you have RAM.

    Of course, the problem with rules of thumb is that not all thumbs are the same.

    Ideally, you don't want any swap space at all. In practice you have to look at how much virtual space your applications need, and then decide how much of that space you can afford to represent with real RAM.

    If you need a peak value of 256 megabytes of memory to do what you want, and you have 64 megabytes of RAM, then you will obviously need 192 megabytes of swap space. If what you are doing won't run well unless all 256 megabytes are real RAM, then you will have to get 256 megabytes of ral RAM, in which case you then won't need any swap at all (but you can always have swap for the hell of it for for emergencies).

    Whether or not it's efficient to meet needs with a large amount of swap depends on the locality of memory references within the applications you are going to be running. Some applications simply won't run well if you don't have actual RAM, others might. Applications that have a small access pattern, but large memory usage (because, for instance, they have nasty memory leaks :) will benefit from a large swap space (the leaking ones will be able to run longer, if not better :). Applications that periodically access large areas of memory will need actual RAM. For example, image processing or scientific simulations with huge arrays.

    So there is no one-size-fits-all rule of thumb; you have to consider the nature of the application. First estimate the memory usage, trying to err on the side of too high rather than too low. Then based on the application type, determine how much swap is sufferable. Perhaps as little as one fourth of the total requirement needs to be physical RAM. Or maybe the whole thing has to be RAM.

    Also, simply set a low cutoff limit based on the RAM market. For example, these days, you might want to assume that there will be 128 megs of real RAM no matter what and proceed from there.

  67. Re:End of disk? by Enahs · · Score: 1

    You are.

    --
    Stating on Slashdot that I like cheese since 1997.
  68. 128MB is just fine by Tarrant · · Score: 3

    There's no need to go above 128MB under any configuration except ones that are already performing very poorly.

    Think about it: What would you do with more than 128MB swap space? Swapping at all is very bad; swapping a couple hundred megs is pretty catastrophic!

    On low-end machines, a 128MB swap would be 2x or 4x the size of your RAM. That's plenty of extra room for X, Emacs, whatever bloated thing you're running.

    On medium-end machines, a 128MB swap might be double your RAM, and...well, why not?

    On high-end machines and servers, you don't want to ever swap. Disk is just too slow. However, the algorithms in the kernel are kinda tuned on the assumption that you have at least a bit of swap space. The buffer cache, for example, might not shrink fast enough when you need the RAM for some fast-growing process. So stick a small swap (like 128MB) on the machine to keep some balance in the algorithms, but hope you don't have to use it too much.

    Do you see a pattern? Just go with 128MB. It should be just fine.

  69. Re:placement (wrong reason for correct placement) by flea · · Score: 1

    The variable density of the data storage on platters makes the rotational velocity moot. On the outermost tracks, data is less dense than on the inner tracks. The image of the subdivision of a platter into sectors is a pizza cut perfectly into slices, and then concentric circles are cut through the slices.

    Each sector (the individual pieces of pizza from the above illustration) is able to contain the SAME number of bits of info, NO MATTER WHERE IT IS ON THE DISK. This is done to make the rate of reading and writing from/to the disks a constant no matter where on the physical platter you are.

    There IS a reason that putting the swap partition on the outter most sector increased performance...

    Because sectors are almost allways numbered starting on the outermost tracks of a partition, if you have only 2 partitions then you can optimize the swap performance. The first partition would be swap (note this if for smaller disks, where the /boot stuff is under the max cyl # barrier) and the rest would be application file system. When you install the OS, programs and data fill the partion from the outtermost tracks inward, which will be closest to the swap partition. As a result, the drive heads will never have to travel further than from the innermost sector containing data.

    This will not be all that effective however, if you have multiple partions that are all accessed frequently. If you have /usr and /usr/local on separate file systems, for instance, and you use programs/data installed in both directories equally frequently, then placing a swap partition between the other two partions is actually the better way to go.

    The assumption that rotational velocity has anything to do with it is wrong; the placement of the swap partion is correct for basic partitioning scheams.

  70. Re:There are many beginnings... by flea · · Score: 1

    Actually, your first point is incorrect (unless drive design has changed radically in the last couple of years). Here's an excerpt from my post (the rest is located above, concerning the topic postion on the disk).

    snippet begins------------------------

    The variable density of the data storage on platters makes the rotational velocity moot. On the outermost tracks, data is less dense than on the inner tracks. The image of the subdivision of a platter into sectors is a pizza cut perfectly into slices, and then concentric circles are cut through the slices.

    Each sector (the individual pieces of pizza from the above illustration) is able to contain the SAME number of bits of info, NO MATTER WHERE IT IS ON THE DISK. This is done to make the rate of reading and writing from/to the disks a constant no matter where on the physical platter you are.
    --------------------end snippet

  71. WindowMaker vs. KDE flame bait... by Jules · · Score: 1

    Forgive me for I cannot help myself...

    My swap partition on a box with 128Mb RAM is a mere 32Mb and I've yet to see more than 2Mb swapped. So why waste the disk space?

    Yet with KDE, I regularly swapped up to 48Mb and beyond.

    Ok, so it's not NT (which bloody swaps even when no apps are loaded!) but why the huge differences? Is WindowMaker really that light?

    1. Re:WindowMaker vs. KDE flame bait... by Psiren · · Score: 1

      What programs are you using that shouldn't have titlebars? Window Maker seems to unerstand any hints that my programs give it. X11amp/xmms doesn't have title bars when I run it. Thats good enough for me.

    2. Re:WindowMaker vs. KDE flame bait... by alhaz · · Score: 1

      You're not just whistling dixie! WindowMaker can call me back when they figure out how to make it understand hints. I'm tired of it slapping a titlebar on everything by default. I use ICE for now.

      --
      This is just like television, only you can see much further.
  72. I bed to differ... by Jules · · Score: 1

    In my never ending quest to try all the distros I can, I've made one partition for /home and regularly blown away everything else, including swap.

    The largest I've had my swap file is a 128Mb partition and with WindowMaker, I've never seen it use more swap than with 32Mb.

    You could well be right but in julesLand, it doesn't seem to be working that way!

  73. There are many beginnings... by Timothy+Chu · · Score: 1

    ...because there are many platters. It's been a long time since hard disks have been on a single disk. Not only that, but they're double sided. So you end up having 6 "beginnings" for a hard disk of 3 platters...it no longer seems like such a big deal where your swap partition is.

    <tim><

    1. Re:There are many beginnings... by Timothy+Chu · · Score: 1

      Hmm...I agree with all you said, but you don't say why I was wrong. Let's say my disk has 2 platters, and double sided. So 4 effective sides. Let's say it's a 1 gig disk (I don't know whether any drives actually exist with this configuration, but this example is to demonstrate a point, not be technically accurate).

      Each effective side (ES, let's call it) has a beginning and an end. As you say, data is written from the outside in. But you have 4 different beginnings and endings with 4 ES's, each of 250 megs. So I can either put the swap at the first cylindar, or at the 250st megabyte boundary, or the 500th meg boundary, or at the 750th meg boundary. You'd have to do some calculations to figure out exactly which cylander this is at (since most disks aren't exactly 1 gig in size) but I think it'd be the same.

      I have no technical background in this area, so forgive me if I'm missing something totally obvious. Let me know if I'm wrong.

      As for why benchmarks show that reading/writing at the beginning of the disk is faster, it's because it *is*. But that's b/c we're comparing reading/writing at the beginning of the disk to anywhere else on the disk So of course, the second way is slower. However, I think that there exists more than one fast location on the disk--at the beginning of each ES.

      <tim><

    2. Re:There are many beginnings... by Paul+Doom · · Score: 3

      There is one beginning, and one end. With multiple platters, the disk doesn't write one platter until it is full, then go on to the next.
      It writes in parallel. That, plus higher media densities, plus higher rotational speeds == faster disks.

      Put your swap on the lowest numbered cylenders that you can if you want the fastest swap. I have yet to hear of a modern drive whose cylenders are not marked starting from the outside of the disk working into the center. There are two reasons the outside of the disk is faster.

      1. Rotational Speed -- More media passes the heads in one rotaion on the outside tracks. The media density is constant accross each platter, so the amount of disk real estate passing under the heads at any position is relative to the heads' distance crom the center of the spindle. If you think of each track as a line, then the length of each track is 2 * the_distance_from_center * PI.
      All this means the disk's maximum throughput is realized when readin/writing to the outermost tracks.

      2. Relative position -- It is obvious that the majority of the data on the disk resides near the outside edge of the disk. Also it is obvious that an equal sized partition will will take up more physical cylenders if it is positioned toward the center of the disk. More physical cylenders = more average distance for the heads to travel when seeking from one block to another when reading/writing non-contiguous blocks.
      This means that the lowest average seek times for a given partition will be realized if that partion is located at the outer edge of the disk.

      If you think that position doesn't make a difference, I have bonnie (a disk benchmarking program) data to back my words up. On some drives, the difference can be huge. That is why the Mindcraft benchmark, where they had both OSes on the same drives, was such a joke as far as disk IO was concerned. Can you guess which OS was on the outside of the disks (first cylenders)? (I'll give you a hint, it is not the OS that allows you to put its / partition at any location on the disk. Another hint, the OS's name starts with an 'N')

      Two more things that others have said, and I would like to reiterate and add to. Put swap on multiple disks, even if there is a disparity in disk speed from one to another, and even if you only want 32MB of swap. And SET THE SWAP PRIORITIES TO AN EQUAL NUMBER BETWEEN SWAP PARTITIONS ON SEPERATE DRIVES! Some folks seem to think Linux does RAID0 for swap automaticly, but it does not. You must set the priorities or swap will be written in a serialized manner. (i.e. -- Filling up one partition before starting to fill the next.)

      And finally, no matter how much RAM you have, have at least a little swap. Why? Every inactive process Linux swaps out makes more room for disk cache and buffers. On a box with 512MB that you are using as a workstation, 32MB of swap is probably fine. Linux has a real memory management system, don't tie its hands by not giving at least a little swap.

      And that is my sermon for the day.

      -Paul

      --
      "Life is life." --Laibach
    3. Re:There are many beginnings... by Mignon · · Score: 1
      2. Relative position -- It is obvious that the majority of the data on the disk resides near the outside edge of the disk.

      That's 'cause of centrifugal force, right?

  74. Re:Put on different disk by neonmatrix · · Score: 2

    also, putting the swap on a different controller and hard drive than the root filesystem...

    ive heard of people getting up to 10% system higher system performance with this method

    --
    Global warming is good for you!
  75. Swap performance. by Colin+Smith · · Score: 1

    You should really check to see how much memory your application is using and make sure you have enough RAM to cover it.

    If you are going in to swap then use about twice the amount of swap as you have memory and spread the partitions across as many disks/channels as you can.

    --
    Deleted
  76. Re:making swap 2x Physical memory... by logicTrAp · · Score: 1

    If you set the swap priority to two swap partitions to be the same in Linux 2.0 and later it will stripe accesses to them. By default however, it assigns swap priorities in decreasing order according to fstab

  77. The more swap the better! by maynard · · Score: 5

    Unlike most, I'm one who believes in investing as much disk to swap as you can afford. 2xRAM is my minimal swap space.

    With Linux kernels previous to (I believe) 2.0.36 you must make each swap partition no larger than 128M, though you may have an arbitrary number of swap partitions or files (and yes, Linux can use swap files in the filesystem instead of individual partitions, but at a performance penalty).

    Older 2.0.x, 1.2.x, and 1.0.x kernels must use individual 128MB swap partitions or files (actually, I seem to recall that 1.0.x kernels didn't support swap files, only partitions), but don't know if the larger swap partition support is limited to 2.2.x kernels or the later 2.0.36/37 kernels. /usr/src/linux/Documentation/Changes in 2.2.10 only states that the 128MB limit is gone, but doesn't list the new physical limit -- I've used up to 1024MB in one swap partition so I know that it can get pretty big. I wouldn't be surprised to find that the limit is 2048MB to conform with the 32 bit file size limit in ext2fs simply for parity with swap files in mkswap.

    Now for why I like lots of swap: You don't have to use it, but when you need it you REALLY need it! Your VM space is only as large as core and swap. Yes, I know the kernel can address anywhere within the 4GB boundary, but the total number of usable pages is limited to your physical RAM plus swap space! This is important to consider if you ever want to run lots of processes which sleep until asynchronous I/O events wake them up. If you want to start lots of processes and let them go off to sleep, having plenty of VM space makes sense. The machine will only thrash if there's memory contention among processes in a run state, so it's safe (and desirable) to let sleeping processes page out to swap while the machine uses physical core for running code.

    Also: consider the possibility of a small application using huge datasets. I run into this at work all the time. We have clustered machines each with 1/2GB of RAM and 1GB of swap. As long as each process only keeps dirty pages of the dataset in core, one can have multiple program instances crunching through different datasets even though together they're exceeding total physical core. Since these programs are stepping linearly through the data, instead of randomly seeking different pages like in a program doing long jumps, this can actually work well. Memory contention occurs not when you exceed total physical ram, but when running processes request pages that have been flushed to disk!

    If you're careful and selective about how you use the extra swap space you can wildly exceed physical core without significant performance loss. Food for thought.

    1. Re:The more swap the better! by stevelinton · · Score: 2

      I configure our big multi-user compute servers, and I am a firm believer in giving them lots of swap. There are three ways it can be used:

      1. to swap out all the inactive daemons, etc when a user process(es) comes close to using all of
      physical RAM. This can use up to 30M or s of swap on a typical system,

      2. for large stopped jobs (or interactive jobs waiting for input) -- it is sometimes nice to be able to have thee or four processes as large as physical RAM, even if only one of them can execute sensibly

      3. For the very rare user with a LOT of time and a problem that won;t fit in physical memory

      and no we can't buy more memory -- it won't fit.

    2. Re:The more swap the better! by alhaz · · Score: 1

      There is a daemon out there that will dynamicly allocate swap files as needed. This would be a reasonable solution for casual users.

      --
      This is just like television, only you can see much further.
    3. Re:The more swap the better! by mattc · · Score: 0

      Okay, sounds good to me! hehe

    4. Re:The more swap the better! by InitZero · · Score: 1

      > I'm one who believes in investing as much disk to swap
      > as you can afford. 2xRAM is my minimal swap space.

      I've got a AIX boxes with two- to eight-gig of real memory. There's no way I could justify putting in 16-gig of swap space. Nor would I ever need 16-gig of swap space. My applications would come to a grinding halt if ever that much memory was swapped-out. Even on 10k rpm SSA drives, it takes a long time to write 16 gig of data.

      While your argument has merit, encouraging folks to have at least twice as much swap as physical RAM all willy-nilly is irresponsible. Disk space may be cheap now days but it certainly ain't free. (I wish it were; so many MP3s, so little disk space.)

      Folks need to examine what their RAM is used for and what their swap will be used for. In my case, I'm running Oracle. Most of the RAM is used for Oracle to cache data and not for the application itself. In my case, under 340 meg of RAM is actually a candidate for swap and thus I've set aside 512 meg for swapping. And I don't think that has ever been touched.

      As the amount of memory in computers expands, old rules (swap must equal RAM; swap must be 2x RAM, etc.) need to fall aside to common sense.


      Matt

  78. I don't know much... by cout · · Score: 1

    I don't know much, but having two swap partitions on the same drive sounds bad. Linux may be smart enough not to do this, but it is conceivable that it could try to write to both partitions simultaneously, thus reducing performance.

    For maximum performance out of your swap space, you probably want it closer to the beginning of the disk. Of course, if you don't do much swapping to disk then filesystem performance may be more important to you, so in that case the swap partition should go closer to the end of the disk.

    You probably won't really notice a difference either way, though.

    1. Re:I don't know much... by ansible · · Score: 1

      I had problems with Solaris 2.6 where I couldn't assign a priority to the swap areas. Compounding the fact is that Solaris has a 2GB max swap size per parition. This makes it difficult to have 2x physical RAM as swap on a system that has 4GB of memory and only 2 disks!

      Oiy!

      James

    2. Re:I don't know much... by Wag+the+Dog · · Score: 1

      Er, if you have two swap partitions on the same disk just use different priorities and Linux will fill one up before trying to use the other. If you have them on different disks, use the same priority so that it load balances between the disks (even better if you have them on dual SCSI channels like I do :-)

    3. Re:I don't know much... by dirty · · Score: 1

      hpfs did something like this too. It stored the directory structure and other fun things that needed to be read often in the middle of the disk, which could reduce seek time by up to 50%. I've always kinda wondered why e2fs doesn't do something similar.

      --

      -matt
    4. Re:I don't know much... by periscope · · Score: 1

      Beginning of the disk?

      There is no clearly defined beginning to a disk. However, location wise on the disk's surface, it would make more sense to have the swap on the tracks closest to the centre of the disk, however, IDE disks use a variable track density and so this philosophy is actually incorrect. Therefore, in conclusion, it makes no different where on the disk the swap goes (as long as it is ofcourse a contguous allocation :-)

      just thought I'd point that out.

      I can see the advantage to having swap partitions on different disks, but what about adjusting the system buffers. The kernel uses a lot of buffering on my PII (128 Mb RAM) - perhaps there is a way to fine tune the way in which RAM is used also?

      -- "Don't try to be a great man, just be a man."
      -- Star Trek, First Contact

      --
      http://www.jonmasters.org/
  79. Re:you want swap by Crass+Spektakel · · Score: 1

    I have no problem to force swapping (or actually paging :-) on a 96MB-single-user-client :-)

    And memory gets even more important with a multiuser-system. My personal "internet-connected" computer eg has 48mb ram, 128MB swap, 30 users and needs around 70mb swap after one week or so even without X. (ok, squid, qwsv and up to 20 screen-session eat quite a lot :-)

    --
    "Life is short and in most cases it ends with death." Sir Sinclair
  80. Linuxperf website by Rik+van+Riel · · Score: 2
    Please take a look at the linuxperf website:
    http://www.nl.linux.org/linuxperf/.

    If you want to help with the site, subscribe to the linuxperf@nl.linux.org mailing list by sending a message to Majordomo@nl.linux.org with "subscribe linuxperf" in the body of the message.

  81. Finally an answer... by Reeses · · Score: 1

    I've wondered this too. Especially since I don't own a machine that has less than 128 MB RAM.. most have in the range of 160-192... and every time I install Linux, sizing the swap partition has always been a big question... of course, now that question will be made easier now that the newer kernel supports larger swap files.

    Note: The linux folks out there need to adjust what they think is a reasonable machine, and provide some guidelines for us who like max things out in a box. I can see the swap guidelines applying to people putting Linux on discarded Pentiums, 486's and non-G3 powerMacs... but there needs to be some guidelines for those of us who buy/acquire/build machines that have wicked fast CPUs, normal Hard Drives (even though they may be of capacities barely heard of a few years ago) and enough money to buy decent amount of RAM (Esp with 128 MB DIMMs going for around $100 a pop, it's easy to get large amounts in a desktop machine).

    So basically, after reading all the posts, the concensus is: Use 128 MB no matter how much RAM you have if you're using a single user machine, and don't really worry about it (assuming the use of an old kernel that only allows a 128 MB swap file), or the same size as your RAM if you're using a newer kernel.

    On server level machines, or machines that are to be used as servers, you need to do a little more analysis based on how the machine will be used.

    Anyone want to verify this?

    --
    Reeses
  82. Put the swap at the beginning of the drive by Ares · · Score: 2

    One thing about swap that the previous posters haven't mentioned is to put your swap partitions in the lower cylinders of the drive, as they are capable of transferring data the fastest due to their location on the inside of the disc. I've got three discs with 128MB each of swap space and each is in the lower cylinders in my 512MB server.

    1. Re:Put the swap at the beginning of the drive by Sq · · Score: 1

      It depends. You are forgetting that transfer rate has only minor impact on random disk reads/writes (as swapping). Much more slower (orders of magnitude slower) is SEEK time.

      So minimazing seek time (like, putting swap in the middle of the disk - but it really depends on your partition configurations and access) will yield much better speed improvements (esp. when disk is busy, as it almost always is when you start swapping)

      much things affect this, as RAID stripping for example, so YMMV.

    2. Re:Put the swap at the beginning of the drive by grot · · Score: 1

      Huh? I thought the rule was, put swap and often-accessed partitions at the outer cylinders of the disk, since the linear speed of the disk past the head is higher there, resulting in higer data transfer rates. If every cylinder had the same number of sectors, this wouldn't matter, but (AFAIK) newer drives (SCSI, at least; maybe IDE too) have more sectors on the outer cylinders than on the inner ones.

  83. Tune to linux-perf by Taco+Cowboy · · Score: 4

    To get better performances for Linux machines, subscribe to the Linux-perf mailinglist.

    To subscribe, send email to majordomo@www.klinik.uni-mainz.de and put "subscribe linux-perf" (without the quotes) in the message body.

    --
    Muchas Gracias, Señor Edward Snowden !
    1. Re:Tune to linux-perf by Signal+11 · · Score: 2

      Ssshhh. Don't tell Mindcraft about this.

      --

    2. Re:Tune to linux-perf by spinkham · · Score: 1

      Um, my mail gets returned saying there is no such user on this system. This sounds cool, please could someone give me information on the real address, if there is one?

      --
      Blessed are the pessimists, for they have made backups.
  84. My observations... by Palisade · · Score: 1

    I have found that my system, which has 128mb of ram, uses very little swap. 64mb should be fine, I currently have a 128mb swap. ("Very little" is 15% maximum)

    Sincerely,
    Nelson Rush

    --
    "God prevent we should ever be twenty years without a revolution." -- Thomas Jefferson
  85. Re:Faster swap at front of drive by signal7 · · Score: 1
    This has been cited several times in the previous discussion -- though some think cyl 1 is near the spindle and others think it's near the edge of the platter. The basic principle is that there are more sectors/track at the outer edge of the platter(Zone Bit Recording technology) and the sequential media rate is faster(though you will suffer some from rotational latency on the outer tracks -- it's a trade off)

    The real answer is that it's manufacturer dependant. The SCSI/IDE command set doesn't specify when I seek where the head will wind up physically. Right now I have queries in with both Seagate and Quantum over this issue because I'll be tuning a new server in the next few days.

    --

    --

    --
    I have no sig.

  86. Multiple swap partitions. by pqbon · · Score: 1

    My recipy is this: 2xPhysical Ram for swap. If possible put each 128Mb swap partition on a diffrent disk.

    Assign the same pririty to each partition on a diffrent disk....

    ie:

    3 disks with 6 partitions...



    the first partition on each disk at priority 1 then the second on each disk at 2...

    Hop this helps!

    "There is no spoon" - Neo, The Matrix
    "SPOOOOOOOOON!" - The Tick, The Tick

    1. Re:Multiple swap partitions. by Mantus · · Score: 1

      I have 256MB of RAM (at $80 for a 128MB DIMM why not?)
      now, i dont run any server software because this is a single user box but the swap partition on my hard drive has never been touched. this man has 128 and you are trying to say he needs 256MB swap and 3 hard disks to do it? if it were an internet server hed have 512+ RAM so ill assume its not a server , 127 should be more than adequate for this

  87. It depends... by QZS4 · · Score: 1

    There is plenty of reasons for going above 128MB swap. I have (well, the department here has, but I take care of them) a cluster of dual-PII:s with 256MB physical memory and 1GB swap each. I have seen many programs here eating around 600-700 MB of memory, the top notation was a Matlab script using close to 1 GB of memory. Yes, the script was carefully written to avoid thrashing. On the other hand, I have also seen programs using "only" about 400 MB that thrashed like h*ll.

    Yes, we're about to buy 1 GB of memory per machine, we really need it. Problem is that with these fscking PC:s you can't have more than 1 GB. We don't really want to buy a Sun Enterprise or an Alpha, since we're trying to move to all PC:s, so I guess we'll have to wait for the Xeon machines to become common.

    Our department is into research in coding theory and cryptography among other things, and the simulations for this kind of stuff are huge. One of our professors want to run a program which needs 4 GB of memory and 20 GB swap, and so far we haven't found any machine which can manage that.

  88. Put on different disk by bstadil · · Score: 1

    One thing you can do if possible is put your Swap on a different harddrive and if you have 2 swap partitions give the one on the separate drive higher priority.

    --
    Help fight continental drift.
    1. Re:Put on different disk by MikeBabcock · · Score: 2

      If you have 128M of ram, for now, create two 64M (or 128M if you can spare the space, but I wouldn't) swap partitions on two different drives. If you have only one drive, make it a 128M partition near the beginning ...

      Partitions:

      /boot
      SWAP
      ... others ...

      ... this way your kernel files are always in the first 1024 cylinders but your swap is at the fastest part of older disks (newer disks use scattering to make all reads and writes the same speed).

      If you use two disks, and assuming the load on both is about the same, set the priorities to be equal in /etc/fstab:

      /dev/hda2 swap swap defaults,pri=1 0 0
      /dev/hdc2 swap swap defaults,pri=1 0 0

      This way the Linux kernel automatically uses both partitions simultaneously for faster reads and writes. If your hard drive isn't doing anything else, you'll get twice the speed out of this.

      Again, with 128M of ram, you only need 128M of swap, even for most mid-level server apps. If you want to run Slashdot on your PC, you might need more :) ...

      ... leave some unpartitioned space in the middle of your drive to add swap to later if you need to ... (or to quickly partition and back up data to if another partition craps out).

      --
      - Michael T. Babcock (Yes, I blog)
  89. USE PLENTY OF SWAP!! by arwild01 · · Score: 1

    Anyone who thinks they can go without swap space is kidding themselves or not running Netscape :)

    In all seriousness my rule of them is:

    Twice the amount of RAM or 256M whichever
    is smaller.

    My primary workstation has 256M of RAM and 256M of swap and I have actually allocated all of my RAM and half of my swap before. They occasions this happens are rare, but imagine if I didn't have the swap there!

    I used to run Linux on a P90 with 16M of RAM and 32M of swap and I can rember programs crashing because of running out of memory. I don't ever want to deal with that again.

    If possible use a high speed drive, but the most signifgant factor is haveing plenty of RAM. I will never build a box again with less than 64M and anything for development use will have a good 128M if not 256M.

    -Alan

    1. Re:USE PLENTY OF SWAP!! by drwatt · · Score: 1

      I've been using a machine without swap drive for several months. I have 128MB RAM. I had the swap drive on old Maxtor 170MB drive that finally croaked.
      Yes, Netscape is the only app I use that seems to take memory and not give it back. Eventually I have to shutdown Netscape (or wait for it to crash) and then re-launch it...
      When swap space is in need the machine definitely begins to crawl.

      --
      DrWatt
  90. Re:Swap Files and Linux... by Firehawk · · Score: 3

    So if I'm running a 2.2.x kernel and a 64Mb swap partition, and say I wanted to make it 128Mb on the second drive, what would I need to do to change it?

    make a new partition on the new drive (use fdisk or whatever), make that drive type 82 (correct me if I'm wrong but the correct type for linux swap anyway), format that drive (mkswap?) and swapon it (or put the appropriate entry in /etc/fstab).

    there you go. easy peasy


  91. Re:Swap Files and Linux... by Ark · · Score: 1

    If I remember correctly, there's a sysctl thing to turn off the overcommit. I just can't remember what it is off the top of my head. See the kernel docs :)

  92. you want swap by Rob_D_Clark · · Score: 1

    I think even if you have 128MB+ RAM, you still want swap. If you have at least some swap, inactive processes can be swapped out in favor of cache when there is heavy disk activity.

    --
    --Rob
  93. End of disk? by Barbarian · · Score: 1

    I always found that partitions at the end of a disk were fastest to access... Maybe I was mistaken.

  94. Same here. (was:Re:USE PLENTY OF SWAP!!) by Rollo · · Score: 1

    128MB seems to be more than enough for the server I'm running (with apache, ftp and >10 simultaneous telnets running gcc and debugging...). Admittedly, not the most mission-critical or demanding of tasks, but it might give you swappartitionformatting folks an idea of what is possible. It seems as if linux can, when it wants to, do some rather impressive garbage collect...

  95. Swap Files and Linux... by trims · · Score: 4

    You asked three seperate questions, so I think I'll answer them in order:

    First off, the 127MB limit was for the older 2.0 series of kernels. The new 2.2 series (and dists based on them) has a much higher limit (I can't remember exactly what is it, but it's ALOT bigger (maybe like 1GB or more)). So, you can make a single swap partition of 256MB or so. If you are using a 2.0-based dist, you should make multiple partitions, each no bigger than 127MB.

    IIRC, linux is like the newer Solaris 2, IRIX, and HPUX systems in that swap space is added to physical RAM to come up with the Total Virtual Memory allotable on the system. Under older BSD4.2-based systems (I don't know about current Free/Net/OpenBSD stuff), swap space equal to physical RAM was used to "shadow" the physical memory (and improve swap performance), and thus your Total Virtual Memory was equal to the amount of swap space you had.

    For Linux 2.2, the rule of 2x physical memory is perhaps a bit overkill. I prefer the Solaris guidelines: you should have at least 128MB of total swap+physical for a typical end-user system, with 256MB for a developer/power user, and 512MB for someone using high-end graphics (the X-server gets big) or doing serious work. The point here is: swap space is slow. You should have enough swap space to hold applications that you aren't currently using, but huge amounts aren't useful (unless you have an application that likes to map large amounts of Virtual Memory, but doesn't actually use it). For most of us, I think no more than 256MB of swap is best.

    Swap being slow, putting your swap drive on the fastest possible disk is a good way to enhance performance. In your case, the performance characteristics of the drive are more important than the interface. Thus, a new drive (6.5ms / 10,000RPM) with a FastSCSI interface is preferable to using an older drive (perhaps 9ms/7200RPM) with WideSCSI. Striping swap is also a good idea, though you should use drives of similar speed.

    Also, note that linux can swap to a file, as well as to a raw partition. However, swapping to a partition is faster, and preferable.

    -Erik

    --
    There are always four sides to every story: your side, their side, the truth, and what really happened.
    1. Re:Swap Files and Linux... by Chipaca · · Score: 2

      Just a couple of additions to this:

      1. if you have multiple swap partitions and explicitly set the same priority in your fstab, the kernel will stripe the VM amongst these partitions, increasing performance quite a bit. You should _not_ make a softRAID array of your swap partitions.

      2. "Swap space is slow so put your swapspace on your fastest disk" is true, but could be misleading: the slow thing in harddrives is the seek time, not the transfer tiem. So you should put the swapspace on your least used drives in general (unless there is so much difference between seek times from the fastest and the least-used that it makes sence--ymmv).

      Also, you could have a cron job that checks for the amount of free swapspace, and adds|removes
      swap files as necessary. As in, say you have 128MB of RAM (as you do). You create a 256MB swap partition, and [if your free swap drops below 32MB you create a new 64MB swapfile (with a lower priority than your swap partition--that's the default), and if your free swap grows beyond 112MB you remove the last swapfile] (cron the []). It works, and it could save your day sometime...

    2. Re:Swap Files and Linux... by Jburkholder · · Score: 2

      Excellent. I've always wondered about swaps since I've seen confusing information about this almost identical to what the original poster saw.

      And now a follow-up question:

      Can you/how do you make changes to your swap setup after your system is already installed?

      I think I went with the "recommended" 2x RAM size way back when my machine only had 32Mb and one HD. Now I have 128Mb and I've upgraded my primary drive and have the old one set up as a slave for temp space for CD burning.

      So if I'm running a 2.2.x kernel and a 64Mb swap partition, and say I wanted to make it 128Mb on the second drive, what would I need to do to change it?

    3. Re:Swap Files and Linux... by leiz · · Score: 1

      here are my suggestions for swap files:

      1. if you got more than one drive, spread them across as many drives as possible

      2. partition your hard drives so that the swap partition is either on the outer tracks (faster data transfer) or in the middle (possibly faster access time?)

      3. use fast hard drives if possible (7200 / 10K RPM)

      4. buy more RAM - (ram is MUCH faster than a hard drive) ram prices are about half of what they were a year ago, and it may still be going down.

    4. Re:Swap Files and Linux... by AOCrowley · · Score: 1

      Eric wrote:
      > Also, note that linux can swap to a file, as well as to a raw partition. However, swapping to a partition is faster, and preferable.

      You sure about that? Seems to me it will only be
      faster if the partition is on a seperate physical
      disk. Why would mounting a partition make the swap file faster than mounting a file?

      > You should have enough swap space to hold applications that
      you aren't currently using, but huge amounts aren't useful (unless you have an application that likes to map large amounts of Virtual Memory,
      but doesn't actually use it)

      Under Linux, mapped virtual memory will never occupy swap or anything else unless an access
      with a page fault occurs.

      --
      void this_is_a_stack_issue(){this_is_a_stack_issue();}
  96. SWAP by Grifter · · Score: 1

    I have RedHat 6.0 and 192megs of RAM... I have 200mb swap partition on another Hard Drive... I also run GNOME, and barley ever see it use all my RAM or even touch my SWAP... execpt when I use VMware, then it uses about 10mb of SWAP. A 50 - 100 mb partition is all you need.

  97. Re:This should be an FAQ by Wag+the+Dog · · Score: 2

    Well I have 256MB RAM and I haven't swapped yet. That's with a 33MB X server, 35MB Netscape, KDE, a couple 10MB mySql severs, and all the "normal" services.

    It only used 60MB with all this running and doing a full kernel compile with -j on my SMP box. (load up to 35, yikes). I did get some "gcc: vfork: Resource temporarily unavailable" messages during the make -k modules, but I had plenty of swap left so it must have been processes or something. Had to limit the concurent jobs to get it to go.

    I'd say, tentatively, that if you have 256MB RAM you probably don't need more than 128MB unless you're doing some serious number crunching. And, you'll probably run into other issues also. I've got two 127MB partitions on separate SCSI channels just to be sure...

  98. Size your total Virtual Memory, NOT swap space! by Deven · · Score: 3

    According to the mkswap(8) manpage that comes with RedHat 6.0, "The maximum useful size of a swap rea now depends on the architecture. It is roughly 2GB on i386, PPC, m68k, ARM, 1GB on sparc, 512MB on mips, 128GB on alpha and 3TB on sparc64." It notes that this is for the new swap area style, which it claims to be supported since 2.1.117. (I don't know if the support is in 2.0.37, but it could be.) It also notes that 8 swap areas are presently allocated, so it's not unlimited. (It can probably be changed fairly easily by recompiling the kernel with a different limit, if it's just a static array.)

    All the guidelines for sizing your swap space based on your RAM size are misleading. On some old Unix systems (SunOS 4, I think), physical memory HAD to fit in swap (to do a core dump) and you usually wanted some extra. I think this is the origin of the "double the RAM size" recommendation for swap space. Under Linux (and I think Solaris and many other systems), the swap space is used for overflow for whatever doesn't fit in physical RAM. Your total Virtual Memory (VM) is the sum of your physical RAM and all the swap areas.

    The best way to size your swap space is to decide how much total VM you want, then subtract your physical RAM. If you have 64 Meg of RAM, and you feel that's enough VM, nothing says you need to create a swap partition. If you want a gigabyte of VM, add enough swap to make up the difference. It all depends on what you want to do with the computer, and how much disk space you're willing to allocate.

    Forget about RAM-to-swap ratios and just focus on total VM. Consider that an old Linux system with 16 Meg of RAM and 32 Meg of swap (double the RAM) had 48 Meg of total VM. Such a machine has less total VM than a newer machine with 64 Meg of RAM and no swap. Your limits will be determined by your total VM, not the ratio.

    Ideally, you'd have enough RAM for your total VM needs and no swap -- it's the fastest. Realistically, you'll want far more than average occasionally, so it's best to have at least some swap. Since disk space keeps getting cheaper, allocating a few hundred megabytes doesn't usually hurt much...

    --

    Deven

    "Simple things should be simple, and complex things should be possible." - Alan Kay

    1. Re:Size your total Virtual Memory, NOT swap space! by Beta · · Score: 1

      In my experience, having a small amount of swap (say, 8-16 mb) helps even if you wouldn't necessarily need it. It let's kernel swap out programs that are never used and in general makes the memory usage behave better.

  99. another add_on question by Pegasus · · Score: 1

    Some people have sugested distributing swap partitions across disk drives. Now imagine one of these drives fail. It might look like pulling out a SIMM while the machine is running. I assume the system would collapse in this case. Has anyone tried such a scenario?
    I'm building a small server here and all i want is reliability not speed. So how would it look like having a swap file on a raid5 partition?

  100. Swap Schmapp.... by miscellaneous · · Score: 1

    All right. I run several servers at work, and a dual-boot box at home. The only thing I have to say is this: I have a measly 64MB of memory at home, and yet I have only a 16MB swap file. I used to have no swap file at all (the horror! the horror!).

    Guess what? I've run out of memory once in the last two years. Once. That was when I was trying to use SNiFF+ to parse the 2.2 kernel...

    I'm not advising you to use as little swap as I am. It's probably too little, especially considering the way app requirements are shooting up all around these days. However, if you're setting up a workstation here, fuggeddabout the multiple F/W LVD SuperSCSI VII Widgetco hardrives and just set yourself up a nice, comfy 64MB partition anywhere on the drive you want. I'm betting it doesn't get used 99% of the time anyway.

    Servers, on the other hand, are a different story...:)

    --
    -k. ^-^ ^D
  101. Re:I don't need no steenkin' swapspace by Wonko · · Score: 1

    I don't understand why anyone would bother running with no swap space. I have about double my physical ram on my box at home(64 meg ram, 128 swap), and I believe my box at work has more than double(128 meg physical, can't remember how much swap)... I'm at home right now, and I seem to be using 10 meg of swap, probably left over from something I did the other day(seeing as how it never seems to deallocate). I also remember my box at work reading about 40 meg of swap used(it has 128 meg physical). Do I remember what I was doing that made it shoot up? nope :p. Why use this obese amount of swap space when so much is unused? Simple... I don't have the 120 meg drive my old 386 with running 1.2.13 had. I can get away with more than 8 meg physical, 16 swap :). Hard drive space is cheap... I was over at pricewatch today and a 17 gig ide is 180 bucks... just over 10 bucks a gig, or a buck per 100 meg... so if you have 128 meg of ram, it's gonna cost you 2 dollars and 50 cents for swap. Even if I don't use it, I aint gonna miss it... I spend more than that on lunch anywho...

  102. Re:I don't need no steenkin' swapspace by kijiki · · Score: 1

    when a program allocates memory, linux will free buffers and cache until enough is free, and only start swapping if it still doesn't have enough.
    Remember: Free memory is wasted memory!

  103. 0.5gb ram and 64mb of swap by wakko · · Score: 1

    MemTotal: 517528 kB
    MemFree: 4308 kB
    MemShared: 24236 kB
    Buffers: 11744 kB
    Cached: 384104 kB
    SwapTotal: 64492 kB
    SwapFree: 48736 kB

    I would have posted 'free' output, but it didn't fit right. Anyway, I have on the average, 110mb ram used on this 512mb machine. Usually about 8 xterms open with 10000 lines scroll back (not that much memory actually), netscape with a 30mb memory cache (no disk), still goes just fine.

    I usually don't see swap until a few days of uptime and to be quite frank, I don't know why it would touch swap with this much ram (usually 400mb left over before buffers/cache)
    --

    --
    Lab test show that use of micro$oft causes deadly cancer in lab animals.
  104. Questions re partition selection. by Black+Parrot · · Score: 1

    A couple of questions:

    Is it ok to use a logical partition?

    Should you use a partition allocated near the middle of your drive?

    --
    Sheesh, evil *and* a jerk. -- Jade
  105. This should be an FAQ by Zoinks · · Score: 1
    Heck, it might already be answered in an FAQ. Every time I check out news on comp.os.linux.hardware, there's some thead about it.

    Anyway, it depends on how much memory you have in your machine and what you plan do run on it. Here's my rule of thumb. For 8 MB up to 64 MB RAM, make a swap partition twice the size of the RAM. For larger RAM, just make swap 127 MB, since it's the limit for a single partition. If you have more than that amount of RAM, 127 MB swap is still fine - remember, you've got lots of RAM.

    (One person's opinion was just go ahead and start off with 127 MB swap no matter how much RAM you have because it's too hard to increase the size after it's been created. I wish I had heard this before I configured my machine.)

    However, if you really need to have several LARGE programs running at the same time (Netscape and StarOffice and KDE and... a few other big things) then you need more RAM than 64 MB (try 192 for starters). If you really need all that swap, adding more is only going to slow things down more, even if it's on another disk - after all, a drive is slower than RAM...

    Still, I'd like to know myself what rules of thumb there are for large memory machines (256 MB and higher). I can't imagine the rules for swap in small RAM machines continues to hold.

  106. Re:Put swap as last partition by rc-flyer · · Score: 1

    Actually, no. Yes, the disk is moving faster, but the physical size of the bits are increased. Think of an old record player spinning at 33 1/3 RPM. The same length of sound was on the outer groove as on the inner groove. That implies that a 1 second sound bite takes up the same proportional amount of the groove. It works out to 10.8 degrees per second, whether you are on the inner groove or the outer groove.
    The same applies to a hard disk (not CD-roms, most of them do have a variable spin). A hard disk spins at a fixed rate of speed. There are the same number of sectors on each track, therefore it will take the same amount of time to read a sector on the inner track as on the outer track.

    This being said, there could still be some performance improvements on locating the swap file/partition at different areas of the disk. For example, placing it as close as possible to the most-often accessed data would certainly reduce the time it takes the head to seek to the appropriate track.

    A good rule of thumb is to place a swap file on the most used partition of the least used hard disk (assuming a file and not a partition). For a swap partition, place it as close as possible to the most used partition on the least used hard disk.

    I don't know how the ext2 filesystem allocates space, so I can't state whether the swap partition should be close to the outer edge of the ext2 filesystem or the inner edge. Perhaps someone who knows could respond.

    Jonathan Bayer

    --
    -- Error: Cannot find file REALITY.SYS - Universe halted, please reboot!
  107. I don't need no steenkin' swapspace by Basilisk · · Score: 2

    I run a PII-400MHz 2.2.10 system, which is essentially single user. I have 128 MB RAM, and 128 MB swap space. I've never seen Linux use more than 1 MB of swap space, even when compiling the kernel. While running X. And Netscape. And X11Amp.

    Oh course, if I were running a server, I'd keep the 128MB, just in case. But I don't. Next time I reinstall Linux, I'm reducing the swap to 32MB (just in case...).

    1. Re:I don't need no steenkin' swapspace by infamous · · Score: 1

      Heh, try browsing several different sites, most of which use java/javascript, and then see how fast your swap space fills up.

      I've got 2xPII400 and 256M, with 246 now allocated:
      MemTotal: 257788 kB
      MemFree: 4872 kB
      MemShared: 61856 kB
      Buffers: 41004 kB
      Cached: 122304 kB
      SwapTotal: 120480 kB
      SwapFree: 120480 kB

      I'm a little miffed at how much memory is hogged for buff/cache, since I'll start swapping out apps I'm using, in favor of the cache. Although, it seems to behave a little better if I let the swap go to 2/3 megs, then swapoff/swapon. What I'd like to see is a tunable parameter that allows me to say don't swap until X amount of memory is allocated to apps, instead of cacheing very large files that I'll only open once.

    2. Re:I don't need no steenkin' swapspace by infamous · · Score: 1

      Hard drive space is cheap... I was over at pricewatch today and a 17 gig ide is 180 bucks... just over 10 bucks a gig, or a buck per 100 meg... so if you have 128 meg of ram, it's gonna cost you 2 dollars and 50 cents for swap. Even if I don't use it, I aint gonna miss it... I spend more than that on lunch anywho...

      Sure, but is it worth the performance? I specifically bought a bunch of RAM so that this machine would be fast. I'll probably get at least another 256 for this machine, just to boost performance. Besides, I'd rather use the 17G for DEVO mp3s ;)

  108. Solaris and Swap by Figec · · Score: 1

    I know this question was about Linux, but I wanted to put my 2 cents in about swap and Solaris as I often run into admins who are ardent supporters of the 2 x RAM rule. My experience is that a lot of people overdo swap on Solaris. The best way to gauge your need of swap is through trial and error. You need to look at what you are going to do with the box and you need to be familiar with the applications. Solaris 2.x deals with anonymous memory in a more efficient manner (it relieves the need for swap space when a process demands more space). The tools you can use to figure out your needs would be /usr/proc/bin/pmap, swap -s, vmstat and df. Sure bets that you will need sizable swap space are databases that rely on shared memory. Often their requirements exceed physical memory. (Check out the Solaris Performance and Tuning from Cockroft and look at Sunworld's swap article from January of `98.) The moral: KNOW YOUR APPLICATIONS. TEST, TEST, TEST! Run the application and peek at it with pmap. How much does it memory does it take? Is that what the peek is? Then do this with the other processes on the system and add them up. Look at swap with vmstat and df -k. Do you have a lot of /tmp and /tmp is swapfs? If you do, then maybe you have too much swap. Also, be sure to trim your system of unneeded processes. Why have automountd running when you don't automount? Why have nfs or rpc running if you don't need them? You will find a winning combination after trial and error. Nothing beats experience and testing in sizing a box.

  109. Put swap as last partition by LLatson · · Score: 2

    In my experience, putting the swap file on the outer edge of disk has increased performance. The disk is moving faster under the head at the edges of the disk. Just a small tip.

    LL

    --
    "If you are falling, dive." -Joseph Campbell
    1. Re:Put swap as last partition by ebrandwi · · Score: 1

      It doesn't matter either way. It would if you were swapping off a CD, but...

      Hard disks are CAV, Constant Angular Velocity. They spin at 7200, 3600, 10000, etc. RPM, regardless of the current head location. There are an identical number of sectors per cylinder, across the whole disk.

      CDs, LaserDiscs (some), are CLV, Constant Linear Velocity. They spin faster at the center of the disk and there is a constant number of sectors per inch. That's why your HD is 7200RPM, and your CD is 32X max variable.
      Eric Brandwine

      --
      Eric Brandwine
      An engineer is a person who solves a problem you did not know you had in a way that you do not u
  110. Adding Swap: 104416k swap-space (priority 2120) by marko_ramius · · Score: 1
    Ok, here's another swap question... when I boot up I get the following message when swap is added...

    Adding Swap: 104416k swap-space (priority 2120)

    This started when I went to a kernel level higher than 2.0.0. When I was at 2.0.0 and lower, I get a swap priority of -1.

    Any idea why this might be happening?

    My /etc/fstab swap partition is defined as such...

    /dev/sda2 swap swap defaults 1 1

    Thanks!

    david

  111. Re:>1 is the best way to go. by BigDaddy · · Score: 1

    Placing swaps between other partitions is again a throw back to the days of less powerful machines. Back when disks had the speed of Fred Flinstone in his foot powered car, the time for a disk head to move between data and swap was considerable. Thus the advice was to alternate data - swap -data so that heads would move less when disk paging. Having a data - data -swap configuration could lead to a preformace hitch if the heads had to transverse the extra data partition in the middle. Now days as drives get faster, this consideration is minimal. Theoretically, one can still get a performance advantage by alternating types, but if preformance is this important you are better off just buying more RAM.

    -Bigdaddy
    "You can't get a blue screen on a monochrome monitor!"

    --
    You can't get a blue screen on a black and white monitor.
  112. Re:Second Post!! by Uart · · Score: 1

    >HA! First reply to second post! Isn't that great >or what?

    First reply to the first reply to the second post!

    --

    Opinionated Law Student Strikes Again!
  113. >1 is the best way to go. by bbk · · Score: 3

    Put one swap partition on each drive you have. The kernel will use whichever drive is less busy to swap on, spreading out the system load. They don't have to be the maximum size. Make whichever one is on the fastest disk have the highest priority.

    You don't necessarily need 2x the size of your physical ram in swap - this is a throwback from the days when RAM was very expensive. 1x the amount of ram is perfectly fine, especially if this is going to be a single user machine - lots of swap is only useful when you either have a lot of users that are idle (i.e. stay logged in when they aren't there) or programs that take up more memory than you can afford.

    I've also heard of ideas like putting small swap partitions inbetween normal partitions, so that the disk heads don't have to move as much. Anyone have luck with a setup like that?

    Also, AFAIK the 127MB limit is a kernel 2.0.X an older requirement - 2.2.X supports bigger swap partitions.

  114. Swap before RAM is filled by TossPot · · Score: 1

    I didn't see this mentioned here, but swap space is used up before the machine fills up the physical memory. This is useful so you have a couple of megs free to run a new program, instead of having to wait to swap crap out first.
    You can tune this by echoing 3 numbers to /proc/sys/vm/freepages. I can't remember where the documentation for this is, but it specifies the limits of when to start swapping and when there's so much memory free it can move it back out of swap even if its not yet been requested.
    I like to set these numbers big to force swapping out sleeping processes and leave plenty free RAM to speed up starting netscape or emacs, whatever.

  115. Solaris 2.x - Tmpfs for swap space? by NiteEyes · · Score: 1

    For the record, tmpfs is not used for swap space and /tmp can be mounted on a real file system instead of mounting it on swap (ramdisk).

    --
    -- Creativity knows no medium
  116. Memory is cheap, and disks are slow by coyote-san · · Score: 1

    Memory is so cheap that I think there's no excuse to be using *any* swap space. Check your memory usage every so often, and if you're using swap space then buy more memory.

    That said, I agree with the other poster that swap space can be useful for long-term idle programs. And a decent sized swap area is cheap insurance against some program taking up a lot more VM than you expect - I've occasionally run out of VM (thanx, Netscape!) and it is not pretty. But your active applications should never hit the swap disk.

    Of course, this assumes that you're using a recent motherboard and additional memory is available. I still occasionally use a 386 maxed out with 20 MB of RAM. In that case I do have a very large swap partition (when compared to the amount of RAM) and accept the performance hit.

    --
    For every complex problem there is an answer that is clear, simple, and wrong. -- H L Mencken
    1. Re:Memory is cheap, and disks are slow by coyote-san · · Score: 2

      I would hope that such university and corporate environments are using real system adminstrators (or students supervised by experienced sysadmins). They will know how to tune swap and real memory for their specific needs.

      My point addresses the vast majority of SOHO users who either have a single user, or at most a family or small department. They should be hitting swap infrequently, if ever.

      --
      For every complex problem there is an answer that is clear, simple, and wrong. -- H L Mencken
    2. Re:Memory is cheap, and disks are slow by \u@\h · · Score: 1

      Imagine a university or company environment where you have a multiuser box where the people don't log out. I admin some boxes where you often have people with idle times > 1 day - leaving the memory claimed by their processes in RAM isn't very useful.

  117. Faster swap at front of drive by bellis · · Score: 1

    I've heard you can get some extra performance
    out of swap partitions at the lower cylinders
    of the hard drive. More so with the larger
    drives coming out these days.

    Can anyone confirm these rumor/theory?

  118. making swap 2x Physical memory... by Sun+Tzu · · Score: 2

    That recommendation comes from Unices that tye a page of swap to each page of ram. Linux (and Solaris) do not work this way. They don't preallocate swap space to the existing physical memory. Any swap space increases your total virtual memory.

    Another issue comes from how the swap is accessed. Some Unices, such as Solaris, automatically alternate between their various swap partitions, resulting in distributing I/O over all the swap devices. It is my understanding that Linux uses them linearly by filling one, then the next. I have not tested this, however. If this is the case it reduces the performance penalty of putting more than one swap partition on a single physical drive.

    As a general rule, I configure a swap partition (or several :) even on machines with a lot of memory. That allows the operating system to page out extremely idle processes (such as that big vi session you opened last week and forgot about) and use the freed physical memory for what would otherwise be a low priority task, such as mapping a couple of additional active files to memory.

  119. Linux and Swap Optimization? by dlc · · Score: 3

    That was one of my first concerns when I first installed Linux as well. I tried it first without a swap partition (Caldera 1.1 mentioned that a swap partition "might be necessary with a low amount of RAM"), since I figured I would be OK without it, and the resulting machine wouldn't run. I had to repartition and reinstall a few times to get it right. Good pratice. :)

    My current Linux machine has 192 M of RAM, and I've gotten away with using one single swap partition of the max size (127 M). I've never had a memory problem, and I have a tendency to run a lot of server stuff (for example, an LDAP server, a mod_perl copy of Apache for development, a mod_roaming copy of Apache to host my department's Netscape profiles, MySQL, and several other custom services), not to mention the many programs I use in the foreground at any given time (several copies of Netscape, several xterms (some running Emacs!), same-gnome, Gnumeric, etc).

    With 128 M of RAM, you probably won't use a swap partition too much, so one should be sufficient. A swap partition is really most essential on low RAM machines (16 M or less) running X or serving a lot of users.

    I say put it as the only partition on a fast disk (maybe a small dedicated SCSI drive... you must a few old ones lying around).

    darren

    --
    (darren)
    1. Re:Linux and Swap Optimization? by NodeZero · · Score: 1

      I have 384M of pc100 ram in my box, what should I set my swap to if I am going to be running server stuff (apache, ftp, shells) ?

      I think I currently have a 128 M swap.

      --
      - "My name is Legion, for we are many" -Mark 5:9
  120. Linux swapsizes.. by ViGe · · Score: 2

    Go ahead and increase the swap size.. The reason you don't see more than 2 MB of swap usage is not because you have unbelieable light software - it's because you have too small swap size.
    I myself used to have a "small" swap too, and linux almost never swapped more than 2MB. Then I increased it to be 160MB (I have 80MB memory), and even as we speak Linux has swapped out 26MB. This is because Linux behaves differently if it has lot's of space to swap on or if it hasn't. If Linux hasn't got a space to swap on and the memory becomes full, it simply throws some unused stuff "out". If it has enough swap space, it swaps in the same situation. And since when the stuff is again required it's faster to load it from the swap than from the disk (yes, I know, the swap is located on the disk too) this is the preferred method.
    --

    --
    It has to work - rfc1925
  121. Swap files and magical numbers by Hard_Code · · Score: 1

    Everybody likes to come up with their magical number or multiplier for swap. They don't really make sense. If RAM + swap = total mem, then just make sure you have enough swap to increase your total memory to that needed to run all apps you think you will be running concurrently. i.e., bring up every single think you *think* you might want to run at the same time, and then check you memory usage. Make your swap = used memory - RAM.

    I really don't understand the 2x multiplier. Um, if I have 500 MB of RAM, that means that I need 1 G swap!!?? Right! The more RAM you have, the LESS swap you should need. Should be something like:

    swap = .5 RAM maybe
    or
    swap = N + .5 RAM

    Striping is cool...you can do that with swap under NT too...heh, NT even gives you one big stripe of useless data down the middle of your partition for "recovery". That's what I call New Technology...

    --

    It's 10 PM. Do you know if you're un-American?
  122. Re: Funny things happen by Hard_Code · · Score: 1

    Yes, inactive processes get swapped out...then the disk cache caches the swap, then they can get read in faster.

    This is sort of weird, but must happen. It sort of begs the question, what is the optimal tradeoff between swap and cache (i.e., the more swap you have = the more can be swapped out = the more disk cache can grow = the more swap can be cached) ???

    Maybe Linux doesn't cache swap...should be a flag somewhere...

    --

    It's 10 PM. Do you know if you're un-American?
  123. Swap space by Thbbbt · · Score: 1

    I've got a PPro 200 with 128 megs ram and 128 megs swap and I've had no problems. The machine is basically my workstation, but there are a few internet/multiuser services running on it (web server with a small rarely used site, FTP server, POP e-mail for 1/2 a dozen people, a couple MUDs). I'm also usually running X with the GNOME desktop, GIMP, Netscape, a 1/2 dozen xterms, and a couple other applications at any given time.

    I rarely hit swap unless someone does something drastic on one of the muds (causes a new zone to be loaded is the most common reason).

    This machine has been reloaded a lot (ahh the joys of experimenting), and I've tried putting swap partitions on different parts of the drives, varying the size of the partitions, using swap size of 2x ram, and I discovered that for what my box does a second swap partition was useless because it never got used. Also, I was never able to actually notice any difference in performance based on location of the swap partition on the drive.

    If I were running a production web server, or an Oracle server than I would worry about it a lot more, but if you're just putting together a machine for your own use and don't plan on doing anything incredibly memory intensive, 128 megs of ram and a 128 meg swap partition should suit your needs just fine.

    Although... now that I'm running Seti@Home my memory useage has gone up, but even so I still rarely hit swap.

  124. Yet someone else's .02 by alexd · · Score: 1

    My experience has been 2x RAM is safe, at least if for any reason that you hit swap you are safe. Also RedHat 6.0 and Mandrake 6.0 allow > 128MB swap partitions.

    Alex DeWolf

  125. killin' da' swap (was:Re:another add_on question) by psergiu · · Score: 2

    Yep did it...

    Linux: dd if=/dev/zero of=/dev/hda1
    almost all of the swapped processes died with strange signals but the systep keep running on

    Linux with swapfile: rm -f /swapfile
    the file is no more here but the disk space is not freed 'till next reboot. system works fine...

    HP/UX: lvreduce -L 1 /dev/vg00/lvol2
    biiiig mistake - system dumps regs and dies

    --
    1% APY, No fees, Online Bank https://captl1.co/2uIErYq Don't let your $$$ sit in a no-interest acct.
  126. Who needs swap, anyway? by Raving+Lunatic · · Score: 1

    In general, I never use swap on Linux. If you have 128Mb+ RAM and aren't doing anything spectacular, why bother with swap? The kernel often finds excuses to use it, bogging the sys down with disk access...

  127. placement for best performance by Starfire · · Score: 1

    I generally locate my swap partitions at the beginning of the disk, starting at cylinder 1. This places the swap at the outer edge of the platters, where the read/write performance is up to 50%(?) faster, and there is a shorter average seek time from most of the data partition. The impact on the data partition's performance should be minimal, and performance in heavy swapping should actually be better due to the shorter seek times between the two partitions (someone should check this).

  128. Re:SWAP FILE on NT by Paul+Robinson · · Score: 1

    to my understanding, NT should keep the paging file from fragmenting, at least if you are using NTFS. if the size is locked, then there should never be a problem anyway. and if you put a paging file on every possible partion, as microsoft recommends, performance should be pretty good.