diff mbox series

recipes-core: initrdscripts overlayroot allow boot partition

Message ID 20250701221135.966025-1-anibal@limonsoftware.com
State New
Headers show
Series recipes-core: initrdscripts overlayroot allow boot partition | expand

Commit Message

Anibal Limon July 1, 2025, 10:11 p.m. UTC
Test if /boot is previously mounted on the OLDROOT and move it
into NEWROOT (ro).

Signed-off-by: Anibal Limon <anibal@limonsoftware.com>
---
 .../initrdscripts/initramfs-framework/overlayroot        | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Khem Raj July 7, 2025, 4:18 p.m. UTC | #1
On Tue, Jul 1, 2025 at 3:11 PM Anibal Limon via lists.openembedded.org
<anibal=limonsoftware.com@lists.openembedded.org> wrote:
>
> Test if /boot is previously mounted on the OLDROOT and move it
> into NEWROOT (ro).

While change looks innocuous, I am curious what prompted this change.
Secondly, these changes can have subtle side-effects
for that it would be good to have a testcase so this behaviour does not regress.

>
> Signed-off-by: Anibal Limon <anibal@limonsoftware.com>
> ---
>  .../initrdscripts/initramfs-framework/overlayroot        | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/overlayroot b/meta/recipes-core/initrdscripts/initramfs-framework/overlayroot
> index 0d41432878..db164d9846 100644
> --- a/meta/recipes-core/initrdscripts/initramfs-framework/overlayroot
> +++ b/meta/recipes-core/initrdscripts/initramfs-framework/overlayroot
> @@ -38,10 +38,10 @@
>  PATH=/sbin:/bin:/usr/sbin:/usr/bin
>
>  # We get OLDROOT from the rootfs module
> -OLDROOT="/rootfs"
> +OLDROOT="${ROOTFS_DIR}"
>
> -NEWROOT="${RWMOUNT}/root"
>  RWMOUNT="/overlay"
> +NEWROOT="${RWMOUNT}/root"
>  ROMOUNT="${RWMOUNT}/rofs"
>  UPPER_DIR="${RWMOUNT}/upper"
>  WORK_DIR="${RWMOUNT}/work"
> @@ -115,4 +115,9 @@ mount -n --move /proc ${NEWROOT}/proc
>  mount -n --move /sys ${NEWROOT}/sys
>  mount -n --move /dev ${NEWROOT}/dev
>
> +# Mount/move boot if is already mounted
> +if mountpoint -q ${OLDROOT}/boot; then
> +    mount -n --move ${OLDROOT}/boot ${NEWROOT}/boot
> +fi
> +
>  exec chroot ${NEWROOT}/ ${bootparam_init:-/sbin/init} || exit_gracefully "Couldn't chroot into overlay"
> --
> 2.39.5
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#219735): https://lists.openembedded.org/g/openembedded-core/message/219735
> Mute This Topic: https://lists.openembedded.org/mt/113938218/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Anibal Limon July 7, 2025, 8:13 p.m. UTC | #2
Hi Khem,

Yes, let me look into the current tests for this one.

Regards!,
Anibal

On Mon, Jul 7, 2025 at 10:19 AM Khem Raj <raj.khem@gmail.com> wrote:

> On Tue, Jul 1, 2025 at 3:11 PM Anibal Limon via lists.openembedded.org
> <anibal=limonsoftware.com@lists.openembedded.org> wrote:
> >
> > Test if /boot is previously mounted on the OLDROOT and move it
> > into NEWROOT (ro).
>
> While change looks innocuous, I am curious what prompted this change.
> Secondly, these changes can have subtle side-effects
> for that it would be good to have a testcase so this behaviour does not
> regress.
>
> >
> > Signed-off-by: Anibal Limon <anibal@limonsoftware.com>
> > ---
> >  .../initrdscripts/initramfs-framework/overlayroot        | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git
> a/meta/recipes-core/initrdscripts/initramfs-framework/overlayroot
> b/meta/recipes-core/initrdscripts/initramfs-framework/overlayroot
> > index 0d41432878..db164d9846 100644
> > --- a/meta/recipes-core/initrdscripts/initramfs-framework/overlayroot
> > +++ b/meta/recipes-core/initrdscripts/initramfs-framework/overlayroot
> > @@ -38,10 +38,10 @@
> >  PATH=/sbin:/bin:/usr/sbin:/usr/bin
> >
> >  # We get OLDROOT from the rootfs module
> > -OLDROOT="/rootfs"
> > +OLDROOT="${ROOTFS_DIR}"
> >
> > -NEWROOT="${RWMOUNT}/root"
> >  RWMOUNT="/overlay"
> > +NEWROOT="${RWMOUNT}/root"
> >  ROMOUNT="${RWMOUNT}/rofs"
> >  UPPER_DIR="${RWMOUNT}/upper"
> >  WORK_DIR="${RWMOUNT}/work"
> > @@ -115,4 +115,9 @@ mount -n --move /proc ${NEWROOT}/proc
> >  mount -n --move /sys ${NEWROOT}/sys
> >  mount -n --move /dev ${NEWROOT}/dev
> >
> > +# Mount/move boot if is already mounted
> > +if mountpoint -q ${OLDROOT}/boot; then
> > +    mount -n --move ${OLDROOT}/boot ${NEWROOT}/boot
> > +fi
> > +
> >  exec chroot ${NEWROOT}/ ${bootparam_init:-/sbin/init} ||
> exit_gracefully "Couldn't chroot into overlay"
> > --
> > 2.39.5
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#219735):
> https://lists.openembedded.org/g/openembedded-core/message/219735
> > Mute This Topic: https://lists.openembedded.org/mt/113938218/1997914
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> raj.khem@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
>
diff mbox series

Patch

diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/overlayroot b/meta/recipes-core/initrdscripts/initramfs-framework/overlayroot
index 0d41432878..db164d9846 100644
--- a/meta/recipes-core/initrdscripts/initramfs-framework/overlayroot
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/overlayroot
@@ -38,10 +38,10 @@ 
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
 # We get OLDROOT from the rootfs module
-OLDROOT="/rootfs"
+OLDROOT="${ROOTFS_DIR}"
 
-NEWROOT="${RWMOUNT}/root"
 RWMOUNT="/overlay"
+NEWROOT="${RWMOUNT}/root"
 ROMOUNT="${RWMOUNT}/rofs"
 UPPER_DIR="${RWMOUNT}/upper"
 WORK_DIR="${RWMOUNT}/work"
@@ -115,4 +115,9 @@  mount -n --move /proc ${NEWROOT}/proc
 mount -n --move /sys ${NEWROOT}/sys
 mount -n --move /dev ${NEWROOT}/dev
 
+# Mount/move boot if is already mounted
+if mountpoint -q ${OLDROOT}/boot; then
+    mount -n --move ${OLDROOT}/boot ${NEWROOT}/boot
+fi
+
 exec chroot ${NEWROOT}/ ${bootparam_init:-/sbin/init} || exit_gracefully "Couldn't chroot into overlay"