diff mbox series

[2/5] package/petitboot: run pb-console at boot

Message ID 20230906194609.74080-3-arbab@linux.ibm.com
State Superseded
Headers show
Series package/petitboot: misc enhancement | expand

Commit Message

Reza Arbab Sept. 6, 2023, 7:46 p.m. UTC
Install a udev rule to run the petitboot UI on commonly-known consoles.
To prevent the kernel's console output from trampling the UI, also add
a sysctl file to reduce the kernel log levels to KERN_ALERT.

Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
---
 package/petitboot/petitboot-console-ui.rules | 4 ++++
 package/petitboot/petitboot.mk               | 4 ++++
 package/petitboot/sysctl.conf                | 1 +
 3 files changed, 9 insertions(+)
 create mode 100644 package/petitboot/petitboot-console-ui.rules
 create mode 100644 package/petitboot/sysctl.conf

Comments

Laurent Vivier Sept. 7, 2023, 8:51 a.m. UTC | #1
Le 06/09/2023 à 21:46, Reza Arbab a écrit :
> Install a udev rule to run the petitboot UI on commonly-known consoles.
> To prevent the kernel's console output from trampling the UI, also add
> a sysctl file to reduce the kernel log levels to KERN_ALERT.
> 
> Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
> ---
>   package/petitboot/petitboot-console-ui.rules | 4 ++++
>   package/petitboot/petitboot.mk               | 4 ++++
>   package/petitboot/sysctl.conf                | 1 +
>   3 files changed, 9 insertions(+)
>   create mode 100644 package/petitboot/petitboot-console-ui.rules
>   create mode 100644 package/petitboot/sysctl.conf
> 
> diff --git a/package/petitboot/petitboot-console-ui.rules b/package/petitboot/petitboot-console-ui.rules
> new file mode 100644
> index 000000000000..de3b4b1c035f
> --- /dev/null
> +++ b/package/petitboot/petitboot-console-ui.rules
> @@ -0,0 +1,4 @@
> +# spawn a petitboot UI on common user-visible interface devices
> +SUBSYSTEM=="tty", KERNEL=="hvc*", RUN+="/usr/libexec/petitboot/pb-console --getty --detach -- -n -i 0 $name linux"
> +SUBSYSTEM=="tty", KERNEL=="tty0", RUN+="/usr/libexec/petitboot/pb-console --getty --detach -- -n -i 0 $name linux"
> +SUBSYSTEM=="tty", KERNEL=="ttyS*", RUN+="/usr/libexec/petitboot/pb-console --getty --detach -- -n -i 0 $name linux"
> diff --git a/package/petitboot/petitboot.mk b/package/petitboot/petitboot.mk

Could you add:

SUBSYSTEM=="tty", KERNEL=="ttyGF*", RUN+="/usr/libexec/petitboot/pb-console --getty=/sbin/getty 
--detach -- -n -i $name 0 linux"

It's needed for my work on virt-m68k petitboot.

