Two harddrives, two swap partitions


Results 1 to 9 of 9

Thread: Two harddrives, two swap partitions

  1. #1
    Join Date
    Oct 2002
    Location
    Binghamton NY
    Posts
    2,435

    Thumbs up Two harddrives, two swap partitions

    I read something a while ago in some Linux manual somewhere about how having two harddrives, each with it's own swap partition is a cool thing. But I can't remember the exact words, or even where I read them. I should be wary of drawing conclusions, yet draw conclusions I must.

    So let me test my conclusions out on you, the justlinux community.

    Suppose that I have x amount of RAM and x isn't a hell of a lot... and so, I set up 2x swap-space on my harddrive?

    Do I get better performace with another hard drive in place with 2x swap space than with just one?

    Furthermore, if this is true:

    Can I assume that I would not be able to reproduce the benefit with one hard drive, even if I assigned 4x swap space?

    And finally, if the first two are true:

    Can I assume that the performance benefits are such that, unless I've got a fairly good-sized wad of RAM, installing a second hard drive is always worthwhile, even if the second hard drive only adds a modest amount of storage space.

    This might explain the seeming difference in results that I've been seeing from two machines that are both older, but with similar specs. The faster one has two hard drives, each with a different linux system... ergo, two swap partitions. Am I onto something here?
    Last edited by blackbelt_jones; 09-03-2007 at 11:25 PM.

  2. #2
    Join Date
    Mar 2004
    Location
    Zoetermeer, Holland
    Posts
    147
    According to this http://www.cyberciti.biz/tips/perfor...partition.html and this http://tldp.org/HOWTO/Partition/setting_up_swap.html you must give the 2 partitions (on separate spindels) the same priority. That would benefit performance.

    If it is by means of round-robin or striped-IO is not clear for me. Maybe that 'mutated' in the kernel 'evolution'.
    Last edited by dr_te_z; 09-04-2007 at 01:55 AM.
    It's a known "problem" with OS/2. It runs continuously until the underlying hardware crumbles under you hands....

    the irony of quality

  3. #3
    Join Date
    Sep 1999
    Posts
    3,202
    You'll get better performance from swap when it isn't on the same physical device as other files you are reading/writing to/from. Same as with NT/2k/XP - putting the pagefile on something besides C: can speed things up.

    Personally, I don't use a swap partition, just swap files so I can add/remove/increase/decrease sizes as needed, but to be honest, its *hard* to make a Linux box swap when it has 512mb ram for light desktop use (surfing, email, docs, etc) ....

  4. #4
    Join Date
    Oct 2002
    Location
    Binghamton NY
    Posts
    2,435
    Both of these answers look like yes.

    I've got two computers here, each with 256 mb RAM, and one seems to be a lot faster than than the other-- but the faster one has a 550 mhz Pentium 3 processor, while the slower one has an 800 mhz Pentium 3 processor. The difference seems to be that the faster one has two hard drives installed, each with it's own Linux OS... and its own corresponding swap partition!

    THANKS FOR THE LINKS!

    According to the fstab file for the faster machine, both swap files are recognized,

    /dev/hda2 swap swap defaults 0 0
    /dev/hdb6 swap swap defaults 0 0
    but neither is assigned a priority number like the examples in the how-to from tldp:

    /dev/hda6 none swap sw,pri=3 0 0
    /dev/hdb2 none swap sw,pri=2 0 0
    /dev/hdc2 none swap sw,pri=1 0 0
    and

    /dev/hda6 none swap sw,pri=3 0 0
    /dev/hdb2 none swap sw,pri=3 0 0
    /dev/hdc2 none swap sw,pri=3 0 0
    I can assume, can I not, that the lack of any priority number for the swap partitions has the same effect as having equal priority numbers.

    It seems to me that the moral of the story is when you salvage an old system, don't throw away that orginal harddrive, even if it only has a lousy 10 GB. Using it to add another swap partition has benefits out of all proportion to the value of the storage space.
    Last edited by blackbelt_jones; 09-04-2007 at 03:44 PM.

  5. #5
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,936
    Quote Originally Posted by blackbelt_jones
    I can assume, can I not, that the lack of any priority number for the swap partitions has the same effect as having equal priority numbers.
    The manpage for swapon(8) doesn't say what happens if no priority argument is given.

    The manpage for swapon(2) (the actual system call) says that if the flags argument is zero, then the current device is given the lowest priority in the system (you need to set a special flag, then encode the priority value in other bits in the flags argument). The Linux kernel source seems to confirm this (at least 2.6.21.3) -- if the special bit isn't set in the flags, then it uses the current lowest priority value, minus one, and decrements the current lowest priority value.

    However, the source for swapon (in util-linux-2.12r anyway) has a default value of -1 for the flags; if no priority is set, it'll pass -1 all the way down. This means that the special bit will be set, and the priority will be the highest. So if you don't specify an explicit priority, yes, all swap partitions (or files) will be given the same priority.

    It seems to me that the moral of the story is when you salvage an old system, don't throw away that orginal harddrive, even if it only has a lousy 10 GB. Using it to add another swap partition has benefits out of all proportion to the value of the storage space.
    If you're hitting swap, that's true. If you have enough RAM that you don't use swap, then your system will always run faster than one that does have to use swap -- even if the system that has to use swap can run its swap across 30 different spindles. Because even if it uses swap from 30 different spindles, at least one of them will have to actually access the data, and it's still faster to get it from RAM.

    But yes, if you're using swap, you may see some increase if you add more (equal-priority) swap space on another spindle. The more swap you use, the higher the benefit.

  6. #6
    Join Date
    Oct 2002
    Location
    Binghamton NY
    Posts
    2,435
    Is there a way to tell for certain whether I'm using swap? A utility maybe? Although, with 256 mb RAM, I'll bet I use swap all the time.
    Last edited by blackbelt_jones; 09-04-2007 at 08:16 PM.

  7. #7
    Join Date
    Jan 2004
    Location
    boston, mass USA
    Posts
    1,878
    free

    the free util will tell you if you have dipped into swap

    Code:
               total       used       free            shared    buffers     cached
    Mem:       1555664     380664    1175000          0      29212     176908
    -/+ buffers/cache:     174544    1381120
    Swap:      1871564          0    1871564

    you see i have used 0 swap.
    Last edited by happybunny; 09-04-2007 at 10:04 PM.

  8. #8
    Join Date
    Oct 2002
    Location
    Binghamton NY
    Posts
    2,435
    Aha! Just as I suspected!

    total used free shared buffers cached
    Mem: 256320 252232 4088 0 3296 134612
    -/+ buffers/cache: 114324 141996
    Swap: 1574316 8140 1566176
    Last edited by blackbelt_jones; 09-04-2007 at 10:31 PM.

  9. #9
    Join Date
    Mar 2004
    Location
    Zoetermeer, Holland
    Posts
    147
    This story http://hedera.linuxnews.pl/_news/200...long/1445.html is very old. I do not know if it is still valid, but it is sooo cool: swapping to your videocard memory. Great for disk-less thin clients as well
    It's a known "problem" with OS/2. It runs continuously until the underlying hardware crumbles under you hands....

    the irony of quality

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •