Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [git commit] initramfs: fix boot with dynamic /dev
@ 2011-07-20 14:30 Peter Korsgaard
  2011-07-20 16:12 ` Michael S. Zick
  2011-08-24  7:53 ` Arnout Vandecappelle
  0 siblings, 2 replies; 6+ messages in thread
From: Peter Korsgaard @ 2011-07-20 14:30 UTC (permalink / raw)
  To: buildroot


commit: http://git.buildroot.net/buildroot/commit/?id=424888e47431db738f5f9b3c6392435bfce7a842
branch: http://git.buildroot.net/buildroot/commit/?id=refs/heads/master

Devtmpfs (which is used by devtmpfs/mdev/udev options) doesn't get
automounted by the kernel when an initramfs is used, causing boot
failures when a dynamic /dev is used.

Fix it by adding a pre-init script to mount devtmpfs before running init.

Reported-by: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
 fs/initramfs/init         |    4 ++++
 fs/initramfs/initramfs.mk |   17 +++++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)
 create mode 100755 fs/initramfs/init

diff --git a/fs/initramfs/init b/fs/initramfs/init
new file mode 100755
index 0000000..751cb27
--- /dev/null
+++ b/fs/initramfs/init
@@ -0,0 +1,4 @@
+#!/bin/sh
+# devtmpfs does not get automounted for initramfs
+/bin/mount -t devtmpfs devtmpfs /dev
+exec /sbin/init $*
diff --git a/fs/initramfs/initramfs.mk b/fs/initramfs/initramfs.mk
index 73122a8..1cd48b6 100644
--- a/fs/initramfs/initramfs.mk
+++ b/fs/initramfs/initramfs.mk
@@ -6,13 +6,26 @@
 #
 #############################################################
 
-define ROOTFS_INITRAMFS_INIT_SYMLINK
+ifeq ($(BR2_ROOTFS_DEVICE_CREATION_STATIC),y)
+
+define ROOTFS_INITRAMFS_ADD_INIT
 	if [ ! -e $(TARGET_DIR)/init ]; then \
 		ln -sf sbin/init $(TARGET_DIR)/init; \
 	fi
 endef
 
-ROOTFS_INITRAMFS_PRE_GEN_HOOKS += ROOTFS_INITRAMFS_INIT_SYMLINK
+else
+# devtmpfs does not get automounted when initramfs is used.
+# Add a pre-init script to mount it before running init
+define ROOTFS_INITRAMFS_ADD_INIT
+	if [ ! -e $(TARGET_DIR)/init ]; then \
+		$(INSTALL) -m 0755 fs/initramfs/init $(TARGET_DIR)/init; \
+	fi
+endef
+
+endif # BR2_ROOTFS_DEVICE_CREATION_STATIC
+
+ROOTFS_INITRAMFS_PRE_GEN_HOOKS += ROOTFS_INITRAMFS_ADD_INIT
 
 define ROOTFS_INITRAMFS_CMD
 	$(SHELL) fs/initramfs/gen_initramfs_list.sh -u 0 -g 0 $(TARGET_DIR) > $$@
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [git commit] initramfs: fix boot with dynamic /dev
  2011-07-20 14:30 [Buildroot] [git commit] initramfs: fix boot with dynamic /dev Peter Korsgaard
@ 2011-07-20 16:12 ` Michael S. Zick
  2011-07-20 17:43   ` Peter Korsgaard
  2011-08-24  7:53 ` Arnout Vandecappelle
  1 sibling, 1 reply; 6+ messages in thread
From: Michael S. Zick @ 2011-07-20 16:12 UTC (permalink / raw)
  To: buildroot

On Wed July 20 2011, Peter Korsgaard wrote:
> 
> commit: http://git.buildroot.net/buildroot/commit/?id=424888e47431db738f5f9b3c6392435bfce7a842
> branch: http://git.buildroot.net/buildroot/commit/?id=refs/heads/master
> 
> Devtmpfs (which is used by devtmpfs/mdev/udev options) doesn't get
> automounted by the kernel when an initramfs is used, causing boot
> failures when a dynamic /dev is used.
> 
> Fix it by adding a pre-init script to mount devtmpfs before running init.
> 
> Reported-by: Arnout Vandecappelle <arnout@mind.be>
> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
> ---
>  fs/initramfs/init         |    4 ++++
>  fs/initramfs/initramfs.mk |   17 +++++++++++++++--
>  2 files changed, 19 insertions(+), 2 deletions(-)
>  create mode 100755 fs/initramfs/init
> 
> diff --git a/fs/initramfs/init b/fs/initramfs/init
> new file mode 100755
> index 0000000..751cb27
> --- /dev/null
> +++ b/fs/initramfs/init
> @@ -0,0 +1,4 @@
> +#!/bin/sh
>

Will the various shell aps run a script without /dev/console and /dev/null?

Once upon a time, some did not, but that may no longer be true.

Mike

> +# devtmpfs does not get automounted for initramfs
> +/bin/mount -t devtmpfs devtmpfs /dev
> +exec /sbin/init $*
> diff --git a/fs/initramfs/initramfs.mk b/fs/initramfs/initramfs.mk
> index 73122a8..1cd48b6 100644
> --- a/fs/initramfs/initramfs.mk
> +++ b/fs/initramfs/initramfs.mk
> @@ -6,13 +6,26 @@
>  #
>  #############################################################
>  
> -define ROOTFS_INITRAMFS_INIT_SYMLINK
> +ifeq ($(BR2_ROOTFS_DEVICE_CREATION_STATIC),y)
> +
> +define ROOTFS_INITRAMFS_ADD_INIT
>  	if [ ! -e $(TARGET_DIR)/init ]; then \
>  		ln -sf sbin/init $(TARGET_DIR)/init; \
>  	fi
>  endef
>  
> -ROOTFS_INITRAMFS_PRE_GEN_HOOKS += ROOTFS_INITRAMFS_INIT_SYMLINK
> +else
> +# devtmpfs does not get automounted when initramfs is used.
> +# Add a pre-init script to mount it before running init
> +define ROOTFS_INITRAMFS_ADD_INIT
> +	if [ ! -e $(TARGET_DIR)/init ]; then \
> +		$(INSTALL) -m 0755 fs/initramfs/init $(TARGET_DIR)/init; \
> +	fi
> +endef
> +
> +endif # BR2_ROOTFS_DEVICE_CREATION_STATIC
> +
> +ROOTFS_INITRAMFS_PRE_GEN_HOOKS += ROOTFS_INITRAMFS_ADD_INIT
>  
>  define ROOTFS_INITRAMFS_CMD
>  	$(SHELL) fs/initramfs/gen_initramfs_list.sh -u 0 -g 0 $(TARGET_DIR) > $$@

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [git commit] initramfs: fix boot with dynamic /dev
  2011-07-20 16:12 ` Michael S. Zick
@ 2011-07-20 17:43   ` Peter Korsgaard
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Korsgaard @ 2011-07-20 17:43 UTC (permalink / raw)
  To: buildroot

>>>>> "Michael" == Michael S Zick <minimod@morethan.org> writes:


 Michael> Will the various shell aps run a script without /dev/console
 Michael> and /dev/null?

 Michael> Once upon a time, some did not, but that may no longer be true.

The busybox ones do atleast (I've tested it). I haven't tried with
/bin/sh == bash though, but that's probably fairly unlikely for an
initramfs.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [git commit] initramfs: fix boot with dynamic /dev
  2011-07-20 14:30 [Buildroot] [git commit] initramfs: fix boot with dynamic /dev Peter Korsgaard
  2011-07-20 16:12 ` Michael S. Zick
@ 2011-08-24  7:53 ` Arnout Vandecappelle
  2011-09-01  7:18   ` Thomas Petazzoni
  1 sibling, 1 reply; 6+ messages in thread
From: Arnout Vandecappelle @ 2011-08-24  7:53 UTC (permalink / raw)
  To: buildroot


On Wednesday 20 July 2011 16:30:14, Peter Korsgaard wrote:
> Devtmpfs (which is used by devtmpfs/mdev/udev options) doesn't get
> automounted by the kernel when an initramfs is used, causing boot
> failures when a dynamic /dev is used.

 [Reviving an old issue]

 I now switched to a cpio that I use as an initrd and of course I encounter 
