• Home
  • Help
  • Search
  • Login
  • Register
Pages: [1]
Author Topic: Swap partitition  (Read 5341 times)
jmknapp
Newbie
*

Karma: 0
Posts: 45



View Profile
« on: April 22, 2009, 06:46:24 AM »

I've added a 16GB SD card as the root partition. As the plug comes without a swap partition configured, would it be advantageous to create a swap file on the SD card?

Joe
« Last Edit: April 22, 2009, 06:58:00 AM by jmknapp » Logged

Rabeeh Khoury
Administrator
Full Member
*****

Karma: 5
Posts: 218


View Profile
« Reply #1 on: April 22, 2009, 08:31:26 AM »

you can do that, but personally i think putting a swap partition on a NAND flash technology based card isn't a good idea - it might wear out the NAND flash pretty fast.
Logged

steveo
Newbie
*

Karma: 0
Posts: 2


View Profile
« Reply #2 on: April 23, 2009, 07:45:03 AM »

Generally swap is a bad idea on SSD but if its a cheap card and you're alright with potentially wearing out at least the swap partition area very quickly, then I guess proceed as usual. For more information check out SSD talk on computer than come with solid state drives like the AsusEEE:

http://wiki.archlinux.org/index.php/Installing_Arch_Linux_on_the_Asus_EEE_PC shows this for example:

   1. Never choose to use a journaling file system on the SSD partitions
   2. Never use a swap partition on the SSD
   3. Edit your new installation fstab to mount the SSD partitions "noatime"
   4. Never log messages or error log to the SSD

These rules ensure that we won't reach the maximum limit of writes on our SSD faster than we should, although this is being contested



hope that helps,
s
Logged

jmknapp
Newbie
*

Karma: 0
Posts: 45



View Profile
« Reply #3 on: April 23, 2009, 08:24:05 AM »

Thanks for the replies. As I have the root partition on a removable 16GB SD card & given that having swap space is a good idea (barring this wear-out issue), I think what I'm going to do is make a 1GB swap file on the card and see what happens. I'll do a nightly backup of the card to the USB drive (dd if=/dev/sda1 of=/<usbroot>/backupXX), saving the last few backups or so, and then another SD card can be loaded from backup if the first one fails.

It should be interesting to see if or when the card would wear out. I did format it ext3 (journaling file system) which is also in the list of "don'ts." However, other opinions on SDHC SD cards refer to the wear-leveling features of that technology & hold that the wear-out issue is overblown, as it would take many years to hit the 1,000,000 write spec of these cards even if they were hammered constantly with writes.

Joe
Logged

plugit
Global Moderator
Full Member
*****

Karma: 0
Posts: 139



View Profile
« Reply #4 on: April 23, 2009, 09:56:31 AM »

Depends on the application, too. Obviously swap is a good thing, but are you going to exhaust the 512M RAM? And as for journaling, are you writing to the rootfs often? The way I have things set up, all the disk churn happens on an external disk drive, and I seem to have about half my memory free most of the time, and I'll bet a good lump of the used memory is just cache!

Just thinking aloud. Smiley
Logged

jmknapp
Newbie
*

Karma: 0
Posts: 45



View Profile
« Reply #5 on: April 24, 2009, 05:40:18 AM »

I only have a vague idea of what journaling entails, but it seems at least at this early experimental stage I often just rudely unplug the SheevaPlug without a graceful shutdown, my impression is that a journaling filesystem is prudent.

On memory usage, right after a reboot very little is used, but I notice that it gets to 95%+ used pretty quickly, although as you say a lot of it is cache. Like right now I get from 'free':

Code:
             total       used       free     shared    buffers     cached
Mem:        515636     511196       4440          0     242460      56572
-/+ buffers/cache:     212164     303472
Swap:      1048568      34052    1014516

X11, gnome, vnc, samba, apache, sendmail and mysql are running.

Joe

« Last Edit: April 24, 2009, 05:42:30 AM by jmknapp » Logged

plugit
Global Moderator
Full Member
*****

Karma: 0
Posts: 139



View Profile
« Reply #6 on: April 24, 2009, 06:06:01 AM »

Oh, I guess if you're running X then you'll want swap. I would.
Logged

earplug
Newbie
*

Karma: 0
Posts: 1


View Profile
« Reply #7 on: April 24, 2009, 09:11:25 AM »

There is "compcache" if you're one of the people nervous about possibly wrecking their flash card - http://code.google.com/p/compcache/
Like how swap swaps unused pages to disk/wherever, compcache compresses unused pages.

For people not worried about SSD wear and tear, I think a swapfile is to be preferred over a swap partition. Historically, a swap file would be slower because it would have to go through the filesystem, but these days in Linux using a swapfile finds out what blocks to use at swapon, then writes to them directly, no filesystem middleman (so it's the same speed as a swap partition for access, it just takes longer at swapon).

A swap file is better than a swap partition because when you delete it, you instantly get the space back - you don't have to backup, unmount, resize, remount your whole filesystem. And also, a swap file carries the risk of becoming fragmented, impossible for a swap partition, but on solid state storage that is not an issue.

So in summary, on embedded Linux a swap file is always preferable over a swap partition, but if I were you I would just go for compcache (or similar technology).


Logged

KostaP
Global Moderator
Newbie
*****

Karma: 0
Posts: 20



View Profile
« Reply #8 on: April 24, 2009, 12:09:47 PM »

I personally run NBD server on my NAS. That allows me to "swap over the network". It might be not the fastest swap ever, but on some low-memory embedded systems sometimes you need more memory then generally available - for instance for locales generation or native compilations. I saw "memory exhausted" message on boards with 64M RAM when desided to add some swap space. However with Shiva's 512M you may not need one.
Logged

Pages: [1]
Print
Jump to: