usb_formatting_with_swap_partition [FreshTomato Wiki]

Site Tools


USB formatting with swap partition

It is suggested to have some sort of permanent storage made available to tomato. USB is an excellent candidate and an provide a swap partition to prevent issues.

Given that you are using either an ARM build or a MIPS with USB support, it is assumed you have already enabled USB support.

For this exmaple I'm using a 16GB USB3 pen drive which is seen in the system as sda.

Automatic way:

make sure your device is actually sda!

The echo 1000M below defines the size of the swap partition you might want to adjust that.Then:

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"

Manual way:

From the GUI: Disable the automount under USB and NAS/USB Support

Via SSH: delete any exsisting partitions:

fdisk /dev/sda


At this point your USB pen drive is unpartitioned. Now let's go into creating the partition table needed:




ENTER (default)

1000M (Essentially 1 GB out for swap)





ENTER (default)

ENTER (default)

l (to verify)

w (to save and exit fdisk)

At this point you should have two unformatted partitions in your USB:

sda1 ~14GB (fs-type ext2/3/4)
sda2 ~1GB (fs-type swap)

Let's format the partitions. NOTE: it is suggested to use ext2 for pen drives and ext3 for hard disks.

mkfs.ext2 -L USB /dev/sda1
mkswap /dev/sda2

mount the partitions:

swapon /dev/sda2
mkdir /mnt/sda1 && mount /dev/sda1 /mnt/sda1

You can now re-enable the USB automount under USB and NAS/USB Support

Final set up:

Now your USB is formatted you USB and NAS page should look like this:


To verify the swap partition to be working ok head towards the overview page and you should see some info related to swap:

usb_formatting_with_swap_partition.txt · Last modified: 2020/06/09 07:36 by rs232