PDA

Bekijk de volledige versie : Swap File Howto



kjentsch
27-09-2005, 14:05
Hi, I'm new to this forum - proud owner of a wl-hdd (running current oleg fw - thanks for a really nice package!) since early summer and using it to stream music to a upnp client.

I found that running dropbear,smbd,nmbd,ftpd and the twonkyvision upnp server simultaneously requires - sometimes - more memory than the wl-hdd has. Of course I had never thought of including a swap partition on the harddisk - and was unwilling to do that when I noticed the need for swap space... The only viable solution was creating a swap file.

Why do I post this?
a) I figure that more people might be experiencing random server crashes, lockups etc. without having any idea how to fix that
b) (I don't know whether the Oleg firmware detects and activates swap partitions automagically) I reckon that I'm not the only one without a swap partition.
c) I couldn't find any documentation on how to set up a swap file on the wl-hdd on this forum.

Here's a short howto for a 16MB swapfile on a single-partition, automounted harddisk inside a wl-hdd; it works for me, your mileage may vary.

login as admin via telnet or ssh (if you already have dropbear running)
create an empty file in /tmp/harddisk using the command

dd if=/dev/zero of=/tmp/harddisk/swapfile bs=1024 count=16384
the output of that command should be

16384+0 records in
16384+0 records out
next prepare this empty, 16MB file to be used as swap space by typing:

mkswap /tmp/harddisk/swapfile
which should output

Setting up swapspace, size = 16777216 bytes

Now insert
swapon /tmp/harddisk/swapfile into your
/usr/local/sbin/post-mount script, directly after
#!/bin/sh (which should be on the first line) on a new line by itself. If you had to insert the line
#!/bin/sh, too, you will have to enter

chmod +x /usr/local/sbin/post-mount now in order to make this script executable - and thus have it executed at unit startup, after the harddisk now containing the swap file is mounted.

a subsequent

flashfs save
flashfs commit
flashfs enable
sequence saves the last change to persistent memory.

Anyone using the Oleg firmware should be familiar with the last few steps, anyway (and should also have at least some idea what he/she's doing there), but I'm including that part for completeness.

Flame me if this has been posted elsewhere on this board - I haven't found anything. Hope this helps some people - works for me on wl-hdd with a single ext3 (shouldn't matter) partition hdd and oleg fw 1.9.2.7-6b.

Comments, corrections and additions welcome.

MobyDick
15-03-2007, 11:48
Thanks!!!!!