What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Need command to create swap file

Jay Culley

Occasional Visitor
Hi. Please excuse my noobness but I am not having much luck creating a swap file. Here is what I have done:
1: Asus RT-AC5300 running Asuswrt-merlin 380.64_1, jffs enabled, only 1 script for logging vsftpd
2: The USB 3.0 port has a 1 TB NTFS drive shared with Samba for music, movies, etc /dev/sdb1 mounted on /tmp/mnt/Exthdd
3: The USB 2 port has an inexpensive Lexar 32GB thumdrive
primary partition /dev/sda2 is 27GB mounted on /tmp/mnt/lex. Latest Entware installed
4: Also on the USB2 Lexar thumbdrive is a logical partition /dev/sda5 size 1 GB formatted Linux Swap, not mounted, no files.

So I guess I need to add an entry to fstab, then run mkswap and swapon? I need the commands with the correct syntax for the BusyBox os that Merlin runs. I am assuming my swap partition of 1GB is fine since the AC5300 has 500MB of RAM, is that correct?

thanks

jay
 
You need to create the partition first ex: /dev/sda5.

# mkswap /dev/sda5
# swapon /dev/sda5

Then edit fstab:

/dev/sda5 none swap sw 0 0


or simply run "swapon /dev/sda5" command at boot script.

Yes, 1GB of swap should be fine.
 
Last edited:
so, /etc/fstab was empty, now it has one line: /dev/sda5 none swap sw 0 0

the other 2 commands looked good

user@5300:/proc# mkswap /dev/sda5
Setting up swapspace version 1, size = 1047523328 bytes
UUID=17a5db57-07b2-4b98-bb72-cb6c34e0e769
user@5300:/proc# swapon /dev/sda5
user@5300:/proc#

booting...
 
In order to check if it's working:

# free
 
did not work. /proc/swaps has nothing and running the top command list no swap at the top. Should this go in /jffs/scripts in services-start or post-mount or in a conf file in /jffs/configs?

free
total used free shared buffers
Mem: 515308 125684 389624 0 536
-/+ buffers: 125148 390160
Swap: 0 0 0
 
It didn't worked because the info you added to /etc/fstab was lost after a reboot, you need to add it there or run the swapon command via boot-script.

You will see it working if you manually run this:

# swapon /dev/sda5
# free
 
OK, good to go! I ran swapon /dev/sda5 and it is now running

free
total used free shared buffers
Mem: 515308 159664 355644 0 3380
-/+ buffers: 156284 359024
Swap: 1022972 0 1022972

I added the swapon command to /jffs/scripts/post-config so it will fire off on the next boot

Thanks @hggomes !!
 
You are very welcome Jay.
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top