Re: Re: How to make a swapfile
"Jared B. Reimer" <[email protected]>
| Newsgroups | gmane.comp.hardware.roku.technical |
|---|---|
| Message-ID | <6.0.0.22.2.20040611060119.02ab9128@LOCALHOST> |
At 05:31 AM 6/11/2004, Peter Kirkpatrick wrote:
>I'm sorry to say that this is
>completely incomprehensible to me.
>(Unix illiterate).
WARNING: If this breaks your Roku, please don't be upset. It's not
officially supported but does work on my box.
1. Telnet in to your Roku (START, RUN, TELNET xxx.xxx.xxx.xxx, then login
as 'root' with no password) replace xxx.xxx.xxx.xxx with the IP address
of your Roku HD1000. You can find the IP in the menus somewhere, under
Setup I believe.
2. At the prompt, type:
cp /etc/rc.local /etc/rc.local.bk
cat >> /etc/rc.local
*IMPORTANT: MAKE SURE you use TWO >> and not just ONE > as ONE >
will completely clobber the file.
3. Paste the following in to your Telnet session:
#!/bin/sh
mount /dev/ide/host0/bus0/target0/lun0/part1 /mnt/flash1 -o
remount,rw,sync,noatime,nodiratime
swapfilename="/mnt/flash1/swapfile"
if [ -e "$swapfilename" ]
then
echo "Swap file $swapfilename found";
else
echo "Swap file $swapfilename not found, creating"
dd if=/dev/zero of="$swapfilename" bs=1024 count=16384
if [ "$?" -eq 0 ]
then
echo "Swapfile created successfully!"
else
echo "Failed to create swapfile"
exit 1;
fi
fi
grep "$swapfilename" /proc/swaps
if [ -e "/proc/swaps" -a "$?" -eq 0 ]
then
echo "Swap already on"
else
echo "Turning swap on..."
mkswap "$swapfilename"
swapon "$swapfilename"
fi
exit 0
4. Press CONTROL+D to save the file. You have just appended the above to
/etc/rc.local
5. Type cat /etc/rc.local and make sure it looks like the
above, with the previous stuff like this:
echo interfaces = `/usr/local/bin/getinterfaces` > /etc/smb.interfaces
echo netbios name = `/usr/local/bin/getinterfaces | head -n 1 | sed
's,/.*,,'` >> /etc/smb.interfaces
touch /var/lock/subsys/local
... showing up ABOVE the stuff you just pasted in. (Just double checking
that the append was successful!)
6. Type /etc/rc.local to test it. It should take a few minutes
to set up the swapfile the first time you run it. Note that the above
script assumes that the swapfile will be 16MB on the CompactFlash
card. You can make it larger or smaller by editing this line: dd
if=/dev/zero of="$swapfilename" bs=1024 count=16384
(change the 'count' to 32768 if you want a 32MB swapfile, etc.)
7. Type reboot on your Roku to restart it, or hold the power
button down for a few seconds. When it reboots, the swapfile should
automatically be activated.
8. To confirm that it works, simply run top and look at the
first few lines. You should see something like this:
Swap: 16380K av, 2908K used, 13472K
free 11816K cached
Note the 'Swap:' line showing 16M of available swap... Press CONTROL+C to
exit the 'top' utility.
9. If you need to undo this for whatever reason, cp
/etc/rc.local.bk /etc/rc.local
(this restores the backup file you created in step 2.)