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!

Asus merlin rt-n16 swap

kiesa1231

Regular Contributor
Hello need help.I buy router asus rt-n16 and installed latest asus merlin firmware.How setup at boot mkswap and swapon?
I enable jffs2 partition and write init-start script but not working.I have 1TB seagate hdd.1 partition /dev/sda1 is ntfs and /dev/sda2 formated swap partition.Very please help how setup /dev/sda2 partition swap at boot.Thanks
 
Hello need help.I buy router asus rt-n16 and installed latest asus merlin firmware.How setup at boot mkswap and swapon?
I enable jffs2 partition and write init-start script but not working.I have 1TB seagate hdd.1 partition /dev/sda1 is ntfs and /dev/sda2 formated swap partition.Very please help how setup /dev/sda2 partition swap at boot.Thanks
Hi,

This might help: Here my pre-mount script (placed in /jffs/scripts folder):
Code:
#!/bin/sh
/usr/bin/logger -t START_$(basename $0) "started [$@]"
SCRLOG=/tmp/$(basename $0).log
touch $SCRLOG
echo "START_$(basename $0) started [$@]" >> $SCRLOG
[B]if [ $1 = "/dev/sda1" ]
then
/sbin/swapon /dev/sda1 >> $SCRLOG
wait
fi
if [ $1 = "/dev/sda2" ]
then

fi[/B]
if [ "$?" -ne 0 ]
then
echo "Error in pre-mount execution! Script: $0" >> $SCRLOG
#exit $?
else
echo "Pre-mount execution OK. Script: $0" >> $SCRLOG
#exit 0
fi
/usr/bin/logger -t STOP_$(basename $0) "return code $?"
exit $?
As marked bold: The two if commands find out which partition is due to be mounted and there you can add the swapon action.
Do not forget to add the execution bit for the scripts in the /jffs/scripts folder with the command:
chmod a+x *

If you not not like my logging (to syslog.log plus seperate log per script), you can remove the lines.

With kind regards
Joe :cool:
 
Last edited:
Hi,

This might help: Here my pre-mount script (placed in /jffs/scripts folder):
Code:
#!/bin/sh
/usr/bin/logger -t START_$(basename $0) "started [$@]"
SCRLOG=/tmp/$(basename $0).log
touch $SCRLOG
echo "START_$(basename $0) started [$@]" >> $SCRLOG
[B]if [ $1 = "/dev/sda1" ]
then
/sbin/swapon /dev/sda1 >> $SCRLOG
wait
fi
if [ $1 = "/dev/sda2" ]
then

fi[/B]
if [ "$?" -ne 0 ]
then
echo "Error in pre-mount execution! Script: $0" >> $SCRLOG
#exit $?
else
echo "Pre-mount execution OK. Script: $0" >> $SCRLOG
#exit 0
fi
/usr/bin/logger -t STOP_$(basename $0) "return code $?"
exit $?
As marked bold: The two if commands find out which partition is due to be mounted and there you can add the swapon action.
Do not forget to add the execution bit for the scripts in the /jffs/scripts folder with the command:
chmod a+x *

If you not not like my logging (to syslog.log plus seperate log per script), you can remove the lines.

With kind regards
Joe :cool:
Thanks but not working.My swap partition is /dev/sda2 Post edit now working i change to this
if [ $1 = "/dev/sda2" ]
then
/sbin/swapon /dev/sda2 >> $SCRLOG
wait
fi
if [ $1 = "/dev/sda1" ]
 
Last edited:
Second question how make username in latest merlin version as root?When i try change username in webif to root i get this error "User's account cannot be 'root', 'guest' or 'anonymous'! Please enter a valid account". I use username root on all routers.Please help thanks
 
Second question how make username in latest merlin version as root?When i try change username in webif to root i get this error "User's account cannot be 'root', 'guest' or 'anonymous'! Please enter a valid account". I use username root on all routers.Please help thanks
Hi,

Well it clearly say: "User's account cannot be 'root', 'guest' or 'anonymous'! Please enter a valid account".
"Root" is simply not possible. Full stop.

What is your question now? :rolleyes:

With kind regards
Joe :cool:

PS.: Double positings does not make things better... :mad:
 
Hello Joe,

Is there a guide somewhere I can use to create/enable a swap space on my RT-N66U router? I would like to make sure I am not going to run out of memory.
 
