diff mbox series

[3/4] busybox: add an inittab entry to activate swap

Message ID 20180611060016.20755-4-casantos@datacom.com.br
State Accepted
Commit d524cc7d9de549228b998ba5747b0d7cd4f24251
Headers show
Series synchronize initab files and enable swap on startup | expand

Commit Message

Carlos Santos June 11, 2018, 6 a.m. UTC
There is a call to swapoff in the shutdown sequence, so call "swapon -a"
on startup. As stated in the swapon man page,

   All devices marked as "swap" in /etc/fstab are made available, except
   for those with the "noauto" option. Devices that are already being
   used as swap are silently skipped.

So even if the system has some init script to start/stop swap (e.g. from
a rootfs ovelay) calling swapon/swapoff would be harmless.

Signed-off-by: Carlos Santos <casantos@datacom.com.br>
---
 package/busybox/inittab | 1 +
 1 file changed, 1 insertion(+)

Comments

Peter Korsgaard June 12, 2018, 12:58 p.m. UTC | #1
>>>>> "Carlos" == Carlos Santos <casantos@datacom.com.br> writes:

 > There is a call to swapoff in the shutdown sequence, so call "swapon -a"
 > on startup. As stated in the swapon man page,

 >    All devices marked as "swap" in /etc/fstab are made available, except
 >    for those with the "noauto" option. Devices that are already being
 >    used as swap are silently skipped.

 > So even if the system has some init script to start/stop swap (e.g. from
 > a rootfs ovelay) calling swapon/swapoff would be harmless.

I guess an explicit swapon <device> after swapon -a (with an entry for
<device> in /etc/fstab) will fail with an error message, but OK - That
is easy to fix if that happens.

Committed, thanks.
Peter Korsgaard June 17, 2018, 3:54 p.m. UTC | #2
>>>>> "Carlos" == Carlos Santos <casantos@datacom.com.br> writes:

 > There is a call to swapoff in the shutdown sequence, so call "swapon -a"
 > on startup. As stated in the swapon man page,

 >    All devices marked as "swap" in /etc/fstab are made available, except
 >    for those with the "noauto" option. Devices that are already being
 >    used as swap are silently skipped.

 > So even if the system has some init script to start/stop swap (e.g. from
 > a rootfs ovelay) calling swapon/swapoff would be harmless.

 > Signed-off-by: Carlos Santos <casantos@datacom.com.br>

Committed to 2018.02.x, thanks.
diff mbox series

Patch

diff --git a/package/busybox/inittab b/package/busybox/inittab
index 7cd203de0b..ff1725c775 100644
--- a/package/busybox/inittab
+++ b/package/busybox/inittab
@@ -18,6 +18,7 @@ 
 ::sysinit:/bin/mount -o remount,rw /
 ::sysinit:/bin/mkdir -p /dev/pts /dev/shm
 ::sysinit:/bin/mount -a
+::sysinit:/sbin/swapon -a
 null::sysinit:/bin/ln -sf /proc/self/fd /dev/fd
 null::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin
 null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout