How to activate SWAP on Asus RT-AC68U router

To enable linux SWAP on your Asus RT-AC68U router you need the following:

  • Custom firmware with jffs partition enabled (I recommend Asuswrt-Merlin build);
  • an USB HDD or USB flash drive to mount on one of your router’s USB ports.

Using a swap file

To enable swapping using a swap file you need to first create the file, prepare it for swapping and then enable the swapping on it. First of, make sure the file system the disk you wish to swap on is properly mounted. If you chose labels for the partitions, use them instead of sda1, sda2, sdb1, etc.

#check how the disk was mounted
ls -l /tmp/mnt

For the purposes of this tutorial we will assume the disk is mounted as /tmp/mnt/sda1/ and we want to use the file /tmp/mnt/sda1/myswap.swp for swapping.

#create a 256MB swap file ("count" is in Kilobytes)
dd if=/dev/zero of=/tmp/mnt/sda1/myswap.swp bs=1k count=262144

#set up the swap file
mkswap /tmp/mnt/sda1/myswap.swp

#enable swap
swapon /tmp/mnt/sda1/myswap.swp

#check if swap is on

If you reboot your router, the swap will be inactive until you swapon again. To do this automatically you have to create the file /jffs/scripts/post-mount, or edit it if exists and add the line:

swapon /tmp/mnt/sda1/myswap.swp

Now every time the router reboots, it will turn on swap.

Using a swap partition

This method is not recommended if using USB storage with multiple partitions.

  1. Using your computer, create a linux-swap partition on your disk that will be mounted on the router. You can use GParted for linux, MiniTool Partition Wizard Home Edition for Windows or Disk Utility for MacOS;
  2. Connect the formatted drive to router and in PuTTY terminal use command fdisk -l to see how it was mounted. Let’s asume it is mounted as sda1;
  3. Again in PuTTY terminal use command swapon /dev/sda1 and then free to see if swap is correctly activated;
  4. If swap is correctly activated, use the script /jffs/scripts/post-mount with the command swapon /dev/sda1 as mentioned above.
swapon /dev/sda1


Do not use SWAP (partition or file) on a device which goes to hibernation or does spin-down. You might make the router more unstable than without using SWAP.

Be sure you deactivate spin-down on the device which you want to use for SWAP.

Spin-down settings on ASUS router powered by Asuswrt-Merlin

Spin-down settings on ASUS router powered by Asuswrt-Merlin

There are some devices, like the Western Digital USB HDDs WD Elements, My Book or My Passport which have their own power management and will not be affected by the settings on the router and they will spin-down if data is not read or written for some time. I recommend to avoid this kind of devices for SWAP.

Info source:

8 thoughts on “How to activate SWAP on Asus RT-AC68U router

  1. Pingback: How to install transmission for Optware on Asus RT-AC68U | Software development tutorials

  2. Pingback: How to install Optware on ASUS RT-AC68U | Software development tutorials

  3. Good timing – I had looked for this before and couldn’t get it working. This worked first time. The first command line takes time to complete …

  4. I just want to point out that I had to set “Enable JFFS custom scripts and configs” to “Yes” for the post-mount script to run. This option can be found: Administration -> System.

  5. Thanks for the guide, I wasn’t able to make my script work on reboot until I made it executable with this command.

    chmod a+rx /jffs/scripts/*

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s