NSLU2-Linux
view · edit · print · history

In order to run programs that consume large amounts of memory (in my case rsync and >300000 files) I needed to add additional swap space on my Unslug system. I didn't like to idea to play around with the partitions on my hard drive so I just added swap space in form of a swap file. To create a swap file in folder /mnt

  1. Create a swap file:


dd if=/dev/zero of=/mnt/swapfile1 bs=1024 count=256k
mkswap -c /mnt/swapfile1

The previous commands would create a 256MB big swap file.

  1. Attach the swapfile to the existing swap space:


swapon /mnt/swapfile1

After the second step your swap space should be increased by 256MB. You can check this by typing

free

Since you probably do not want to execute the swapon command every time the slug starts up you can create your own startup script. Create a new startup file (e.g. S100addswap) in /opt/etc/init.d with the following content:

#!/bin/sh
swapon /mnt/swapfile1

You then need to make the script executable.

chmod +x /opt/etc/init.d/S100addswap

For Unslung firmware users the prefered method is to create an Unslung Script using a Unix style text editor such as vi and save this script to the /unslung folder with name rc.local, a similar method to that mentioned above.

#!/bin/sh
swapon /mnt/swapfile1
return 1

Then make the script executable.

chmod +x /unslung/rc.local


More permanent swap should probably be in its own partition. Use coreutil's fdisk to set a partitions ID to Linux swap. Then use:

mkswap /dev/sdb5

where sdb5 is your target partition. you can dynamically add it with swapon like above, or put it in /etc/fstab to have it there with each reboot, an entry like:

/dev/sdb5 none swap defaults 0 0

will work with openslug. With Unslung this may not work as fstab is overwritten by reboot - need to test and use diversion script to keep the additional swap used permamently.



The dd, mkswap and swapon commands are included with Unslung firmware. To run mkswap and swapon in OpenSlug and probably any other *Slug you will need to install util-linux.

view · edit · print · history · Last edited by RobHam.
Based on work by Krigan, hifi-andrew, fishywishywoo, Init, kaste, and Gregor Zurowski.
Originally by Gregor Zurowski.
Page last modified on June 30, 2006, at 09:49 PM