> index 8d220f88f45a..556d41230237 100644
> --- a/package/petitboot/petitboot.mk
> +++ b/package/petitboot/petitboot.mk
> @@ -55,6 +55,10 @@ define PETITBOOT_POST_INSTALL
>   		$(TARGET_DIR)/etc/petitboot/boot.d/90-sort-dtb
>   	$(INSTALL) -m 0755 -D $(PETITBOOT_PKGDIR)/S15pb-discover \
>   		$(TARGET_DIR)/etc/init.d/S15pb-discover
> +	$(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/petitboot-console-ui.rules \
> +		$(TARGET_DIR)/etc/udev/rules.d/petitboot-console-ui.rules
> +	$(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/sysctl.conf \
> +		$(TARGET_DIR)/etc/sysctl.d/petitboot.conf
>   	mkdir -p $(TARGET_DIR)/usr/share/udhcpc/default.script.d/
>   	ln -sf /usr/sbin/pb-udhcpc \
>   		$(TARGET_DIR)/usr/share/udhcpc/default.script.d/
> diff --git a/package/petitboot/sysctl.conf b/package/petitboot/sysctl.conf
> new file mode 100644
> index 000000000000..02ab8e3275b5
> --- /dev/null
> +++ b/package/petitboot/sysctl.conf
> @@ -0,0 +1 @@
> +kernel.printk = 1 1 1 1

I think you also need:

diff --git a/system/Config.in b/system/Config.in
index 1ca7690ea3ba..786ec9a1c6b3 100644
--- a/system/Config.in
+++ b/system/Config.in
@@ -375,7 +375,7 @@ config BR2_SYSTEM_BIN_SH

  menuconfig BR2_TARGET_GENERIC_GETTY
         bool "Run a getty (login prompt) after boot"
-       default y
+       default y         if !BR2_PACKAGE_PETITBOOT

  if BR2_TARGET_GENERIC_GETTY
  config BR2_TARGET_GENERIC_GETTY_PORT

Otherwise the petitboot prompt will be mixed with getty prompt.

Thanks,
Laurent
Reza Arbab Sept. 7, 2023, 7:41 p.m. UTC | #2
On Thu, Sep 07, 2023 at 10:51:32AM +0200, Laurent Vivier wrote:
>Le 06/09/2023 à 21:46, Reza Arbab a écrit :
>>--- /dev/null
>>+++ b/package/petitboot/petitboot-console-ui.rules
>>@@ -0,0 +1,4 @@
>>+# spawn a petitboot UI on common user-visible interface devices
>>+SUBSYSTEM=="tty", KERNEL=="hvc*", RUN+="/usr/libexec/petitboot/pb-console --getty --detach -- -n -i 0 $name linux"
>>+SUBSYSTEM=="tty", KERNEL=="tty0", RUN+="/usr/libexec/petitboot/pb-console --getty --detach -- -n -i 0 $name linux"
>>+SUBSYSTEM=="tty", KERNEL=="ttyS*", RUN+="/usr/libexec/petitboot/pb-console --getty --detach -- -n -i 0 $name linux"
>>diff --git a/package/petitboot/petitboot.mk b/package/petitboot/petitboot.mk
>
>Could you add:
>
>SUBSYSTEM=="tty", KERNEL=="ttyGF*", RUN+="/usr/libexec/petitboot/pb-console --getty=/sbin/getty --detach -- -n -i $name 0 linux"
>
>It's needed for my work on virt-m68k petitboot.

Sure, no problem.

>I think you also need:
>
>diff --git a/system/Config.in b/system/Config.in
>index 1ca7690ea3ba..786ec9a1c6b3 100644
>--- a/system/Config.in
>+++ b/system/Config.in
>@@ -375,7 +375,7 @@ config BR2_SYSTEM_BIN_SH
>
> menuconfig BR2_TARGET_GENERIC_GETTY
>        bool "Run a getty (login prompt) after boot"
>-       default y
>+       default y         if !BR2_PACKAGE_PETITBOOT
>
> if BR2_TARGET_GENERIC_GETTY
> config BR2_TARGET_GENERIC_GETTY_PORT
>
>Otherwise the petitboot prompt will be mixed with getty prompt.

This makes sense, but oddly, all our configs have

   BR2_TARGET_GENERIC_GETTY=y
   BR2_TARGET_GENERIC_GETTY_PORT="hvc0"

Let me try to figure out why it's never caused problems.
Reza Arbab Sept. 13, 2023, 3:54 p.m. UTC | #3
On Thu, Sep 07, 2023 at 02:41:22PM -0500, Reza Arbab wrote:
>On Thu, Sep 07, 2023 at 10:51:32AM +0200, Laurent Vivier wrote:
>>I think you also need:
>>
>>diff --git a/system/Config.in b/system/Config.in
>>index 1ca7690ea3ba..786ec9a1c6b3 100644
>>--- a/system/Config.in
>>+++ b/system/Config.in
>>@@ -375,7 +375,7 @@ config BR2_SYSTEM_BIN_SH
>>
>>menuconfig BR2_TARGET_GENERIC_GETTY
>>       bool "Run a getty (login prompt) after boot"
>>-       default y
>>+       default y         if !BR2_PACKAGE_PETITBOOT
>>
>>if BR2_TARGET_GENERIC_GETTY
>>config BR2_TARGET_GENERIC_GETTY_PORT
>>
>>Otherwise the petitboot prompt will be mixed with getty prompt.
>
>This makes sense, but oddly, all our configs have
>
>  BR2_TARGET_GENERIC_GETTY=y
>  BR2_TARGET_GENERIC_GETTY_PORT="hvc0"
>
>Let me try to figure out why it's never caused problems.

I found that the reason we've never had problems with this is because 
BR2_TARGET_GENERIC_GETTY operates on the default /etc/inittab, but we 
overwrite that file in our overlay.

So your suggestion seems good to me! I'll add it to v2.
diff mbox series

Patch

diff --git a/package/petitboot/petitboot-console-ui.rules b/package/petitboot/petitboot-console-ui.rules
new file mode 100644
index 000000000000..de3b4b1c035f
--- /dev/null
+++ b/package/petitboot/petitboot-console-ui.rules
@@ -0,0 +1,4 @@ 
+# spawn a petitboot UI on common user-visible interface devices
+SUBSYSTEM=="tty", KERNEL=="hvc*", RUN+="/usr/libexec/petitboot/pb-console --getty --detach -- -n -i 0 $name linux"
+SUBSYSTEM=="tty", KERNEL=="tty0", RUN+="/usr/libexec/petitboot/pb-console --getty --detach -- -n -i 0 $name linux"
+SUBSYSTEM=="tty", KERNEL=="ttyS*", RUN+="/usr/libexec/petitboot/pb-console --getty --detach -- -n -i 0 $name linux"
diff --git a/package/petitboot/petitboot.mk b/package/petitboot/petitboot.mk
index 8d220f88f45a..556d41230237 100644
--- a/package/petitboot/petitboot.mk
+++ b/package/petitboot/petitboot.mk
@@ -55,6 +55,10 @@  define PETITBOOT_POST_INSTALL
 		$(TARGET_DIR)/etc/petitboot/boot.d/90-sort-dtb
 	$(INSTALL) -m 0755 -D $(PETITBOOT_PKGDIR)/S15pb-discover \
 		$(TARGET_DIR)/etc/init.d/S15pb-discover
+	$(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/petitboot-console-ui.rules \
+		$(TARGET_DIR)/etc/udev/rules.d/petitboot-console-ui.rules
+	$(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/sysctl.conf \
+		$(TARGET_DIR)/etc/sysctl.d/petitboot.conf
 	mkdir -p $(TARGET_DIR)/usr/share/udhcpc/default.script.d/
 	ln -sf /usr/sbin/pb-udhcpc \
 		$(TARGET_DIR)/usr/share/udhcpc/default.script.d/
diff --git a/package/petitboot/sysctl.conf b/package/petitboot/sysctl.conf
new file mode 100644
index 000000000000..02ab8e3275b5
--- /dev/null
+++ b/package/petitboot/sysctl.conf
@@ -0,0 +1 @@ 
+kernel.printk = 1 1 1 1