TechInfoDepot:Tomato/How to enable swap in TomatoUSB

From TechInfoDepot
Jump to navigationJump to search

Thx to jomcty

1. Partition and format a drive with a swap partition (>= 15MB) and at least one data partition (if FLASH-based drive use ext2, otherwise use ext3).

Assign the swap and data partition a single-word descriptive label. For example use the label SWAP for the swap partition. The SWAPNAME variable in the script will have to reflect this label name.

2. Create the following script in the root directory of the data partition of the external drive, using vi, naming it "00-start-swap.autorun":

#!/bin/sh
# $1 - The fully qualified path of the root directory of the mounted drive
#      (w/o any trailing '/').
# See: http://www.linksysinfo.org/forums/showthread.php?p=364690#post364690

# The decriptive label assigned to the swap partition.
SWAPNAME=SWAP #Replace SWAP with your swap partitions label

# If no parameter, complain and quit.
[[ xx == x$1x ]] && exit

# Edit fstab to put the swap partition label there.
sed -i "/^LABEL=.* swap swap/d" /etc/fstab
echo "LABEL=$SWAPNAME swap swap" >>/etc/fstab

# Activate the swap partition
swapon -a

With the script in place in the root-directory of the mounted drive the swap partition will be mounted whenever the drive is plugged in.

The swap partition will auto-unmount when the drive is unmounted via the Tomato GUI.

swap in TomatoUSB