OpenWrt Forum Archive

Topic: OpenWrt and swap partition

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

Hello,

i have a simple question. Does OpenWrt use the swap function from Linux on default or is it disabled?
I need to put OpenWrt as read-only but if there is a swap function i need to disable it. So my question is just if there is a swap function on OpenWrt and if yes how to disable it.

I use Openwrt DD-r48151 with some compiled programs on an Raspberry Pi B+.

Thanks in advance

Patrick

No, swap is not used by default; it would destroy the flash in the device. To be sure, just execute "free" to see if there is any swap available, or "cat /proc/swaps" to see which files or devices are being used as swap.

If you need to put OpenWRT into read only mode, why would you need to disable swap if it was enabled?

Since swap doesn't hold any data over a boot loop cycle I fail to see why disabling swap is any better than starting with fresh swap space after each reboot.

What are you trying to do?

Well in my understanding swap is used when the ram memory is on it´s limit. So the system saves some space on the flash memory as safety. So with this swap space it is possible to write on my flash memory wich i try to prevent.
Tell me if im wrong but swap uses flash memory as ram so it writes if possible in this space an delete it on startup so this action causes writings on my flash memory. Because sawp is like you said established on Startup it bypass my read-only function and still wirtes on my memory.

But i think there is no swap used on OpenWrt on Default because if i type

free -m 

there is a 0 on the swap entry so i guess there is no swap space allocated

Taulin wrote:

Well in my understanding swap is used when the ram memory is on it´s limit. So the system saves some space on the flash memory as safety. So with this swap space it is possible to write on my flash memory wich i try to prevent.
Tell me if im wrong but swap uses flash memory as ram so it writes if possible in this space an delete it on startup so this action causes writings on my flash memory. Because sawp is like you said established on Startup it bypass my read-only function and still wirtes on my memory.

But i think there is no swap used on OpenWrt on Default because if i type

free -m 

there is a 0 on the swap entry so i guess there is no swap space allocated

Your understanding correct.

Taulin wrote:

So with this swap space it is possible to write on my flash memory wich i try to prevent.

Ah, so you basically want to avoid any write operations in order to prevent damage on your flash memory. That's the exact reason why swap is disabled by default and no logging is persisted. There's close to no write operation going on.

I had the impression you were trying to prevent anybody from adjust your routers configuration and thus want your flash memory to not accept write calls.

The discussion might have continued from here.