Feature Request: Please enable swap file/partition handling.

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Goto page 1, 2  Next

If mmc/sd swap support is enabled, would you use it?
Yes, I know what swap is for and it would be useful.
77%
 77%  [ 7 ]
No, I have loads of free ram and don't need swap.
11%
 11%  [ 1 ]
Huh? What's all this swap stuff about anyway?
11%
 11%  [ 1 ]
Total Votes : 9

Author Message
zardoz99
DD-WRT Novice


Joined: 17 May 2007
Posts: 4

PostPosted: Fri May 18, 2007 14:10    Post subject: Feature Request: Please enable swap file/partition handling. Reply with quote
As a matter of urgency, please could the version of busybox being distributed with dd-wrt v24 be enabled for "mkswap", "swapon" and "swapoff" commands.

This would save a lot of time and memory for those of use who have to install a huge amount of "optware" just to make these functions available.

Now that mmc/sd card support is well established, it makes sense for there to be the basic swapfile or swap-partition support on external media.

Manny thanks,

Z.
Sponsor
michielske
DD-WRT Novice


Joined: 08 Apr 2007
Posts: 40

PostPosted: Fri May 18, 2007 14:37    Post subject: Reply with quote
i hope it can be possible to add a new busybox.
Now i have to install lots of things to make swapon available for use.
and a torrent client with gui in the webbrowser should be very nice too.
i use enchanced-ctorrent added the torrentclient to a modded firmware but i need to start it in from the commandline.
Is it also possible to add the old smbmount in stead of CIFS , i have here an ethernet harddisk that can only be mounted with a patched smbfs.o file. I tried lot of things with cifs but always get errors. and i think that there a lot of people with that problem.
xciton
DD-WRT User


Joined: 07 Jun 2006
Posts: 50

PostPosted: Fri May 18, 2007 20:06    Post subject: Reply with quote
Let me see if I understand you correctly. You want to enable swap on a flash device?

If so, perhaps you should research that a bit first.
olmari
DD-WRT Guru


Joined: 24 Oct 2006
Posts: 1447
Location: Finland

PostPosted: Fri May 18, 2007 20:36    Post subject: Reply with quote
Swap? On flash device? Flash is pretty much THE reason there are no flash at first place... Flash wears out at each write, hence it is read only, and even when using JFFS etc it still has no swap...
zardoz99
DD-WRT Novice


Joined: 17 May 2007
Posts: 4

PostPosted: Fri May 18, 2007 22:25    Post subject: Reply with quote
It's worth reading http://en.wikipedia.org/wiki/NAND_flash about flash endurance with modern devices. It's not as bad as it used to be. And with the way that swap would be used on this type of device, it tends to be only at critical times, and not just on the fly paging.

Ok, so it's not a brilliant solution, but until drivers exist that allow the use of the very small CF format hard disks from people like Seagate, we are limited in our choices.

All constructive comments are welcomed...

Z.
xciton
DD-WRT User


Joined: 07 Jun 2006
Posts: 50

PostPosted: Fri May 18, 2007 23:03    Post subject: Reply with quote
Why do you feel swap is the answer to your problem? What is the problem?

Swapping should be avoided at almost any cost. Even on standard unix/windows machines, swap is an expensive operation. Swapping to flash is even worse for speed.

It won't take long for 100,000 writes to add up when using swap. Even if you only changed a byte every 15 minutes, that's 2.8 years of service. Not to mention, that you don't traditionally erase one byte, but usually a sector/page of flash at a time instead.

Swapping to flash is "Just not the right way to do things" (tm). Either cut back on what processes are running (and/or reduce the RAM usage on some processes), or add more physical RAM.



edit: okay it looks like they're up to about 1,000,000 writes on some devices, I don't know what the ratings are on the chips on wrt platforms.
zardoz99
DD-WRT Novice


Joined: 17 May 2007
Posts: 4

PostPosted: Fri May 18, 2007 23:26    Post subject: Reply with quote
The mmc device I am using is a SanDisk 1GB MiniSD SDSDM-1024-E10M in a carrier, used as a socket. I wouldn't put any load on the internal flash, mostly as it's extrememly hard to replace. However, a removable external MiniSD card is at least changable if/when it wears out.

Reason for swap? Well, I'm using one of the partially crippled WRT54GSv4 units. The ones where Linksys in thier wisdom decided to halve the built in flash and ram from previous versions. Adding more ram is not going to be easy!

Agreed on the desirability of swap. It's not performant... However, it can save you from having processes killed because of sudden memory requirement transients.

Of course, the next option is swap over ethernet.. It can be done, and it works on "some" networking protocols, like NFS for example. It's actually used in some thin-client workstatsions based on PXE booted linux.

Z.
kocoman
DD-WRT User


Joined: 27 Oct 2006
Posts: 58

PostPosted: Wed Dec 05, 2007 2:58    Post subject: Reply with quote
As of v24 RC5 its still not implemented...
oleo
DD-WRT User


Joined: 25 Jul 2006
Posts: 120

PostPosted: Fri Dec 07, 2007 20:59    Post subject: Reply with quote
I've ran this on DD-WRT v24 RC5 wl500gd with 500MB swap
Code:
root@demsar-wl:~# free
              total         used         free       shared      buffers
  Mem:        30316        29448          868            0         1556
 Swap:       506036            0       506036
Total:       536352        29448       506904
root@demsar-wl:~# dd if=/dev/zero of=/tmp/a bs=1M count=20
20+0 records in
20+0 records out
root@demsar-wl:~# free
              total         used         free       shared      buffers
  Mem:        30316        29752          564            0          224
 Swap:       506036          972       505064
Total:       536352        30724       505628

It seems like swap is working?
flokrates
DD-WRT Novice


Joined: 01 Jan 2008
Posts: 7

PostPosted: Tue Jan 01, 2008 17:38    Post subject: Reply with quote
Hi oleo,

I've also tried v24 RC5 (Std. as well as VPN) with my Asus WL-500gP but can't get swap working like you've described in:

http://www.dd-wrt.com/wiki/index.php/Optware#Startup_for_external_USB_Disk

Upon calling "swapon" I get following error mesasge:

Code:
swapon: can't resolve symbol 'swapon'


Can you please let us know which exact version of RC5 you've used?

Personally I believe that the kernel support for swapping is still not activated in DD-WRT, thus I'm wondering how you could get this working ;)

flokrates
oleo
DD-WRT User


Joined: 25 Jul 2006
Posts: 120

PostPosted: Tue Jan 01, 2008 20:20    Post subject: Reply with quote
Pay attention to LD_LIBRARY_PATH setting. There is the catch. Differrent binaries d=needs different uCLibc
flokrates
DD-WRT Novice


Joined: 01 Jan 2008
Posts: 7

PostPosted: Wed Jan 02, 2008 11:40    Post subject: Reply with quote
Thanks for your quick reply.

I agree that this has to do something with a missing library or a screwed up library configuration.

I've checked the script again, but the LD_LIBRARY_PATH settings is exactly the same as in the script you've provided.

Thus I've started from scratch. I wiped out my JFFS partition unplugged the USB disc and did following:

Code:
ipkg install swap-utils
dd if=/dev/zero of=/tmp/test.swp BS=1M count=2
/jffs/usr/sbin mkswap /tmp/test.swp

So this installs the swap-utils package and finally I've created a 2 mb swap file in the temp directory. Well, creating a swap file in RAM is not the best idea, but for this test I assume it's okay ;)

And finally I tried to activated swap, but still fails:

Code:

root@Stargate:/jffs/usr/sbin# ./swapon /tmp/test.swp
./swapon: can't resolve symbol 'swapon'

To sum up: I haven't loaded any USB modules, no optware, nothing, it's a clean JFFS. The only thing which is on JFFS is the "swap-utils" package.

So there are two options: A library is missing (e.g. uclibc) or it is failing due to kernel support.

Do you know if a special library is needed for the swap-utils package, at least there is no dependency specified for this package?!

flokrates
CaScAdE
DD-WRT Guru


Joined: 18 Jun 2006
Posts: 1110
Location: Kiel (54.4247,10.1721)

PostPosted: Wed Jan 02, 2008 12:49    Post subject: Reply with quote
flokrates wrote:
To sum up: I haven't loaded any USB modules, no optware, nothing, it's a clean JFFS. The only thing which is on JFFS is the "swap-utils" package.

So there are two options: A library is missing (e.g. uclibc) or it is failing due to kernel support.

Do you know if a special library is needed for the swap-utils package, at least there is no dependency specified for this package?!


You have absolutely NO clue what this is all about, right?

The packages are NOT for dd-wrt. We use them, but they are for other distributions.
In other distributins there are other uClibc and stuff available which HAVE this stuff, but not in dd-wrt.
So you NEED other uclibc... uclibc-opt_0.9.28-12_mipsel.ipk if I remember it correcty.

To bring it to a clear statement: The depencies in the file are not the only stuff you need for running them on dd-wrt.