Is there a guide somewhere I can use to create/enable a swap space on my RT-N66U router?
Hi,

Your router is running a, small version, of Linux. For the creation and usage of a Swap partition (or file) you have to use the standard Linux commands:
- fdisk - to partition the drive and create a swap partition (if you not going for a swap-file)
- mkswap - to prepare the partition or the file for swap usage
- swapon - to enable swap (on each boot) - or you use a custom fstab configuration (which I do not recommend)

Google will help you finding the necessary information on how to use these standard Linux tools.
PLUS: You will learn to search for information and you will learn something about Linux! :rolleyes:

With kind regards
Joe :cool:
 
#!/bin/sh
/usr/bin/logger -t START_$(basename $0) "started [$@]"
SCRLOG=/tmp/$(basename $0).log
touch $SCRLOG
echo "START_$(basename $0) started [$@]" >> $SCRLOG
if [ $1 = "/dev/sda3" ]
then
/sbin/swapon /dev/sda3 >> $SCRLOG
wait
fi
if [ $1 = "/dev/sda1" ]
then

fi
if [ "$?" -ne 0 ]
then
echo "Error in pre-mount execution! Script: $0" >> $SCRLOG
#exit $?
else
echo "Pre-mount execution OK. Script: $0" >> $SCRLOG
#exit 0
fi
/usr/bin/logger -t STOP_$(basename $0) "return code $?"
exit $?

Hello all need good swap mount script at boot.I think this maybe wrong.This script placed in /jffs/scripts Because rt-n16 sometimes himself reboots.I have 1TB hdd.It is fdisk -l
/dev/sda1 * 1 121324 974530560 7 HPFS/NTFS
/dev/sda2 121324 121585 2097152 83 Linux
/dev/sda3 121585 121602 133120 82 Linux swap

sda1 ntfs,sda2 ext3,sda3 swap very please help.
 
Hello all need good swap mount script at boot.I think this maybe wrong.This script placed in /jffs/scripts Because rt-n16 sometimes himself reboots.I have 1TB hdd.It is fdisk -l
/dev/sda1 * 1 121324 974530560 7 HPFS/NTFS
/dev/sda2 121324 121585 2097152 83 Linux
/dev/sda3 121585 121602 133120 82 Linux swap

sda1 ntfs,sda2 ext3,sda3 swap very please help.
Hi,

The script looks good (should be named pre-mount and put into the /jffs/scripts folder).

But the partitions are a little bit odd: I would always put the swap partion as first onto the drive. This is for performance reasons as in your case the drive need to seek to the end of the disk to read/write the swap! :rolleyes:

With kind regards
Joe :cool:
 
Hi,

The script looks good (should be named pre-mount and put into the /jffs/scripts folder).

But the partitions are a little bit odd: I would always put the swap partion as first onto the drive. This is for performance reasons as in your case the drive need to seek to the end of the disk to read/write the swap! :rolleyes:

With kind regards
Joe :cool:

Ok thanks i try format swap partition to /dev/sda1
 
I use internal SD card for swap space and also have two usb drives attached to the router. The SD card is currently formated as sda1. If I reboot the router will it remain sda1 or do I need to add a line to this script defining drives to load with certain partition names?
 
i suspect your best bet will be to mount the swap partition by it's UUID. in the past, i used a line like thus in /jffs/scripts/post-mount

swapon UUID="6c04959b-4417-4285-b727-44c7a135e15a"

you can find the UUID with the 'blkid' command. that said, if your other partitions are labelled, it may retain /dev/sda1
 
Thanks but not working.My swap partition is /dev/sda2 Post edit now working i change to this
if [ $1 = "/dev/sda2" ]
then
/sbin/swapon /dev/sda2 >> $SCRLOG
wait
fi
if [ $1 = "/dev/sda1" ]

I am also having problems making the script work. My swap partition is /dev/sda1 No matter what I do I cannot make the swap to be set upon reboot.

admin@AHWNR:/tmp/home/root# free
total used free shared buffers
Mem: 239712 137684 102028 0 93916
-/+ buffers: 43768 195944
Swap: 0 0 0



admin@AHWNR:/tmp/home/root# fdisk -l