the same issue...  So we can do the same thing for cpio archives.  Then I have 
two issues:

 - Are cpio archives used for something else than initrd?  In that case, we 
shouldn't use this /init.  OTOH, /init is never used if it's not an initrd so 
it shouldn't really make a difference.

 - Clearly this should be refactored so we don't duplicate the same stuff in 
initramfs.mk and cpio.mk.

 Given that /init is only used in initramfs situations, why don't we create it 
unconditionally as part of the .root skeleton?  OK, it adds 4K to the ext2fs 
but that shouldn't be the issue, right?


 Regards,
 Arnout
-- 
Arnout Vandecappelle                               arnout at mind be
Senior Embedded Software Architect                 +32-16-286540
Essensium/Mind                                     http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  31BB CF53 8660 6F88 345D  54CC A836 5879 20D7 CF43
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20110824/7aff7e70/attachment.html>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [git commit] initramfs: fix boot with dynamic /dev
  2011-08-24  7:53 ` Arnout Vandecappelle
@ 2011-09-01  7:18   ` Thomas Petazzoni
  2011-09-01 16:18     ` Arnout Vandecappelle
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Petazzoni @ 2011-09-01  7:18 UTC (permalink / raw)
  To: buildroot

Hello,

Le Wed, 24 Aug 2011 09:53:22 +0200,
Arnout Vandecappelle <arnout@mind.be> a ?crit :

>  I now switched to a cpio that I use as an initrd and of course I
> encounter the same issue...

Ah, yes, of course.

>  So we can do the same thing for cpio archives.  Then I have two
> issues:
> 
>  - Are cpio archives used for something else than initrd?

I don't think so. I would say that we can assume that cpio archives are
always used for initramfs.

>  - Clearly this should be refactored so we don't duplicate the same
> stuff in initramfs.mk and cpio.mk.

In fact I think the initramfs.mk and cpio.mk should be merged. Instead
of having initramfs.mk generating the "initramfs file list", we could
just have cpio.mk generate the cpio archive and then have the kernel
configuration tuned to include this cpio archive as an initramfs. I
haven't thought too much about the details of this but I remember we
already discussed this in the past and it's probably doable.

>  Given that /init is only used in initramfs situations, why don't we
> create it unconditionally as part of the .root skeleton?  OK, it adds
> 4K to the ext2fs but that shouldn't be the issue, right?

Well, I'd prefer to keep it for the initramfs situation only. Not
because of the size, just for the sake of cleanliness and clarity.

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [git commit] initramfs: fix boot with dynamic /dev
  2011-09-01  7:18   ` Thomas Petazzoni
@ 2011-09-01 16:18     ` Arnout Vandecappelle
  0 siblings, 0 replies; 6+ messages in thread
From: Arnout Vandecappelle @ 2011-09-01 16:18 UTC (permalink / raw)
  To: buildroot


On Thursday 01 September 2011 09:18:42, Thomas Petazzoni wrote:
> >  - Clearly this should be refactored so we don't duplicate the same
> >
> > stuff in initramfs.mk and cpio.mk.
> 
> In fact I think the initramfs.mk and cpio.mk should be merged. Instead
> of having initramfs.mk generating the "initramfs file list", we could
> just have cpio.mk generate the cpio archive and then have the kernel
> configuration tuned to include this cpio archive as an initramfs. I
> haven't thought too much about the details of this but I remember we
> already discussed this in the past and it's probably doable.

 That actually sounds simpler than the way it's done now :-)

 If I find the time, I'll take a look at it.


 Regards,
 Arnout

-- 
Arnout Vandecappelle                               arnout at mind be
Senior Embedded Software Architect                 +32-16-286540
Essensium/Mind                                     http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  31BB CF53 8660 6F88 345D  54CC A836 5879 20D7 CF43

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-09-01 16:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-20 14:30 [Buildroot] [git commit] initramfs: fix boot with dynamic /dev Peter Korsgaard
2011-07-20 16:12 ` Michael S. Zick
2011-07-20 17:43   ` Peter Korsgaard
2011-08-24  7:53 ` Arnout Vandecappelle
2011-09-01  7:18   ` Thomas Petazzoni
2011-09-01 16:18     ` Arnout Vandecappelle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox