[Buildroot] [git commit] package/skeleton-init-sysv: conditionally enable swapon/swapoff in inittab

Peter Korsgaard peter at korsgaard.com
Sat Feb 8 19:17:57 UTC 2020

commit: https://git.buildroot.net/buildroot/commit/?id=fbe18eb246375af9d8c9421045ba315573049c43
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

The default inittab files added by busybox and sysvinit runs 'swapon -a'
during init and 'swapoff -a' during shutdown, but those programs are not
guaranteed to be available, so the boot log may become polluted by error
messages like this:

    swapon: not found

Add a target-finalize hook to skeleton-init-sysv that enables or disables
the swapon/swapoff lines in /etc/inittab, depending on the existence of

Based on a previous patch sent by Thomas De Schampheleire.

Signed-off-by: Carlos Santos <unixmania at gmail.com>
Signed-off-by: Peter Korsgaard <peter at korsgaard.com>
 package/skeleton-init-sysv/skeleton-init-sysv.mk | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/package/skeleton-init-sysv/skeleton-init-sysv.mk b/package/skeleton-init-sysv/skeleton-init-sysv.mk
index c89c2dc1fd..009dc100ea 100644
--- a/package/skeleton-init-sysv/skeleton-init-sysv.mk
+++ b/package/skeleton-init-sysv/skeleton-init-sysv.mk
+# enable/disable swapon/off calls depending on availability of the commands
+	if [ -x $(TARGET_DIR)/sbin/swapon -a -x $(TARGET_DIR)/sbin/swapoff ]; then \
+		$(SED) '/^#.*\/sbin\/swap/s/^#\+[[:blank:]]*//' $(TARGET_DIR)/etc/inittab; \
+	else \
+		$(SED) '/^[^#].*\/sbin\/swap/s/^/#/' $(TARGET_DIR)/etc/inittab; \
+	fi
 $(eval $(generic-package))

More information about the buildroot mailing list