Message ID | 20250328180456.90413-1-gavrosc@yahoo.com |
---|---|
State | Accepted, archived |
Commit | 0f745024fd40518f98390008b4f613d5641df416 |
Headers | show |
Series | initramfs-framework: remove hard dependency with busybox | expand |
Hi Christos Since the -c has been around for a very long time, I assume that there are many users who use it with busybox. Using it with core-utils will probably remain the special use case. The proposed fix raises the question of why the -c was introduced at some point. If your fix also works for busybox, was the -c always redundant? Or has something changed in the meantime? Please also address the busybox users' point of view in the commit message and summarize how this was tested with busybox in particular. Thank you. Adrian On Fri, 2025-03-28 at 19:04 +0100, Christos Gavros via lists.openembedded.org wrote: > In 'finish'script the Switch_root command with option -c is busybox > specific. > When package-core-base-utils is selected the boot is breaking. > Remove -c option to make it compatible with both providers > Fixes [YOCTO #15716] > > CC: Yoann Congal <yoann.congal@smile.fr> > CC: Randy MacLeod <randy.macleod@windriver.com> > CC: Ross Burton <ross.burton@arm.com> > CC: jbk <jbk@mm-software.com> > Signed-off-by: Christos Gavros <gavrosc@yahoo.com> > --- > meta/recipes-core/initrdscripts/initramfs-framework/finish | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/meta/recipes-core/initrdscripts/initramfs- > framework/finish b/meta/recipes-core/initrdscripts/initramfs- > framework/finish > index ac0de9f996..716c2f44af 100755 > --- a/meta/recipes-core/initrdscripts/initramfs-framework/finish > +++ b/meta/recipes-core/initrdscripts/initramfs-framework/finish > @@ -41,7 +41,7 @@ finish_run() { > mount --move /sys $ROOTFS_DIR/sys > > cd $ROOTFS_DIR > - exec switch_root -c /dev/console $ROOTFS_DIR > ${bootparam_init:-/sbin/init} > + exec switch_root $ROOTFS_DIR ${bootparam_init:- > /sbin/init} > else > debug "No rootfs has been set" > fi > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#213861): > https://lists.openembedded.org/g/openembedded-core/message/213861 > Mute This Topic: https://lists.openembedded.org/mt/111959232/4454582 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: > https://lists.openembedded.org/g/openembedded-core/unsub [ > adrian.freihofer@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- >
hi Adrian thank you for the comment. I had a look in commits log and it looks that '-c' was there since the beginning in 2008/09/10 in script 'init-live.sh' and then moved in 'finish.sh' in 2011/12/08. I reproduced the issue by using qemu and I described how I did it in detail in bug # 15716. After I applied the change I tested both busybox and packagegroup-core-base-utils. The boot was successful in both cases. Also '-c' is an option in busybox: https://www.busybox.net/downloads/BusyBox.html I will wait for more comments and then I will extend the commit message and send a v2. Br Christos
On Sat, Mar 29, 2025 at 9:01 AM Christos Gavros via lists.openembedded.org <gavrosc=yahoo.com@lists.openembedded.org> wrote: > > hi Adrian > > thank you for the comment. I had a look in commits log and it looks that '-c' was there since the beginning in 2008/09/10 in script 'init-live.sh' and then moved in 'finish.sh' in 2011/12/08. > I reproduced the issue by using qemu and I described how I did it in detail in bug #15716. > After I applied the change I tested both busybox and packagegroup-core-base-utils. The boot was successful in both cases. > Also '-c' is an option in busybox: https://www.busybox.net/downloads/BusyBox.html > -c option is to redirect the console after switching root. Some devices it did not work properly because util-linux version moved the pseudo filesystems like /dev automatically but busybox version did not, maybe things have changed but I would suggest that this operation is now happening with both switch_root versions with you script manually doing so. > I will wait for more comments and then I will extend the commit message and send a v2. > > Br > Christos > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#213885): https://lists.openembedded.org/g/openembedded-core/message/213885 > Mute This Topic: https://lists.openembedded.org/mt/111959232/1997914 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- >
On Sat, 2025-03-29 at 09:29 -0700, Khem Raj via lists.openembedded.org wrote: > On Sat, Mar 29, 2025 at 9:01 AM Christos Gavros via > lists.openembedded.org <gavrosc=yahoo.com@lists.openembedded.org> > wrote: > > > > hi Adrian > > > > thank you for the comment. I had a look in commits log and it looks > > that '-c' was there since the beginning in 2008/09/10 in script > > 'init-live.sh' and then moved in 'finish.sh' in 2011/12/08. > > I reproduced the issue by using qemu and I described how I did it > > in detail in bug #15716. > > After I applied the change I tested both busybox and packagegroup- > > core-base-utils. The boot was successful in both cases. > > Also '-c' is an option in busybox: > > https://www.busybox.net/downloads/BusyBox.html > > > > -c option is to redirect the console after switching root. Some > devices it did not work properly because util-linux version moved the > pseudo filesystems like /dev automatically > but busybox version did not, maybe things have changed but I would > suggest that this operation is now happening with both switch_root > versions with you script manually doing so. I tested this on a device with kernel 6.1+. It seams to work as expected also with a busybox based initramfs. Maybe you are right and this is more like a legacy thing which can (or even should?) be removed. Additionally I looked into the code from busybox. The related lines are: if (console) { close(0); xopen(console, O_RDWR); xdup2(0, 1); xdup2(0, 2); } https://github.com/brgl/busybox/blob/master/util-linux/switch_root.c#L143 At least on my device this would just close /dev/console and open it again. Not really useful. I think the patch is beneficial for probably all kind of systems. Adrian > > > I will wait for more comments and then I will extend the commit > > message and send a v2. > > > > Br > > Christos > > > > > > > > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#213886): > https://lists.openembedded.org/g/openembedded-core/message/213886 > Mute This Topic: https://lists.openembedded.org/mt/111959232/4454582 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: > https://lists.openembedded.org/g/openembedded-core/unsub [ > adrian.freihofer@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- >
On Thu, 2025-04-10 at 23:27 +0200, Adrian Freihofer wrote: > On Sat, 2025-03-29 at 09:29 -0700, Khem Raj via lists.openembedded.org > wrote: > > On Sat, Mar 29, 2025 at 9:01 AM Christos Gavros via > > lists.openembedded.org <gavrosc=yahoo.com@lists.openembedded.org> > > wrote: > > > > > > hi Adrian > > > > > > thank you for the comment. I had a look in commits log and it looks > > > that '-c' was there since the beginning in 2008/09/10 in script > > > 'init-live.sh' and then moved in 'finish.sh' in 2011/12/08. > > > I reproduced the issue by using qemu and I described how I did it > > > in detail in bug #15716. > > > After I applied the change I tested both busybox and packagegroup- > > > core-base-utils. The boot was successful in both cases. > > > Also '-c' is an option in busybox: > > > https://www.busybox.net/downloads/BusyBox.html > > > > > > > -c option is to redirect the console after switching root. Some > > devices it did not work properly because util-linux version moved the > > pseudo filesystems like /dev automatically > > but busybox version did not, maybe things have changed but I would > > suggest that this operation is now happening with both switch_root > > versions with you script manually doing so. > > I tested this on a device with kernel 6.1+. It seams to work as > expected also with a busybox based initramfs. Maybe you are right and > this is more like a legacy thing which can (or even should?) be > removed. > > Additionally I looked into the code from busybox. The related lines > are: > > if (console) { > close(0); > xopen(console, O_RDWR); > xdup2(0, 1); > xdup2(0, 2); > } > https://github.com/brgl/busybox/blob/master/util-linux/switch_root.c#L143 > > At least on my device this would just close /dev/console and open it > again. Not really useful. > > I think the patch is beneficial for probably all kind of systems. Thanks, this analysis really helps. I agree that this does appear to make sense. I guess it is in case the initramfs and the main system have different /dev/console entries but that is probably/hopefully very rare. It would only be the init process affected. Cheers, Richard
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/finish b/meta/recipes-core/initrdscripts/initramfs-framework/finish index ac0de9f996..716c2f44af 100755 --- a/meta/recipes-core/initrdscripts/initramfs-framework/finish +++ b/meta/recipes-core/initrdscripts/initramfs-framework/finish @@ -41,7 +41,7 @@ finish_run() { mount --move /sys $ROOTFS_DIR/sys cd $ROOTFS_DIR - exec switch_root -c /dev/console $ROOTFS_DIR ${bootparam_init:-/sbin/init} + exec switch_root $ROOTFS_DIR ${bootparam_init:-/sbin/init} else debug "No rootfs has been set" fi
In 'finish'script the Switch_root command with option -c is busybox specific. When package-core-base-utils is selected the boot is breaking. Remove -c option to make it compatible with both providers Fixes [YOCTO #15716] CC: Yoann Congal <yoann.congal@smile.fr> CC: Randy MacLeod <randy.macleod@windriver.com> CC: Ross Burton <ross.burton@arm.com> CC: jbk <jbk@mm-software.com> Signed-off-by: Christos Gavros <gavrosc@yahoo.com> --- meta/recipes-core/initrdscripts/initramfs-framework/finish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)