Skip to content

Instantly share code, notes, and snippets.

@Aqours
Last active April 14, 2024 16:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aqours/90a364dd5f8729286c21cd87660f2c08 to your computer and use it in GitHub Desktop.
Save Aqours/90a364dd5f8729286c21cd87660f2c08 to your computer and use it in GitHub Desktop.
Creating Swap File for AsusWrt(RT-AC86U)
# @see https://www.snbforums.com/threads/add-swap-to-usb-drive-on-asus-router.46911/
# Run the command `df` to see where your USB drive is mounted.
# Should be something like /tmp/mnt/volume-label
# Of course use your volume label in the following commands.
#--------------------------------------------
# Create a swap file
#--------------------------------------------
dd if=/dev/zero of=/tmp/mnt/volume-label/myswap.swp bs=1k count=524288
mkswap /tmp/mnt/volume-label/myswap.swp
#--------------------------------------------
# Start the swap
#--------------------------------------------
swapon /tmp/mnt/volume-label/myswap.swp
# Run the `free` command to see the swap is started
# Uninstall swap: `swapoff /tmp/mnt/volume-label/myswap.swp`
# Delete swap: `rm /tmp/mnt/volume-label/myswap.swp`
#--------------------------------------------
# Create the script file in /jffs (The following is using telnet. There are other ways to create the file)
#--------------------------------------------
cat > /jffs/post-mount
# Press `Enter`
#!/bin/sh
# Press `Enter`
swapon /tmp/mnt/volume-label/myswap.swp
# Press `Enter`
# Press `Ctrl + Enter` keys
chmod 755 /jffs/post-mount
#--------------------------------------------
# Modify nvram
#--------------------------------------------
nvram set script_usbmount="/jffs/post-mount"
nvram commit
#--------------------------------------------
# Reboot the router, log in with telnet or SSH and run the free command.
# You should see the swap size of 512MB.
#--------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment