* [PATCH 0/4] some init/finish enhancements for initramfs-framework
@ 2015-09-09 13:10 Patrick Ohly
2015-09-09 13:10 ` [PATCH 1/4] initramfs-framework: support rootflags and rootfstype boot parameter Patrick Ohly
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Patrick Ohly @ 2015-09-09 13:10 UTC (permalink / raw)
To: openembedded-core
While continuing my work in integrating IMA into the
initramfs-framework, I found that it is necessary to have more control
over the mount parameters. These patches grant that control using the same
boot parameters as in the Linux kernel.
For debugging I also found it useful to have more opportunities to get
into a shell.
I'm posting these patches because others may also find them useful. If
there's no time to review or merge now, feel free to ignore until
after the next release. In the meantime, I'll proceed with a local
copy of the two files.
The following changes since commit 8402958cd2cb87b8283c8ee4e2d08e1a6717d67a:
pseudo_1.7.3.bb: New version of pseudo (2015-09-06 15:24:28 +0100)
are available in the git repository at:
git://github.com/pohly/openembedded-core initramfs-framework
https://github.com/pohly/openembedded-core/tree/initramfs-framework
Patrick Ohly (4):
initramfs-framework: support rootflags and rootfstype boot parameter
initramfs-framework: support ro boot parameter
initramfs-framework: support init boot parameter
initramfs-framework: support dropping into shell on failure
.../initrdscripts/initramfs-framework/finish | 17 +++++++++++++++--
.../recipes-core/initrdscripts/initramfs-framework/init | 4 ++++
2 files changed, 19 insertions(+), 2 deletions(-)
--
2.1.4
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/4] initramfs-framework: support rootflags and rootfstype boot parameter
2015-09-09 13:10 [PATCH 0/4] some init/finish enhancements for initramfs-framework Patrick Ohly
@ 2015-09-09 13:10 ` Patrick Ohly
2015-09-09 14:10 ` Otavio Salvador
2015-09-09 13:10 ` [PATCH 2/4] initramfs-framework: support ro " Patrick Ohly
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Patrick Ohly @ 2015-09-09 13:10 UTC (permalink / raw)
To: openembedded-core
These two parameters are supported by the kernel
(https://www.kernel.org/doc/Documentation/kernel-parameters.txt). When
an initramfs is used, the kernel does not mount the rootfs and the
initramfs needs to react to them.
The boot parameters can be set both by the image creator and
by users.
Supporting these two parameters is useful:
- rootflags is needed to ensure that the rootfs is already mounted as
intended in the time between starting init and init remounting
it (as systemd does); this is critical for IMA where iversion must be
active already when system starts writing files.
- setting it correctly up-front avoids messages from the kernel ("cannot
mount ... as ext2 because ...") when trying to guess the desired type.
For example, assuming that only one of ext4/ext3/ext2 is set,
rootfstype could be set in an image recipe with:
APPEND_append = "${@''.join([' rootfstype=' + i for i in ['ext4', 'ext3', 'ext2'] if i in d.getVar('IMAGE_FSTYPES', True).split()])}"
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
---
meta/recipes-core/initrdscripts/initramfs-framework/finish | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/finish b/meta/recipes-core/initrdscripts/initramfs-framework/finish
index 325f47b..006aef2 100755
--- a/meta/recipes-core/initrdscripts/initramfs-framework/finish
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/finish
@@ -22,7 +22,14 @@ finish_run() {
fi
if [ -e "$bootparam_root" ]; then
- mount $bootparam_root $ROOTFS_DIR
+ flags=""
+ if [ -n "$bootparam_rootflags" ]; then
+ flags="$flags -o$bootparam_rootflags"
+ fi
+ if [ -n "$bootparam_rootfstype" ]; then
+ flags="$flags -t$bootparam_rootfstype"
+ fi
+ mount $flags $bootparam_root $ROOTFS_DIR
else
debug "root '$bootparam_root' doesn't exist."
fi
--
2.1.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/4] initramfs-framework: support ro boot parameter
2015-09-09 13:10 [PATCH 0/4] some init/finish enhancements for initramfs-framework Patrick Ohly
2015-09-09 13:10 ` [PATCH 1/4] initramfs-framework: support rootflags and rootfstype boot parameter Patrick Ohly
@ 2015-09-09 13:10 ` Patrick Ohly
2015-09-09 14:11 ` Otavio Salvador
2015-09-09 13:10 ` [PATCH 3/4] initramfs-framework: support init " Patrick Ohly
2015-09-09 13:10 ` [PATCH 4/4] initramfs-framework: support dropping into shell on failure Patrick Ohly
3 siblings, 1 reply; 9+ messages in thread
From: Patrick Ohly @ 2015-09-09 13:10 UTC (permalink / raw)
To: openembedded-core
Default is to mount the rootfs read/write. "ro" can be used to turn
that into read-only, which is useful on systems where userspace does
an fsck before remounting read-write.
Giving both "ro" and "rw" will still mount read-only regardless of the
order, because the ordering information is not preserved by the
initramfs-framework's boot param support.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
---
meta/recipes-core/initrdscripts/initramfs-framework/finish | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/finish b/meta/recipes-core/initrdscripts/initramfs-framework/finish
index 006aef2..a8806aa 100755
--- a/meta/recipes-core/initrdscripts/initramfs-framework/finish
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/finish
@@ -23,6 +23,12 @@ finish_run() {
if [ -e "$bootparam_root" ]; then
flags=""
+ if [ -n "$bootparam_ro" ]; then
+ if [ -n "$bootparam_rootflags" ]; then
+ bootparam_rootflags="$bootparam_rootflags,"
+ fi
+ bootparam_rootflags="${bootparam_rootflags}ro"
+ fi
if [ -n "$bootparam_rootflags" ]; then
flags="$flags -o$bootparam_rootflags"
fi
--
2.1.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/4] initramfs-framework: support init boot parameter
2015-09-09 13:10 [PATCH 0/4] some init/finish enhancements for initramfs-framework Patrick Ohly
2015-09-09 13:10 ` [PATCH 1/4] initramfs-framework: support rootflags and rootfstype boot parameter Patrick Ohly
2015-09-09 13:10 ` [PATCH 2/4] initramfs-framework: support ro " Patrick Ohly
@ 2015-09-09 13:10 ` Patrick Ohly
2015-09-09 14:11 ` Otavio Salvador
2015-09-09 13:10 ` [PATCH 4/4] initramfs-framework: support dropping into shell on failure Patrick Ohly
3 siblings, 1 reply; 9+ messages in thread
From: Patrick Ohly @ 2015-09-09 13:10 UTC (permalink / raw)
To: openembedded-core
It can be useful for debugging to override the default /sbin/init.
This is something typically done via the init boot parameter which
then gets interpreted by the kernel. But when using an initramfs, it
is the initramfs which must react to the option.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.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 a8806aa..e712ff0 100755
--- a/meta/recipes-core/initrdscripts/initramfs-framework/finish
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/finish
@@ -53,7 +53,7 @@ finish_run() {
mount --move /sys $ROOTFS_DIR/sys
cd $ROOTFS_DIR
- exec switch_root -c /dev/console $ROOTFS_DIR /sbin/init
+ exec switch_root -c /dev/console $ROOTFS_DIR ${bootparam_init:-/sbin/init}
else
debug "No rootfs has been set"
fi
--
2.1.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/4] initramfs-framework: support dropping into shell on failure
2015-09-09 13:10 [PATCH 0/4] some init/finish enhancements for initramfs-framework Patrick Ohly
` (2 preceding siblings ...)
2015-09-09 13:10 ` [PATCH 3/4] initramfs-framework: support init " Patrick Ohly
@ 2015-09-09 13:10 ` Patrick Ohly
2015-09-09 14:12 ` Otavio Salvador
3 siblings, 1 reply; 9+ messages in thread
From: Patrick Ohly @ 2015-09-09 13:10 UTC (permalink / raw)
To: openembedded-core
When the init_fatal_sh boot parameter is present (i.e. used without
value) and a fatal problem occurs inside the initramfs-module, a shell
will be started instead of looping forever.
Useful for debugging.
Interestingly enough, the code was already indented to support such an
if check...
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
---
meta/recipes-core/initrdscripts/initramfs-framework/init | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/init b/meta/recipes-core/initrdscripts/initramfs-framework/init
index e8f4713..9291ad5 100755
--- a/meta/recipes-core/initrdscripts/initramfs-framework/init
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/init
@@ -58,9 +58,13 @@ fatal() {
echo $1 >/dev/console
echo >/dev/console
+ if [ -n "bootparam_init_fatal_sh" ]; then
+ sh
+ else
while [ "true" ]; do
sleep 3600
done
+ fi
}
# Variables shared amoung modules
--
2.1.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/4] initramfs-framework: support rootflags and rootfstype boot parameter
2015-09-09 13:10 ` [PATCH 1/4] initramfs-framework: support rootflags and rootfstype boot parameter Patrick Ohly
@ 2015-09-09 14:10 ` Otavio Salvador
0 siblings, 0 replies; 9+ messages in thread
From: Otavio Salvador @ 2015-09-09 14:10 UTC (permalink / raw)
To: Patrick Ohly; +Cc: Patches and discussions about the oe-core layer
On Wed, Sep 9, 2015 at 10:10 AM, Patrick Ohly <patrick.ohly@intel.com> wrote:
> These two parameters are supported by the kernel
> (https://www.kernel.org/doc/Documentation/kernel-parameters.txt). When
> an initramfs is used, the kernel does not mount the rootfs and the
> initramfs needs to react to them.
>
> The boot parameters can be set both by the image creator and
> by users.
>
> Supporting these two parameters is useful:
> - rootflags is needed to ensure that the rootfs is already mounted as
> intended in the time between starting init and init remounting
> it (as systemd does); this is critical for IMA where iversion must be
> active already when system starts writing files.
> - setting it correctly up-front avoids messages from the kernel ("cannot
> mount ... as ext2 because ...") when trying to guess the desired type.
>
> For example, assuming that only one of ext4/ext3/ext2 is set,
> rootfstype could be set in an image recipe with:
> APPEND_append = "${@''.join([' rootfstype=' + i for i in ['ext4', 'ext3', 'ext2'] if i in d.getVar('IMAGE_FSTYPES', True).split()])}"
>
> Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Acked-by: Otavio Salvador <otavio@ossystems.com.br>
--
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/4] initramfs-framework: support ro boot parameter
2015-09-09 13:10 ` [PATCH 2/4] initramfs-framework: support ro " Patrick Ohly
@ 2015-09-09 14:11 ` Otavio Salvador
0 siblings, 0 replies; 9+ messages in thread
From: Otavio Salvador @ 2015-09-09 14:11 UTC (permalink / raw)
To: Patrick Ohly; +Cc: Patches and discussions about the oe-core layer
On Wed, Sep 9, 2015 at 10:10 AM, Patrick Ohly <patrick.ohly@intel.com> wrote:
> Default is to mount the rootfs read/write. "ro" can be used to turn
> that into read-only, which is useful on systems where userspace does
> an fsck before remounting read-write.
>
> Giving both "ro" and "rw" will still mount read-only regardless of the
> order, because the ordering information is not preserved by the
> initramfs-framework's boot param support.
>
> Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Acked-by: Otavio Salvador <otavio@ossystems.com.br>
--
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/4] initramfs-framework: support init boot parameter
2015-09-09 13:10 ` [PATCH 3/4] initramfs-framework: support init " Patrick Ohly
@ 2015-09-09 14:11 ` Otavio Salvador
0 siblings, 0 replies; 9+ messages in thread
From: Otavio Salvador @ 2015-09-09 14:11 UTC (permalink / raw)
To: Patrick Ohly; +Cc: Patches and discussions about the oe-core layer
On Wed, Sep 9, 2015 at 10:10 AM, Patrick Ohly <patrick.ohly@intel.com> wrote:
> It can be useful for debugging to override the default /sbin/init.
> This is something typically done via the init boot parameter which
> then gets interpreted by the kernel. But when using an initramfs, it
> is the initramfs which must react to the option.
>
> Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Acked-by: Otavio Salvador <otavio@ossystems.com.br>
--
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 4/4] initramfs-framework: support dropping into shell on failure
2015-09-09 13:10 ` [PATCH 4/4] initramfs-framework: support dropping into shell on failure Patrick Ohly
@ 2015-09-09 14:12 ` Otavio Salvador
0 siblings, 0 replies; 9+ messages in thread
From: Otavio Salvador @ 2015-09-09 14:12 UTC (permalink / raw)
To: Patrick Ohly; +Cc: Patches and discussions about the oe-core layer
On Wed, Sep 9, 2015 at 10:10 AM, Patrick Ohly <patrick.ohly@intel.com> wrote:
> When the init_fatal_sh boot parameter is present (i.e. used without
> value) and a fatal problem occurs inside the initramfs-module, a shell
> will be started instead of looping forever.
>
> Useful for debugging.
>
> Interestingly enough, the code was already indented to support such an
> if check...
>
> Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Acked-by: Otavio Salvador <otavio@ossystems.com.br>
--
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
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-09-09 14:12 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-09 13:10 [PATCH 0/4] some init/finish enhancements for initramfs-framework Patrick Ohly
2015-09-09 13:10 ` [PATCH 1/4] initramfs-framework: support rootflags and rootfstype boot parameter Patrick Ohly
2015-09-09 14:10 ` Otavio Salvador
2015-09-09 13:10 ` [PATCH 2/4] initramfs-framework: support ro " Patrick Ohly
2015-09-09 14:11 ` Otavio Salvador
2015-09-09 13:10 ` [PATCH 3/4] initramfs-framework: support init " Patrick Ohly
2015-09-09 14:11 ` Otavio Salvador
2015-09-09 13:10 ` [PATCH 4/4] initramfs-framework: support dropping into shell on failure Patrick Ohly
2015-09-09 14:12 ` Otavio Salvador
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox