Skip to contentSkip to conversation

A better solution for the swapon/swapoff issue in inittag

PATCH New unixmania at gmail.com 2 participants 5 messages Feb 7, 2020 – Feb 8, 2020

lore
Share & tools
lore
#0 lore raw

v2 cover A better solution for the swapon/swapoff issue in inittag

From: Carlos Santos <[email protected]>

The current solution adds target-finalize hooks to two packages and defines the hook in system/system.mk. The hook code is more complex than it needs to be.

This solution adds the hook to skeleton-init-sysv, only, and uses a simpler logic.
---
CC: Thomas De Schampheleire <[email protected]>
CC: Peter Korsgaard <[email protected]>
---

Carlos Santos (2):
Revert "system: don't attempt swapon/swapoff in inittab if not
available"
package/skeleton-init-sysv: conditionally enable swapon/swapoff in
inittab

 package/busybox/busybox.mk                       |  1 -
 package/skeleton-init-sysv/skeleton-init-sysv.mk | 10 ++++++++++
 package/sysvinit/sysvinit.mk                     |  1 -
 system/system.mk                                 | 13 -------------
 4 files changed, 10 insertions(+), 15 deletions(-)
Signature · 1 line
2.18.2
#1 lore raw

PATCH v2 1/2 Revert "system: don't attempt swapon/swapoff in inittab if not available"

From: Carlos Santos <[email protected]>

This reverts commit c4dce0ae0f5d5d7fecb6f493e974e131a6df43da.

A different fix will be provided in a forthcoming patch.
---
CC: Thomas De Schampheleire <[email protected]>
CC: Peter Korsgaard <[email protected]>

---
 package/busybox/busybox.mk   |  1 -
 package/sysvinit/sysvinit.mk |  1 -
 system/system.mk             | 13 -------------
 3 files changed, 15 deletions(-)
package/busybox/busybox.mk +0 -1
index 45f74271f2..6283bc96ea 100644
@@ -226,7 +226,6 @@ endif # BR2_TARGET_GENERIC_GETTY
 BUSYBOX_TARGET_FINALIZE_HOOKS += BUSYBOX_SET_GETTY
 
 BUSYBOX_TARGET_FINALIZE_HOOKS += SYSTEM_REMOUNT_ROOT_INITTAB
-BUSYBOX_TARGET_FINALIZE_HOOKS += SYSTEM_UPDATE_SWAPON_SWAPOFF_INITTAB
 
 endif # BR2_INIT_BUSYBOX
 
package/sysvinit/sysvinit.mk +0 -1
index a717ae0459..c778a9cde5 100644
@@ -45,6 +45,5 @@ endif # BR2_TARGET_GENERIC_GETTY
 SYSVINIT_TARGET_FINALIZE_HOOKS += SYSVINIT_SET_GETTY
 
 SYSVINIT_TARGET_FINALIZE_HOOKS += SYSTEM_REMOUNT_ROOT_INITTAB
-SYSVINIT_TARGET_FINALIZE_HOOKS += SYSTEM_UPDATE_SWAPON_SWAPOFF_INITTAB
 
 $(eval $(generic-package))
system/system.mk +0 -13
index 6f1f5c27b1..8fe2c138b0 100644
@@ -96,19 +96,6 @@ define SYSTEM_REMOUNT_ROOT_INITTAB
 endef
 endif
 
-define SYSTEM_UPDATE_SWAPON_SWAPOFF_INITTAB
-	if [ -x $(TARGET_DIR)/sbin/swapon ]; then \
-		$(SED) '\%:/sbin/swapon%s/^#*//' $(TARGET_DIR)/etc/inittab ; \
-	else \
-		$(SED) '\%:/sbin/swapon%s/^#*/#/' $(TARGET_DIR)/etc/inittab ; \
-	fi
-	if [ -x $(TARGET_DIR)/sbin/swapoff ]; then \
-		$(SED) '\%:/sbin/swapoff%s/^#*//' $(TARGET_DIR)/etc/inittab ; \
-	else \
-		$(SED) '\%:/sbin/swapoff%s/^#*/#/' $(TARGET_DIR)/etc/inittab ; \
-	fi
-endef
-
 ifeq ($(BR_BUILDING)$(BR2_SYSTEM_DEFAULT_PATH),y"")
 $(error BR2_SYSTEM_DEFAULT_PATH can't be empty)
 endif
Signature · 1 line
2.18.2
#2 lore raw

PATCH v2 1/2 Revert "system: don't attempt swapon/swapoff in inittab if not available"

Quoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"unixmania" == unixmania <[email protected]> writes:

From: Carlos Santos <[email protected]>
This reverts commit c4dce0ae0f5d5d7fecb6f493e974e131a6df43da.

A different fix will be provided in a forthcoming patch.
---
CC: Thomas De Schampheleire <[email protected]>
CC: Peter Korsgaard <[email protected]>

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH v2 2/2 package/skeleton-init-sysv: conditionally enable swapon/swapoff in inittab

In reply to unixmania at gmail.com

From: Carlos Santos <[email protected]>

The default inittab files added by busybox and sysvinit run '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 targe-finalize to skeleton-init-sysv that enables or disables the swapon/swapoff lines in /etc/inittab, depending on the existence of $(TARGET_DIR)/sbin/swap{on,off}.

Based on a previous patch sent by Thomas De Schampheleire.

---
CC: Thomas De Schampheleire <[email protected]>
CC: Peter Korsgaard <[email protected]>

---
 package/skeleton-init-sysv/skeleton-init-sysv.mk | 10 ++++++++++
 1 file changed, 10 insertions(+)
package/skeleton-init-sysv/skeleton-init-sysv.mk +10 -0
index c89c2dc1fd..6c9c2e80fb 100644
@@ -19,4 +19,14 @@ define SKELETON_INIT_SYSV_INSTALL_TARGET_CMDS
 	$(call SYSTEM_RSYNC,$(SKELETON_INIT_SYSV_PKGDIR)/skeleton,$(TARGET_DIR))
 endef
 
+define SKELETON_INIT_SYSV_SWAPON_SWAPOFF_INITTAB
+	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
+endef
+
+SKELETON_INIT_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_INIT_SYSV_SWAPON_SWAPOFF_INITTAB
+
 $(eval $(generic-package))
Signature · 1 line
2.18.2
#4 lore raw

PATCH v2 2/2 package/skeleton-init-sysv: conditionally enable swapon/swapoff in inittab

Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"unixmania" == unixmania <[email protected]> writes:

From: Carlos Santos <[email protected]>
The default inittab files added by busybox and sysvinit run '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 targe-finalize to skeleton-init-sysv that enables or disables the

target-finalize hook

Quoted 18 lines

swapon/swapoff lines in /etc/inittab, depending on the existence of $(TARGET_DIR)/sbin/swap{on,off}.

Based on a previous patch sent by Thomas De Schampheleire.

---
CC: Thomas De Schampheleire <[email protected]>
CC: Peter Korsgaard <[email protected]>

---
 package/skeleton-init-sysv/skeleton-init-sysv.mk | 10 ++++++++++
 1 file changed, 10 insertions(+)
package/skeleton-init-sysv/skeleton-init-sysv.mk +0 -0
index c89c2dc1fd..6c9c2e80fb 100644

package/skeleton-init-sysv/skeleton-init-sysv.mk define SKELETON_INIT_SYSV_INSTALL_TARGET_CMDS · line 22

Quoted 4 lines
package/skeleton-init-sysv/skeleton-init-sysv.mk +1 -0
@@ -19,4 +19,14 @@ define SKELETON_INIT_SYSV_INSTALL_TARGET_CMDS
 	$(call SYSTEM_RSYNC,$(SKELETON_INIT_SYSV_PKGDIR)/skeleton,$(TARGET_DIR))
 endef
 
+define SKELETON_INIT_SYSV_SWAPON_SWAPOFF_INITTAB

I added a comment explaining what / why this is done and committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard