OpenWrt Forum Archive

Topic: enabling a swap file in /etc/config/fstab

The content of this topic has been archived on 30 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I can't seem to enable a swap file in /etc/config/fstab:

  config swap
      option device   /mnt/usbdrive/swapfile
      option enabled  1

If I manually enable swap with "swapon /mnt/usbdrive/swapfile" I get my swap space. But I can't get it to autoenable with /etc/config/fstab.

--Dan

(Last edited by DanSF on 18 Sep 2008, 23:51)

Set

option enabled 0

to

option enabled 1

~ JoW

Thanks, but I tried both values without success. I edited my original post to reflect the value that /etc/init.d/fstab expects.

--Dan

No idea if the fstab implementation supports a swapfile. It's working with a swap partition fine here.

I've formatted a USB pen drive with a swap partition and then created the swap space with:

# opkg install swap-utils
# mkswap /dev/sda2

Now the swap partition is prepared for usage. Time to configure /etc/config/swap using UCI CLI:

# uci set fstab.swap@[-1].device=/dev/sda2
# uci set fstab.swap@[-1].enabled=1
# uci commit fstab
# /etc/init.d/fstab restart

This works with latest trunk and a swap partion.

For usage with a swap file do:

# opkg install swap-utils
# dd if=/dev/zero of=/swapfile bs=1024 count=65536   # Create a 64MB swap file at /swapfile
# mkswap /swapfile
# uci set fstab.@swap[-1].device=/swapfile
# uci set fstab.@swap[-1].enabled=1
# uci commit fstab
# /etc/init.d/fstab restart

Using a swap file instead of a partion does not work for me. The Kernel just segfaults sad

root@OpenWrt:/# swapon /swapfile 
<1>BUG: unable to handle kernel NULL pointer dereference at 00000000
IP: [<c0276d0a>] __down+0x4e/0xd4
*pde = 00000000 
Oops: 0002 [#1] SMP 
Modules linked in: usb_storage via_rhine ehci_hcd uhci_hcd ohci_hcd ath_pci wlan_xauth wlan_wep wlan_tkip wlan_ccmp wlan_acl ath_rate_minstrel ath_hal(P) wlan_scan_sta wlan_scan_ap wlan leds_alix sata_via sd_mod nf_nat_tftp nf_conntrack_tftp nf_nat_irc nf_conntrack_irc nf_nat_ftp nf_conntrack_ftp ipt_TTL xt_MARK ipt_ECN xt_CLASSIFY ipt_ttl xt_time ipt_time xt_tcpmss xt_statistic xt_mark xt_mac xt_length ipt_ecn xt_DSCP xt_dscp ipt_IMQ xt_string xt_layer7 ipt_ipp2p ipt_LOG xt_CHAOS xt_DELUDE xt_TARPIT xt_quota xt_portscan xt_pkttype iptable_raw xt_NOTRACK xt_CONNMARK ipt_recent xt_helper xt_conntrack xt_connmark xt_connbytes aec62xx ext3 jbd nls_utf8 nls_iso8859_15 libata usbcore scsi_mod nls_base

Pid: 1377, comm: swapon Tainted: P         (2.6.25.16 #1)
EIP: 0060:[<c0276d0a>] EFLAGS: 00010002 CPU: 0
EIP is at __down+0x4e/0xd4
EAX: cfb589cc EBX: cfb589c0 ECX: 00000000 EDX: cd86fef4
ESI: 00000246 EDI: cfb589c8 EBP: ce61d490 ESP: cd86fee8
 DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
Process swapon (pid: 1377, ti=cd86e000 task=ce61d490 task.ti=cd86e000)
Stack: 00000001 ce61d490 c011568e cfb589cc 00000000 cfb589c0 00000000 cfb58a98 
       00000000 c0276b6b 000000d0 c11af160 c01977ee c11af160 c0139645 c01977d9 
       cfb58a98 cfb589f0 00000001 cd86e000 c013aeef cfc1c520 cfb58a98 c014bdc2 
Call Trace:
 [<c011568e>] default_wake_function+0x0/0x8
 [<c0276b6b>] __down_failed+0x7/0xc
 [<c01977ee>] jffs2_readpage+0x15/0x31
 [<c0139645>] read_cache_page_async+0x95/0x11d
 [<c01977d9>] jffs2_readpage+0x0/0x31
 [<c013aeef>] read_cache_page+0xa/0x3f
 [<c014bdc2>] sys_swapon+0x2bc/0x898
 [<c01120ed>] do_page_fault+0x202/0x549
 [<c0103c22>] syscall_call+0x7/0xb
 =======================
Code: c0 ab ab 8d 7b 08 c7 45 00 02 00 00 00 89 f8 e8 6a 01 00 00 83 0c 24 01 89 c6 8d 43 0c 8b 48 04 8d 54 24 0c 89 50 04 89 44 24 0c <89> 11 ff 43 04 89 4c 24 10 8b 43 04 48 90 01 03 0f 98 c0 84 c0 
EIP: [<c0276d0a>] __down+0x4e/0xd4 SS:ESP 0068:cd86fee8
---[ end trace c4bb807da6c9f357 ]---
Segmentation fault

EDIT: Hmm, interesting. Moving the swap file from my CF card from inside the ALIX.2C2 to a USB pen drive connected on the ALIX the swap file just works fine smile

(Last edited by Yanira on 19 Sep 2008, 10:33)

The discussion might have continued from here.