Disk /dev/sdb: 2000.3 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 243202 1953513559+ 7 HPFS/NTFS

Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdc1 1 121602 976759808 7 HPFS/NTFS

Disk /dev/sda: 31.9 GB, 31914983424 bytes
64 heads, 32 sectors/track, 30436 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 30436 31166448 83 Linux

I guess the swap partition is not mounting?

admin@AHWNR:/tmp/home/root# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 24.5M 24.5M 0 100% /
tmpfs 117.0M 2.2M 114.8M 2% /tmp
devfs 117.0M 0 117.0M 0% /dev
/dev/mtdblock4 5.5M 392.0K 5.1M 7% /jffs
/dev/sdb1 931.5G 247.6G 683.9G 27% /tmp/mnt/BACKUP
/dev/sdc1 1.8T 335.0G 1.5T 18% /tmp/mnt/MEDIA
admin@AHWNR:/tmp/home/root#
 
Last edited:
i suspect your best bet will be to mount the swap partition by it's UUID. in the past, i used a line like thus in /jffs/scripts/post-mount

swapon UUID="6c04959b-4417-4285-b727-44c7a135e15a"

you can find the UUID with the 'blkid' command. that said, if your other partitions are labelled, it may retain /dev/sda1

Could you please share your post-mount script? is this the only line you have in it?
 
I am also having problems making the script work. My swap partition is /dev/sda1 No matter what I do I cannot make the swap to be set upon reboot.

admin@AHWNR:/tmp/home/root# free
total used free shared buffers
Mem: 239712 137684 102028 0 93916
-/+ buffers: 43768 195944
Swap: 0 0 0



admin@AHWNR:/tmp/home/root# fdisk -l

Disk /dev/sda: 31.9 GB, 31914983424 bytes
64 heads, 32 sectors/track, 30436 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 30436 31166448 83 Linux
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 121602 976759808 7 HPFS/NTFS

Disk /dev/sdc: 2000.3 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdc1 * 1 243

I guess the swap partition is not mounting?

admin@AHWNR:/tmp/home/root# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 24.5M 24.5M 0 100% /
tmpfs 117.0M 2.2M 114.8M 2% /tmp
devfs 117.0M 0 117.0M 0% /dev
/dev/mtdblock4 5.5M 392.0K 5.1M 7% /jffs
/dev/sdb1 931.5G 247.6G 683.9G 27% /tmp/mnt/BACKUP
/dev/sdc1 1.8T 335.0G 1.5T 18% /tmp/mnt/MEDIA
admin@AHWNR:/tmp/home/root#

here is what my pre-mount script looks like. I also made sure it had proper permissions with chmod a+x


#!/bin/sh
/usr/bin/logger -t START_$(basename $0) "started [$@]"
SCRLOG=/tmp/$(basename $0).log
touch $SCRLOG
echo "START_$(basename $0) started [$@]" >> $SCRLOG
if [ $1 = "/dev/sda1" ]
then
/sbin/swapon /dev/sda1 >> $SCRLOG
wait
fi
if [ $1 = "/dev/sda2" ]
then

fi
if [ "$?" -ne 0 ]
then
echo "Error in pre-mount execution! Script: $0" >> $SCRLOG
#exit $?
else
echo "Pre-mount execution OK. Script: $0" >> $SCRLOG
#exit 0
fi
/usr/bin/logger -t STOP_$(basename $0) "return code $?"
exit $?admin@AHWNR:/jffs/scripts#


mount output:

exit $?admin@AHWNR:/jffs/scripts# mount
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro)
proc on /proc type proc (rw)
tmpfs on /tmp type tmpfs (rw)
devfs on /dev type tmpfs (rw,noatime)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw)
/dev/mtdblock4 on /jffs type jffs2 (rw,noatime)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/sdb1 on /tmp/mnt/MEDIA type ufsd (rw,nodev,noatime,nls=utf8,fmask=0,dmask=0,sparse,force)
/dev/sdc1 on /tmp/mnt/BACKUP type ufsd (rw,nodev,noatime,nls=utf8,fmask=0,dmask=0,sparse,force)

ls -l on /jffs/scripts

drwxr-xr-x 2 admin root 0 Dec 31 2010 configs
drwxr-xr-x 2 admin root 0 Jul 16 14:57 scripts
 
Last edited:

Latest 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