What's new

Entware-ARM swap file problem

  • 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!

knubbze

Occasional Visitor
I'm running AsusWRT-Merlin on an RT-AC68P, and have installed Entware-ARM, using the integrated 'entware-setup.sh' script, and then setting up a swap file, as advised in this tutorial.

But but there appears to be a problem with the swap file getting mounted twice(?):

When I run the 'free' command shortly after boot, it reports the correct size of the swap file allocation (512MB, as specified in the tutorial):

Code:
adm@router:/tmp/home/root# free
total used free shared buffers
Mem: 255740 48884 206856 0 876
-/+ buffers: 48008 207732
Swap: 524284 0 524284

But, if I wait a while longer, and type 'free' again, it now says the swap memory is double what it should be:

Code:
adm@router:/tmp/home/root# free
total used free shared buffers
Mem: 255740 50576 205164 0 1180
-/+ buffers: 49396 206344
Swap: 1048568 0 1048568

The web GUI also reports the swap size as 1024MB:

ws5dt90.png


It then stays at 1048568 until a reboot. Is this an error, and if so, what is going wrong? I figured maybe /jffs/scripts/post-mount was being run twice at startup, perhaps?
 
Last edited:
Upon further investigation, it looks like the mountpoint of my ext4 USB drive which I installed Entware onto changes following boot-up.

If I type 'mount' shortly after the router boots, it reports:

/dev/sdb1 on /tmp/mnt/16GB type ext4 (rw,nodev,relatime,barrier=1,data=ordered)

At this point, the 'free' command reports 512MB of swap space. After waiting a minute or two, then trying the 'mount' command again, I get the following:

/dev/sda1 on /tmp/mnt/16GB type ext4 (rw,nodev,relatime,barrier=1,data=ordered)

And 'free' now reports 1024MB of swap.

Does anyone know why this is happening?
 
Move the swapon command to services-start script.

Sent from my Nexus 5 using Tapatalk
 
I also recommend assigning a label to your disk using "tune2fs -L". Asuswrt will then create a mountpoint using that label instead of the device name, which can change whenever you add/remove USB devices.
 
Type blkid to show the device UUIDs, then specify those UUIDs in your fstab and services-start. Also need to create the mount points for fstab in your init-start.

/jffs/scripts/init-start
Code:
#!/bin/sh

# create mount points for fstab
mkdir -p /tmp/mnt/16GB

/jffs/configs/fstab
Code:
UUID=11111111-2222-3333-4444-555555555555        /tmp/mnt/16GB   ext4    rw,nodev,noatime        0       0

/jffs/scripts/services-start
Code:
#!/bin/sh

# enable swapping to disk
/sbin/swapon UUID="66666666-7777-8888-9999-aaaaaaaaaaaa"
 
Type blkid to show the device UUIDs, then specify those UUIDs in your fstab and services-start. Also need to create the mount points for fstab in your init-start.

/jffs/scripts/init-start
Code:
#!/bin/sh

# create mount points for fstab
mkdir -p /tmp/mnt/16GB

/jffs/configs/fstab
Code:
UUID=11111111-2222-3333-4444-555555555555        /tmp/mnt/16GB   ext4    rw,nodev,noatime        0       0

/jffs/scripts/services-start
Code:
#!/bin/sh

# enable swapping to disk
/sbin/swapon UUID="66666666-7777-8888-9999-aaaaaaaaaaaa"

Thanks for the help. Unfortunately, after doing the above, I now have no swap allocated...
 
I also recommend assigning a label to your disk using "tune2fs -L". Asuswrt will then create a mountpoint using that label instead of the device name, which can change whenever you add/remove USB devices.

I already labelled the disk (/tmp/mnt/16GB).
 
Thanks for the help. Unfortunately, after doing the above, I now have no swap allocated...
Be sure you replace my fake UUIDs with your real UUIDs from blkid. These configs are taken from my RT-AC68U with the latest Asuswrt-Merlin.

What does the 'blkid' command show? You should see your ext4 and swap partitions with device UUIDs?
 
Be sure you replace my fake UUIDs with your real UUIDs from blkid. These configs are taken from my RT-AC68U with the latest Asuswrt-Merlin.

What does the 'blkid' command show? You should see your ext4 and swap partitions with device UUIDs?

I did replace the fake UUIDs with the real ones from the 'blkid' command, which are as follows:
Code:
/dev/sdc1: LABEL="2TB" UUID="9AE0F011E0EFF185"
/dev/sda1: LABEL="16GB" UUID="6e8d8755-129b-4dba-b280-bf3fc594f3b3"

The '2TB' drive is a separate external drive which I intend to use to store media and download torrents onto. The '16GB' drive is the device which I have installed Entware-ARM and the swap file onto.

I noticed that you mention a swap partition - I am using a swap file (as suggested in the tutorial that I linked in the first post) - would this be a problem?
 
Try a delay loop before enabling the swap file. The /opt partition might not be accessible at this point in the boot process. Examples:

/jffs/scripts/services-start
Code:
#!/bin/sh

