This is an old revision of the document!
It is highly advisable to make some form of permanent storage available to Tomato. A swap partition can prevent several types of insufficient RAM symptoms, such as system instability, failing processes, and in very severe cases, even spontaneous reboots. All this will depend largely on the network load and on Tomato's configuration. Some functions require much more RAM than others, and higher network traffic will put more load on the router and require more RAM than lower traffic. USB is an excellent candidate for providing swap space.
Assuming you are using either an ARM build or a MIPS build with USB support, it is assumed you have already have USB support enabled.
For this example I'm using a 16GB USB 3.0 USB flash drive which is seen in the system as sda.
This assumes your drive device device name is sda ! If it's not, make sure to change the following commands consistent with your drive's device name.
The echo 1000M statement below defines the size of the swap partition (in MB). You may want to adjust that, according to your needs.
Then enter:
device=/dev/sda partition=$device'1' nvram set usb_automount="0" (echo o; echo n; echo p; echo 2; echo ; echo 1000M; echo t; echo 82; echo n; echo p; echo 1; echo ; echo ; echo w) | fdisk $device mkfs.ext2 -L USB $partion mkswap /dev/sda2 swapon /dev/sda2 mkdir /mnt/sda1 && mount /dev/sda1 /mnt/sda1 nvram set usb_automount="1"
From the Web interface, disable the Automount checkbox in the USB and NAS/USB Support menu.
Via SSH: delete any existing partitions:
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>fdisk /dev/sda</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>o</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>At this point your USB flash drive is unpartitioned. Now let's create the necessary partition table:</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>n</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>p</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>2</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>ENTER (default)</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>1000M (Essentially 1 GB out for swap)</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>t</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>82</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>n</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>p
ENTER (default)</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>ENTER (default)</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>l (to verify)</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>w (to save and exit fdisk)</font>
At this point you should have two unformatted partitions on your USB flash drive:
sda1 ~14GB (fs-type ext2/3/4)
sda2 ~1GB (fs-type swap)
Now, let's format the partitions. NOTE: it is suggested you use <font inherit/inherit;;#c0392b;;inherit>ext2</font> for USB flash drives and ext3 for hard disks.
mkfs.ext2 -L USB /dev/sda1 mkswap /dev/sda2
Now, mount the partitions
swapon /dev/sda2 mkdir /mnt/sda1 && mount /dev/sda1 /mnt/sda1
You can now re-enable USB Automount on the USB and NAS menu.