Creating a swap space isnt so difficult. I used it on my rt-n56u router usingf these instructions below from this site:
https://code.google.com/p/rt-n56u/wiki/HowToConfigureEntware
I copied a portion of the instructions from that site and am assuming you have ssh's into your router with putty or terminal or something of that ilk. i use a 1 gig swap space which is way more than i should ever need on a router with 256mb of memory. A good rule of thums is to use a swap space 2 times larger than your memory ammount, though there are exceptions (compiling chrome os comes to mind)
If you need a swap partition
You may need a SWAP partition if you intend to use applications like BitTorrent-clients or applications that require large amounts of memory (download managers, 'tiny servers', etc.). Also, the presence of the SWAP partition is recommended when using a media server UPnP/DLNA, which is in the process of database creation of media content consumed a large amount of RAM.
Important note! It is not recommended to create swap files or partitions on USB hard drives. There is a risk of a system crash if the USB disk is unplugged incorrectly (for example, if router is powered off suddenly, or some other reason).
# fdisk -u /dev/sda
Command (m for help): m
Command Action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): d
Selected partition 1
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-15820799, default 2048): Using default value 2048
Last sector or +size or +sizeM or +sizeK (2048-15820799, default 15820799): +256M
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First sector (502049-15820799, default 502049): Using default value 502049
Last sector or +size or +sizeM or +sizeK (502049-15820799, default 15820799): Using default value 15820799
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 82
Changed system type of partition 1 to 82 (Linux swap)
Command (m for help): p
Disk /dev/sda: 8100 MB, 8100249600 bytes
175 heads, 12 sectors/track, 7533 cylinders, total 15820800 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
/dev/sda1 2048 502048 250000+ 82 Linux swap
Partition 1 does not end on cylinder boundary
/dev/sda2 502049 15820799 7659375+ 83 Linux
Partition 2 does not end on cylinder boundary
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table
Now unmount the drive:
# ejusb
Now format the partition with volume label "Main".
# mkfs.ext4 -m 0 -T largefile -L Main /dev/sda2
mke2fs 1.42.8 (20-Jun-2013)
Filesystem label=Main
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
7552 inodes, 1914843 blocks
0 blocks (0.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1962934272
59 block groups
32768 blocks per group, 32768 fragments per group
128 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
And create the swap space:
# mkswap /dev/sda1
Setting up swapspace version 1, size = 255996416 bytes