# Wait up to 60 seconds to make sure /opt partition is mounted
tmax=60
i=0
while [ $i -le $tmax ]
do
    if [ -d /opt/tmp ]
    then
        break
    fi
    sleep 1
    i=`expr $i + 1`
done

# enable swapping to disk
/sbin/swapon /opt/swap

/jffs/scripts/init-start
Code:
#!/bin/sh

# create mount points for fstab
mkdir -p /tmp/mnt/2TB
mkdir -p /tmp/mnt/16GB

/jffs/configs/fstab
Code:
UUID=9AE0F011E0EFF185        /tmp/mnt/2TB   ext4    rw,nodev,noatime        0       0
UUID=6e8d8755-129b-4dba-b280-bf3fc594f3b3        /tmp/mnt/16GB   ext4    rw,nodev,noatime        0       0
 
Last edited:
Try a delay loop before enabling the swap file. The /opt partition might not be accessible at this point in the boot process. Examples:

/jffs/scripts/services-start
Code:
#!/bin/sh

# Wait up to 60 seconds to make sure /opt partition is mounted
tmax=60
i=0
while [ $i -le $tmax ]
do
    if [ -d /opt/tmp ]
    then
        break
    fi
    sleep 1
    i=`expr $i + 1`
done

# enable swapping to disk
/sbin/swapon /opt/swap

/jffs/scripts/init-start
Code:
#!/bin/sh

# create mount points for fstab
mkdir -p /tmp/mnt/2TB
mkdir -p /tmp/mnt/16GB

/jffs/configs/fstab
Code:
UUID=9AE0F011E0EFF185        /tmp/mnt/2TB   ext4    rw,nodev,noatime        0       0
UUID=6e8d8755-129b-4dba-b280-bf3fc594f3b3        /tmp/mnt/16GB   ext4    rw,nodev,noatime        0       0

Thanks! I will try this. Just one question: The Entware installation script creates a services-start script, the contents of which are as follows:
Code:
#!/bin/sh
script="/opt/etc/init.d/rc.unslung"

i=60
until [ -x "" ]
do
        i=1
        if [ "2" -lt 1 ]
        then
                logger "Could not start Entware"
                exit
        fi
        sleep 1
done
start

So shall I append your code to the bottom of this, after the 'start'?
 
Also, what is the purpose of the fstab mount points? Just wondering, so that I know what I'm doing here. Thanks again.
 
So I edited the scripts as suggested, but still no swap is allocated. I even tried reformatting the USB drive as ext2 and setting everything up again, but then I decided to look in the syslog and saw some I/O errors:

http://pastebin.com/uKPvN6v9

This is occuring immediately after formatting the USB drive and rebooting. The USB drive is not faulty - I have checked it with h2testw and there were no errors. Similarly, e2fsck reports no errors:
Code:
adm@router:/tmp/home/root# e2fsck -fv /dev/sda1
e2fsck 1.42.8 (20-Jun-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

          21 inodes used (0.00%, out of 977280)
           0 non-contiguous files (0.0%)
           0 non-contiguous directories (0.0%)
             # of inodes with ind/dind/tind blocks: 0/0/0
       70881 blocks used (1.81%, out of 3907328)
           0 bad blocks
           1 large file

          10 regular files
           2 directories
           0 character device files
           0 block device files
           0 fifos
           0 links
           0 symbolic links (0 fast symbolic links)
           0 sockets
------------
          12 files
 
What does your /etc/fstab file look like? It was created automatically by the firmware at boot time. The firmware does a good job of auto-detecting this information. Use this file as a starting point to create your own /jffs/configs/fstab.

A Linux Swap partition is probably a good idea too. Since you're already re-formatting the disks anyway, you may as well create a Linux Swap partition on your fastest fixed disk. Then you can ignore that section in the tutorial on creating a swap file.

Your custom fstab file, /jffs/configs/fstab, will get copied automatically by the firmware to /etc/fstab at boot time. It will be used by the 'mount' command for mounting and un-mounting partitions. This allows you to fine tune the mounting options. And you can specify the unique device UUIDs of the disk partitions instead of using the OS assigned device paths /dev/sdX. You tell the firmware specifically which partitions to mount and exactly how to mount them, so it won't try to guess every time.
 
What is the best solution, swap partition or swap file? Is necessary install optware or entware to activate swap partition or swap file?
If i update the firmware on the router, i have to reconfigure the swap partition or the swap file and i have to reinstall optware or entware?
 
What does your /etc/fstab file look like? It was created automatically by the firmware at boot time. The firmware does a good job of auto-detecting this information. Use this file as a starting point to create your own /jffs/configs/fstab.

My /etc/fstab is an empty, 0-byte file - should it not be?:
Code:
-rw-r--r--    1 adm      root             0 Jan  1  1970 fstab
 
What is the best solution, swap partition or swap file? Is necessary install optware or entware to activate swap partition or swap file?
If i update the firmware on the router, i have to reconfigure the swap partition or the swap file and i have to reinstall optware or entware?
A swap partition is better.
 
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!
Top