MT300A - Micro SD Card Enabling Swap

I’ve formatted a 16GB micro SD and used swapon to enable swap, but as /etc/config/fstab doesn’t exist, where do i set swap to be enabled at boot?

Hi this is not difficult.

Here is the instructions: Fstab Configuration [Old OpenWrt Wiki]

I verified. You can just do:

opkg update
opkg install block-mount 
block detect > /etc/config/fstab
vi /etc/config/fstab
# Please check the option enabled '0' and change all '0' to '1'
/etc/init.d/fstab enable
block mount

And it is done

The issue with installing block-mount and using fstab is that hot plug and mounting of USB block devices stop working. I’ve tried twice now with the same results.

Any suggestions?

 

Yes. This is a problem. This is why we didn’t use block-mount.

The hotplug script is /etc/hotplug.d/block/01-mount

After you install block-mount, the content will be replaced by only one line: block mount

You can modify this script to (suppose you only have up to 2 disks, if you have more, just add more uci command).

But I didn’t try this.

block detect > /etc/config/fstab
uci set fstab.@mount[0].enabled='1'
uci set fstab.@mount[1].enabled='1'
uci set fstab.@swap[0].enabled='1'
uci commit fstab
block mount

For anyone else looking to enable swap. I found the following solution works best as it enables swap at boot and maintains the hotplug mount of usb block devices.

 

  1. Take a copy of /etc/hotplug.d/block/10-mount

  2. Install block-mount package
    opkg update
    opkg install block-mount
    block detect > /etc/config/fstab
    vi /etc/config/fstab

Please check the option enabled ‘0’ and change swap ‘0’ to ‘1’

  1. Copy /etc/hotplug.d/block/10-mount back and reboot.

 

To check swap is enabled, use free. It will show you the free/used space of swap. If under the free heading shows 0, then swap is not enabled.

 

Thanks for sharing.