<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tutorial Library Tutlib for Your life &#187; Enable swap</title>
	<atom:link href="http://tutlib.com/tag/tag/enable-swap/feed" rel="self" type="application/rss+xml" />
	<link>http://tutlib.com</link>
	<description>Design weblog for designers, bloggers and tech users. Covering useful tools, tutorials, tips and inspirational photos.</description>
	<lastBuildDate>Tue, 07 Sep 2010 21:42:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>[Howto] Enable swap</title>
		<link>http://tutlib.com/tag/howto-enable-swap-367.html</link>
		<comments>http://tutlib.com/tag/howto-enable-swap-367.html#comments</comments>
		<pubDate>Fri, 12 Mar 2010 17:51:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Enable swap]]></category>
		<category><![CDATA[linux tutorial]]></category>

		<guid isPermaLink="false">http://tutlib.com/?p=367</guid>
		<description><![CDATA[
Tested on a ASUS WL-500g Premium with Kamikaze 7.07 (brcm-2.4).

1. Install kmod-loop, losetup and swap-utils packages

ipkg install kmod-loop losetup swap-utils

2. Create the UCI configuration file (/etc/config/swap)
config swap
        option path     '/tmp'
        option filename 'swapfile'
    


Related posts:<ol><li><a href='http://tutlib.com/tag/mini-ad-spot-v1-4-joomla-module-318.html' rel='bookmark' title='Permanent Link: Mini Ad Spot v1.4 Joomla Module'>Mini Ad Spot v1.4 Joomla Module</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://tutlib.com/wp-content/uploads/2010/03/swap_tutlib.com_.jpg"><img class="aligncenter size-full wp-image-368" title="swap_tutlib.com" src="http://tutlib.com/wp-content/uploads/2010/03/swap_tutlib.com_.jpg" alt="" width="418" height="286" /></a></p>
<p>Tested on a ASUS WL-500g Premium with Kamikaze 7.07 (brcm-2.4).</p>
<p><span id="more-367"></span></p>
<p><strong>1.</strong> Install kmod-loop, losetup and swap-utils packages</p>
<div>
<pre>ipkg install kmod-loop losetup swap-utils

<strong>2.</strong> Create the UCI configuration file (/etc/config/swap)
<pre>config swap
        option path     '/tmp'
        option filename 'swapfile'
        option size     '2000'

<strong>3.</strong> Create the init script to initialize the swap space  on every boot
<pre>#!/bin/sh /etc/rc.common
# Copyright (C) 2007 OpenWrt.org
START=98
sleep 5

start_service () {
        local section="$1"
        config_get path     "$section" path
        config_get filename "$section" filename
        config_get size     "$section" size

        dd if=/dev/zero of=/$path/$filename count=$size
        losetup /dev/loop/0 /$path/$filename
        mkswap /dev/loop/0
        swapon /dev/loop/0
}

start() {
        config_load "swap"
        config_foreach start_service swap
}

stop() {
        swapoff /dev/loop/0
}

<strong>4.</strong> Make the init script executable
<div>
<pre>chmod +x /etc/init.d/swap

<strong>5.</strong> Enable the swap space, by default a swap space with  1MiB on /tmp in the ramdisk will be created.
<pre>/etc/init.d/swap enable
/etc/init.d/swap start

<strong>6.</strong> You can change a few parameters using UCI.
<pre>OPTION      DEFAULT VALUE    DESCRIPTION
path        /tmp             Location where swap file will be stored.
filename    swapfile         Name of the swap file.
size        2000             Size in blocks: 1000 blocks = 512 Kbytes | 1 Megabyte = 2000 blocks

E.g. to change to location of the swap file to your USB pen drive and  change the size of the swap space to 256MiB do:
<pre>uci set swap.cfg1.path=/mnt/usb
uci set swap.cfg1.size=512000
uci commit swap
/etc/init.d/swap restart

<strong>7.</strong> With the 'free' command you can check the swap space  usage...
<pre>              total         used         free       shared      buffers
  Mem:        30512        13856        16656            0         1316
 Swap:          992            0          992
Total:        31504        13856        17648</pre>
</pre>
</pre>
</pre>
</pre>
</div>
</pre>
</pre>
</pre>
</div>


<p>Related posts:<ol><li><a href='http://tutlib.com/tag/mini-ad-spot-v1-4-joomla-module-318.html' rel='bookmark' title='Permanent Link: Mini Ad Spot v1.4 Joomla Module'>Mini Ad Spot v1.4 Joomla Module</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://tutlib.com/tag/howto-enable-swap-367.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->