Skip to contentSkip to conversation

initramfs-framework: configuration to boot up live image

PATCH Superseded [email protected] 3 participants 8 messages Jul 7, 2017 – Jul 11, 2017

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover initramfs-framework: configuration to boot up live image

From: "Ng, Wei Tee" <[email protected]>

Hi,

This patch is to get initramfs-framework able to boot up live image. A new scriplet named setup-live module has been created to handle the removeable media detection and assign the rootfs.img. This is because the current rootfs module has no support for rootfs images, only rootfs partitions.

This version 3 included the changes for creation of initramfs-module-setup-live in the recipe and added udev-extraconf rdepends on this module because it is needed for automounting process.

This changes has been verified with build test and boot up test on Minnowboard Max platform.

Please review and provide feedback if you have any. The patches are targeted for merging into poky master branch.

Thanks and regards,
Wei Tee

The following changes since commit 4b1d270602a0542eef1b497eaf15bad2b747686f:

bitbake: bitbake-user-manual: Removed and replaced broken link (2017-07-04 16:05:22 +0100)

are available in the git repository at:

ssh://git.yoctoproject.org/poky-contrib weiteeng/initramfs-v3
http://git.yoctoproject.org/cgit.cgi//log/?h=weiteeng/initramfs-v3

Ng, Wei Tee (2):
initramfs-framework: setup-live: detect media and assign rootfs image
initramfs-framwork: module to support boot live image

 .../initrdscripts/initramfs-framework/setup-live   | 67 ++++++++++++++++++++++
 .../initrdscripts/initramfs-framework_1.0.bb       | 13 ++++-
 2 files changed, 78 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-core/initrdscripts/initramfs-framework/setup-live
Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 1/2 initramfs-framework: setup-live: detect media and assign rootfs image

From: "Ng, Wei Tee" <[email protected]>

Integrate the featuers in init-live.sh into new scriptlet to handle boot up live image process using framework method.

This commit include the changes for:
- Create a conditional loop for the bootparam_root variable. If it is not set, then it will boot from ROOT_IMAGE. Else, it will boot normally which is not from removable media.

- Gives a standard path to the original boot disk mount which can be used to. While /media/sda is a good guess, it isn't always right, nor is it a good assumption that only one boot disk is in the system.

- The current rootfs module has no support for rootfs images, currently it only support for rootfs partitions for wic image. Therefore, there is a need to assign the rootfs image for live image.

---
 .../initrdscripts/initramfs-framework/setup-live   | 67 ++++++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 meta/recipes-core/initrdscripts/initramfs-framework/setup-live
meta/recipes-core/initrdscripts/initramfs-framework/setup-live new file +67 -0
new file mode 100644
index 0000000..16da34a
@@ -0,0 +1,67 @@
+#/bin/sh
+# Copyright (C) 2011 O.S. Systems Software LTDA.
+# Licensed on MIT
+
+setup_enabled() {
+	return 0
+}
+
+setup_run() {
+ROOT_IMAGE="rootfs.img"
+ISOLINUX=""
+ROOT_DISK=""
+shelltimeout=30
+
+	if [ -z $bootparam_root ]; then
+		echo "Waiting for removable media..."
+		C=0
+		while true
+		do
+		  for i in `ls /run/media 2>/dev/null`; do
+		      if [ -f /run/media/$i/$ROOT_IMAGE ] ; then
+				found="yes"
+				ROOT_DISK="$i"
+				break
+			  elif [ -f /run/media/$i/isolinux/$ROOT_IMAGE ]; then
+				found="yes"
+				ISOLINUX="isolinux"
+				ROOT_DISK="$i"
+				break
+		      fi
+		  done
+		  if [ "$found" = "yes" ]; then
+		      break;
+		  fi
+		  # don't wait for more than $shelltimeout seconds, if it's set
+		  if [ -n "$shelltimeout" ]; then
+		      echo -n " " $(( $shelltimeout - $C ))
+		      if [ $C -ge $shelltimeout ]; then
+		           echo "..."
+			   echo "Mounted filesystems"
+		           mount | grep media
+		           echo "Available block devices"
+		           cat /proc/partitions
+		           fatal "Cannot find $ROOT_IMAGE file in /run/media/* , dropping to a shell "
+		      fi
+		      C=$(( C + 1 ))
+		  fi
+		  sleep 1
+		done
+
+		# The existing rootfs module has no support for rootfs images. Assign the rootfs image.
+		bootparam_root="/run/media/$ROOT_DISK/$ISOLINUX/$ROOT_IMAGE"
+	else
+		break
+	fi
+
+	if [ "$bootparam_LABEL" != "boot" -a -f /init.d/$bootparam_LABEL.sh ] ; then
+		if [ -f /run/media/$i/$ISOLINUX/$ROOT_IMAGE ] ; then
+		    ./init.d/$bootparam_LABEL.sh $i/$ISOLINUX $ROOT_IMAGE $video_mode $vga_mode $console_params
+		else
+		    fatal "Could not find $bootparam_LABEL script"
+		fi
+
+		# If we're getting here, we failed...
+		fatal "Target $bootparam_LABEL failed"
+	fi
+}
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH v3 1/2] initramfs-framework: setup-live: detect media and assign rootfs image

Quoted 3 lines · On Thu, Jul 6, 2017 at 3:28 PM, <[email protected]> wrote:

From: "Ng, Wei Tee" <[email protected]>

Integrate the featuers in init-live.sh into new scriptlet to handle

typo!

Quoted 30 lines

boot up live image process using framework method.

This commit include the changes for:
- Create a conditional loop for the bootparam_root variable. If it is not set, then it will boot from ROOT_IMAGE. Else, it will boot normally which is not from removable media.

- Gives a standard path to the original boot disk mount which can be used to. While /media/sda is a good guess, it isn't always right, nor is it a good assumption that only one boot disk is in the system.

- The current rootfs module has no support for rootfs images, currently it only support for rootfs partitions for wic image. Therefore, there is a need to assign the rootfs image for live image.

---
 .../initrdscripts/initramfs-framework/setup-live   | 67 ++++++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 meta/recipes-core/initrdscripts/initramfs-framework/setup-live
meta/recipes-core/initrdscripts/initramfs-framework/setup-live new file +3 -0
new file mode 100644
index 0000000..16da34a
@@ -0,0 +1,67 @@
+#/bin/sh
+# Copyright (C) 2011 O.S. Systems Software LTDA.
+# Licensed on MIT

meta/recipes-core/initrdscripts/initramfs-framework/setup-live line 13

Quoted 10 lines
meta/recipes-core/initrdscripts/initramfs-framework/setup-live new file +10 -0
+
+setup_enabled() {
+       return 0
+}
+
+setup_run() {
+ROOT_IMAGE="rootfs.img"
+ISOLINUX=""
+ROOT_DISK=""
+shelltimeout=30

Wrong indent

meta/recipes-core/initrdscripts/initramfs-framework/setup-live line 25

Quoted 11 lines
meta/recipes-core/initrdscripts/initramfs-framework/setup-live new file +11 -0
+       if [ -z $bootparam_root ]; then
+               echo "Waiting for removable media..."
+               C=0
+               while true
+               do
+                 for i in `ls /run/media 2>/dev/null`; do
+                     if [ -f /run/media/$i/$ROOT_IMAGE ] ; then
+                               found="yes"
+                               ROOT_DISK="$i"
+                               break
+                         elif [ -f /run/media/$i/isolinux/$ROOT_IMAGE ]; then

Wrong indent

Quoted 9 lines
meta/recipes-core/initrdscripts/initramfs-framework/setup-live new file +9 -0
+                               found="yes"
+                               ISOLINUX="isolinux"
+                               ROOT_DISK="$i"
+                               break
+                     fi
+                 done
+                 if [ "$found" = "yes" ]; then
+                     break;
+                 fi

meta/recipes-core/initrdscripts/initramfs-framework/setup-live line 44

Quoted 10 lines
meta/recipes-core/initrdscripts/initramfs-framework/setup-live new file +10 -0
+                 # don't wait for more than $shelltimeout seconds, if it's set
+                 if [ -n "$shelltimeout" ]; then
+                     echo -n " " $(( $shelltimeout - $C ))
+                     if [ $C -ge $shelltimeout ]; then
+                          echo "..."
+                          echo "Mounted filesystems"
+                          mount | grep media
+                          echo "Available block devices"
+                          cat /proc/partitions
+                          fatal "Cannot find $ROOT_IMAGE file in /run/media/* , dropping to a shell "

IIRC fatal does not drop to a shell, it keeps a loop.

Quoted 31 lines
meta/recipes-core/initrdscripts/initramfs-framework/setup-live new file +23 -1
+                     fi
+                     C=$(( C + 1 ))
+                 fi
+                 sleep 1
+               done
+
+               # The existing rootfs module has no support for rootfs images. Assign the rootfs image.
+               bootparam_root="/run/media/$ROOT_DISK/$ISOLINUX/$ROOT_IMAGE"
+       else
+               break
+       fi
+
+       if [ "$bootparam_LABEL" != "boot" -a -f /init.d/$bootparam_LABEL.sh ] ; then
+               if [ -f /run/media/$i/$ISOLINUX/$ROOT_IMAGE ] ; then
+                   ./init.d/$bootparam_LABEL.sh $i/$ISOLINUX $ROOT_IMAGE $video_mode $vga_mode $console_params
+               else
+                   fatal "Could not find $bootparam_LABEL script"
+               fi
+
+               # If we're getting here, we failed...
+               fatal "Target $bootparam_LABEL failed"
+       fi
+}
--

2.7.4

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#3 lore raw

PATCH v3 2/2 initramfs-framwork: module to support boot live image

In reply to [email protected]

From: "Ng, Wei Tee" <[email protected]>

setup-live module is a new module being introduced to integrate the functionality of init-live.sh into new scriptlet in order to support the live boot image. The udev-extraconf rdepends is being added to perform automounting. It gets to run before the rootfs and finish module.

[YOCTO #11701]

---
This v3 changes included the creation of new initramfs-module-setup-live and added the udev-extraconf rdepends on this module as live-boot require it to work.

 meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb +11 -2
index 67a1b04..aa1d847 100644
@@ -13,7 +13,8 @@ SRC_URI = "file://init \
            file://mdev \
            file://udev \
            file://e2fs \
-           file://debug"
+           file://debug \
+	   file://setup-live"
 
 S = "${WORKDIR}"
 
@@ -25,6 +26,9 @@ do_install() {
     install -m 0755 ${WORKDIR}/rootfs ${D}/init.d/90-rootfs
     install -m 0755 ${WORKDIR}/finish ${D}/init.d/99-finish
 
+    # setup-live
+    install -m 0755 ${WORKDIR}/setup-live ${D}/init.d/80-setup-live
+
     # mdev
     install -m 0755 ${WORKDIR}/mdev ${D}/init.d/01-mdev
 
@@ -48,7 +52,8 @@ PACKAGES = "${PN}-base \
             initramfs-module-udev \
             initramfs-module-e2fs \
             initramfs-module-rootfs \
-            initramfs-module-debug"
+            initramfs-module-debug \
+	    initramfs-module-setup-live"
 
 FILES_${PN}-base = "/init /init.d/99-finish /dev"
 
@@ -68,6 +73,10 @@ SUMMARY_initramfs-module-udev = "initramfs support for udev"
 RDEPENDS_initramfs-module-udev = "${PN}-base udev"
 FILES_initramfs-module-udev = "/init.d/01-udev"
 
+SUMMARY_initramfs-module-setup-live = "initramfs support for setup live"
+RDEPENDS_initramfs-module-setup-live = "${PN}-base udev-extraconf"
+FILES_initramfs-module-setup-live = "/init.d/80-setup-live"
+
 SUMMARY_initramfs-module-e2fs = "initramfs support for ext4/ext3/ext2 filesystems"
 RDEPENDS_initramfs-module-e2fs = "${PN}-base"
 FILES_initramfs-module-e2fs = "/init.d/10-e2fs"
Signature · 1 line
2.7.4
#4 lore raw

Re: [PATCH v3 2/2] initramfs-framwork: module to support boot live image

Quoted 11 lines · On Thu, Jul 6, 2017 at 3:28 PM, <[email protected]> wrote:

From: "Ng, Wei Tee" <[email protected]>

setup-live module is a new module being introduced to integrate the functionality of init-live.sh into new scriptlet in order to support the live boot image. The udev-extraconf rdepends is being added to perform automounting. It gets to run before the rootfs and finish module.

[YOCTO #11701]

I think this patch could be squashed onto the first as it is required for it to work.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#5 lore raw

Re: [PATCH v3 2/2] initramfs-framwork: module to support boot live image

Yes, I had squash the changes into a single commit and corrected the typo also. The changes is being submitted to the mailing list. Thanks a lot!

Regards,
Wei Tee

-----Original Message-----
From: Otavio Salvador [mailto:[email protected]]
Sent: Tuesday, July 11, 2017 1:43 AM
To: Ng, Wei Tee <[email protected]>
Cc: Patches and discussions about the oe-core layer <[email protected]>; Wold, Saul <[email protected]>
Subject: Re: [OE-core] [PATCH v3 2/2] initramfs-framwork: module to support boot live image

Quoted 11 lines · On Thu, Jul 6, 2017 at 3:28 PM, <[email protected]> wrote:

From: "Ng, Wei Tee" <[email protected]>

setup-live module is a new module being introduced to integrate the functionality of init-live.sh into new scriptlet in order to support the live boot image. The udev-extraconf rdepends is being added to perform automounting. It gets to run before the rootfs and finish module.

[YOCTO #11701]

I think this patch could be squashed onto the first as it is required for it to work.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#6 lore raw

Re: [PATCH v3 2/2] initramfs-framwork: module to support boot live image

Quoted 2 lines · Wei Tee

Yes, I had squash the changes into a single commit and corrected the typo also. The changes is being submitted to the mailing list. Thanks a lot!

There are bad indents yet; please double check it all.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#7 lore raw
In reply to [email protected]
Quoted 4 lines · On 6 July 2017 at 19:28, <[email protected]> wrote:

Ng, Wei Tee (2):
initramfs-framework: setup-live: detect media and assign rootfs image
initramfs-framwork: module to support boot live image

Can you squash these into a single commit, as the addition of setup-live in the first commit doesn't achieve anything on its own.

Ross