Page 1 of 1

Re: Linux Swap and SD Cards

Posted: Mon Mar 05, 2012 3:52 pm
by SN
Haven't easily found anything on this subject but I'd be grateful if someone could answer this one.

First off - I assume that any Linux Build used on the Raspi will be holding Linux swap on the SD card.

Now I've had a play with 'low power' 'solid state' 'no moving parts' Linux Cigarette Packet Servers in the past with the wonderful Linksys NSLU2 NAS - this was a 266Mhz Arm5 Compatible Core device with 32Mb (ouch) of RAM that had 2 USB ports which you could hang Memory Sticks and whatnot on - there was a big 'health warning' on them though that they would not run forever because the Linux Swap was on the SD Card/USB Stick and these devices were certified for quite a low number of device writes before failing - and of course Linux Swap gets good and hammered on low memory devices - and indeed that's what happened to mine.

So - is this issue likely to afflict the Raspi?  I assume the more expensive the SD Card, the greater the number of guaranteed write cycles on the card, so maybe we can buy our way out of the issue (if it actually exists)

Re: Linux Swap and SD Cards

Posted: Tue Mar 06, 2012 8:51 am
by melhiore
There is always a chance that even good SD card will die due to amount read/writes. RPi having 256MB of RAM may perform better comparing to your previous boxes, SD card with its 200MB of SWAP may survive longer. Everything depends on type of use. I would suspect that combination of these two (RAM/SWAP) will give overall good performance and life span - we're going to know for sure when we finally get the units so we can start testing...

Re: Linux Swap and SD Cards

Posted: Tue Mar 06, 2012 9:28 am
by dennisMe
Depending on the applications you plan to try, you might not even need any swap space at all. Its not a hard and fast requirement of the OS, just very commonplace on desktops and servers where there is lots of storage available and you might as well use swap, just in case.

256MB is a lot of memory for a device dedicated to a single purpose. The problems start when you do like Freddie Mercury and sing the "I want it all, and I want it NOW" song...

Memory and swap usage are easy enough to test using a virtual machine, use the "top" command in a separate console to see what the memory does as you run stuff, swap will only be touched if the system needs it, and the used amount is an indication of what you have to "slim" off your applications' memory footprint.

Dennis

Re: Linux Swap and SD Cards

Posted: Tue Mar 06, 2012 6:04 pm
by benthepoet
It definitely depends on usage. I'm currently running Arch Linux ARM on a Pogoplug that only has 128MB of RAM. It doesn't have swap and runs off a USB flash drive. I'm able to serve up Django applications with Nginx as a reverse proxy without running out of memory. Try to find the lowest resource intensive application for whatever task you're trying to accomplish.

Re: Linux Swap and SD Cards

Posted: Tue Mar 06, 2012 6:52 pm
by mjdon
I agree using swap on a flash drive can be an issue. A first sulution is to turn the swap off with something like:sudo swapoff /dev/sdaX
You can also se a pourcentage withcat /proc/sys/vm/swappiness
which indicates how much ram needs to be used befor the kernel starts using the cache. It can be changed by addingvm.swappiness = 20
in the /etc/sysctl.conf file and restarting the computer. These commands seems to work with ubuntu, so make sure it's also appropriate with your distribution when you try it

Re: Linux Swap and SD Cards

Posted: Wed Mar 07, 2012 6:13 pm
by llewell
I once built a Debian system that ran off a USB key (it was a prototype for something we ended up not doing).  Not a ramfs system that copied everything into a ramdisk; it just ran right off the USB drive.  It didn't have any swap but it did have an SNMP-based network management system that wrote regularly to the drive.  We ran it for a week once.  The system appeared to be working fine when I shut it down.  That USB key never booted again, though, and it wasn't readable when I tried to see what the trouble was.

I believe most consumer-grade flash memory devices are good for about 100,000 writes to any location, but they normally try to avoid writing to the same location over and over.