Afterwards there is still the problem that cou cannot put the lib to /lib, only to /tmp/lib /jffs/lib /mmc/lib or /opt/lib (except you are copying the whole /lib to /jffs/lib and binding the /jffs/lib to /lib). So you need binaries which look in other pathes than /lib or you need an updated ld.so.conf/ld.so.cache which tells the binaries where to look...
This is why in the Wiki Optware installs uclibc-opt_0.9.28-12_mipsel.ipk and afterwards an ipkg-opt which works for opt-bins...

Installing openwrt packages is not easy since they often want to write their stuff to /lib /bin /sbin and so on, but you can not do this using dd-wrt. So installing the crosscompiled unslug bins is far easier.

Code:
DD-WRT v24 std (c) 2007 NewMedia-NET GmbH
Release: 11/22/07 (SVN revision: 8422)

testing.113.wck login: root
Password:
==========================================================

 ____  ___    __        ______ _____         ____  _  _
 | _ \| _ \   \ \      / /  _ \_   _| __   _|___ \| || |
 || | || ||____\ \ /\ / /| |_) || |   \ \ / / __) | || |_
 ||_| ||_||_____\ V  V / |  _ < | |    \ V / / __/|__   _|
 |___/|___/      \_/\_/  |_| \_\|_|     \_/ |_____|  |_|

                       DD-WRT v24
                   http://www.dd-wrt.com

==========================================================


BusyBox v1.4.2 (2007-11-24 17:34:58 CET) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

root@testing:~# uname -a
Linux testing.113.wck 2.4.35 #2715 Sat Nov 24 17:38:59 CET 2007 mips unknown
root@testing:~# dd if=/dev/zero of=/opt/.swapfile bs=1M count=32
32+0 records in
32+0 records out
root@testing:~# /opt/sbin/mkswap /opt/.swapfile
Setting up swapspace version 1, size = 33550337 bytes
root@testing:~# /opt/sbin/swapon /opt/.swapfile
root@testing:~# free
              total         used         free       shared      buffers
  Mem:        30316        29620          696            0         1520
 Swap:        32760            0        32760
Total:        63076        29620        33456
root@testing:~#


edit:
Code:
root@testing:~# free
              total         used         free       shared      buffers
  Mem:        30316        29612          704            0         1344
 Swap:        32760          324        32436
Total:        63076        29936        33140
root@testing:~#

now it is even used...

_________________
DD-WRT F.A.Q.

Webcam Kiel
flokrates
DD-WRT Novice


Joined: 01 Jan 2008
Posts: 7

PostPosted: Wed Jan 02, 2008 14:40    Post subject: Reply with quote
First thanks for your reply. Nevertheless I'm new to this topic and I try to get the big picture, as it is quite confusing in some places.

Just to let you know: Swapping is working for me using the latest busybox from optware, but I was wondering how oleo can do it in his script as he is mounting his opt partition after he has activated swapping. Also he is setting the library path /jffs/lib and /jffs/usr/lib, I can't see any library path to /opt/lib, /jffs/opt/lib where the libs from the "uclibc-opt" package are located:

Code:
 # assure correct paths when running OpenWRT programs like e2fsck
 export LD_LIBRARY_PATH=/jffs/lib:/jffs/usr/lib                         
 export PATH=/jffs/bin:/jffs/sbin:/jffs/usr/sbin:/jffs/usr/bin:/bin:/sbin
                         
 echo "Activating swap..."   
 swapon /dev/discs/disc0/part2
                                     
 echo "Checking optware partition..."
 e2fsck -p /dev/discs/disc0/part1
                                   
 echo "Checking user-data partition"
 e2fsck -p /dev/discs/disc0/part3
                                   
 echo "Mountint disk partitions..." 
 export LD_LIBRARY_PATH=/lib:/usr/lib               
 mount -t ext3 -o noatime /dev/discs/disc0/part1 /opt
 mount -t ext3 -o noatime /dev/discs/disc0/part3 /mmc


Full script to be found at: http://www.dd-wrt.com/wiki/index.php/Optware#Startup_for_external_USB_Disk

Do you have got an idea what's the trick here?

flokrates
CaScAdE
DD-WRT Guru


Joined: 18 Jun 2006
Posts: 1110
Location: Kiel (54.4247,10.1721)

PostPosted: Wed Jan 02, 2008 15:08    Post subject: Reply with quote
Trick is easy: He has the stuff in /jffs I guess...
Thats what jffs is intended to be for...

_________________
DD-WRT F.A.Q.

Webcam Kiel
Goto page 1, 2  Next Display posts from previous:    Page 1 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum