Loading ...
Sorry, an error occurred while loading the content.

8563Re: Swap partition

Expand Messages
  • Bill
    Mar 1, 2012
    • 0 Attachment
      A swap file simply acts as extra memory blocks. Lets take a very simple case. Lets say you had six memory blocks, and each program took one memory block each while running. Then if you were to run 18 programs, at any given time 12 would be swapped to disk instead of being available to actively run. It turns out often times problems are just waiting for IO response some other event, and many of the memory blocks they allocate are not referenced that frequently, so this kind of ratio works out well for some system loads. I found on my NSLU2 I would typically run with 2 to 3 times the amount of swap in use as actual memory. Some programs such as apache took more memory than the NSLU2 had just to start-up. But so long as the actual system load (usage) was light it worked out fine. When I would run into problem is when I tried to stream a video via the apache web server, copy files via samba, and download e-mail with dovecot all at the same time. Then the NSLU2 would grind to a halt because it was spending all its time reading and writing memory blocks from disk.

      As for putting swap on an flash device, it is a bad idea. As it will shorten the life of the drive if you use the swap frequently. If you have a swap on disk and one on flash generally it works out fine to just make the flash swap lower priority. Another option is just to use a very inexpensive flash device you don't mind replacing when needed.

      Since I haven't really looked at the directions I'll just give my own here:

      dd if=/dev/zero of=/swap.img bs=1M count=256
      mkswap -L myswap /swap.img
      swapon /swap.img

      To verify:

      swapon -s


    • Show all 10 messages in this topic