cpio: fix boot with dynamic /dev
PATCH 1/2 cpio: fix boot with dynamic /dev
From: "Arnout Vandecappelle (Essensium/Mind)" <[email protected]>
Devtmpfs doesn't get automounted by the kernel when an initramfs is used. Since cpio archives are used almost exclusively as an initramfs, the same fix should be applied to it as for the initramfs.
Cfr. commit 424888e47431db738f5f9b3c6392435bfce7a842 and 10a130f91e5b947e2d2558443ff09b1686eac273.
--- fs/cpio/cpio.mk | 24 +++++++++++++++++++----- fs/cpio/init | 7 +++++++ 2 files changed, 26 insertions(+), 5 deletions(-) create mode 100755 fs/cpio/init
fs/cpio/cpio.mk +19 -5
@@ -4,15 +4,29 @@ # ############################################################# -define ROOTFS_CPIO_INIT_SYMLINK - rm -f $(TARGET_DIR)/init - ln -s sbin/init $(TARGET_DIR)/init +ifeq ($(BR2_ROOTFS_DEVICE_CREATION_STATIC),y) + +define ROOTFS_CPIO_ADD_INIT + if [ ! -e $(TARGET_DIR)/init ]; then \ + ln -sf sbin/init $(TARGET_DIR)/init; \ + fi +endef + +else +# devtmpfs does not get automounted when initramfs is used. +# Add a pre-init script to mount it before running init +define ROOTFS_CPIO_ADD_INIT + if [ ! -e $(TARGET_DIR)/init ]; then \ + $(INSTALL) -m 0755 fs/cpio/init $(TARGET_DIR)/init; \ + fi endef -ROOTFS_CPIO_PRE_GEN_HOOKS += ROOTFS_CPIO_INIT_SYMLINK +endif # BR2_ROOTFS_DEVICE_CREATION_STATIC + +ROOTFS_CPIO_PRE_GEN_HOOKS += ROOTFS_CPIO_ADD_INIT define ROOTFS_CPIO_CMD cd $(TARGET_DIR) && find . | cpio --quiet -o -H newc > $$@ endef -$(eval $(call ROOTFS_TARGET,cpio)) +$(eval $(call ROOTFS_TARGET,cpio))
fs/cpio/init new file +7 -0
@@ -0,0 +1,7 @@ +#!/bin/sh +# devtmpfs does not get automounted for initramfs +/bin/mount -t devtmpfs devtmpfs /dev +exec 0</dev/console +exec 1>/dev/console +exec 2>/dev/console +exec /sbin/init $*
Signature · 1 line
1.7.5.4
PATCH 2/2 fs/initramfs: refactor with fs/cpio
From: "Arnout Vandecappelle (Essensium/Mind)" <[email protected]>
An initramfs is in fact the same as a cpio archive, but embedded in the kernel. So instead of duplicating the cpio infrastructure, we can simply build images/rootfs.cpio and link that into the kernel.
--- fs/initramfs/Config.in | 13 ++- fs/initramfs/gen_initramfs_list.sh | 203 ------------------------------------ fs/initramfs/init | 7 -- fs/initramfs/initramfs.mk | 35 ++---- linux/linux.mk | 17 ++-- 5 files changed, 25 insertions(+), 250 deletions(-) delete mode 100644 fs/initramfs/gen_initramfs_list.sh delete mode 100755 fs/initramfs/init
fs/initramfs/Config.in +7 -6
@@ -1,20 +1,21 @@ config BR2_TARGET_ROOTFS_INITRAMFS bool "initramfs for initial ramdisk of linux kernel" depends on BR2_LINUX_KERNEL + select BR2_TARGET_ROOTFS_CPIO help Integrate the root filesystem generated by Buildroot as an initramfs inside the kernel image. This integration will take place automatically. - The rootfs.initramfs file generated in the images/ directory - is only a text file describing the contents of the initramfs - in a format understood by the CONFIG_INITRAMFS_SOURCE kernel - configuration option. + A rootfs.cpio file will be generated in the images/ directory. + This is the archive that will be included in the kernel image. + The rootfs in the kernel will always be gzip'ed, regardless + of how buildroot's cpio archive is configured. - Note that enabling initramfs together with other filesystem + Note that enabling initramfs together with another filesystem formats doesn't make sense: you would end up having two identical root filesystems, one embedded inside the kernel - image, and one separatly. + image, and one separately. comment "initramfs requires a Linux kernel to be built" depends on !BR2_LINUX_KERNEL
fs/initramfs/gen_initramfs_list.sh deleted +0 -203
203 lines not on this page · raw message
fs/initramfs/init deleted +0 -7
@@ -1,7 +0,0 @@ -#!/bin/sh -# devtmpfs does not get automounted for initramfs -/bin/mount -t devtmpfs devtmpfs /dev -exec 0</dev/console -exec 1>/dev/console -exec 2>/dev/console -exec /sbin/init $*
fs/initramfs/initramfs.mk +11 -24
@@ -1,36 +1,23 @@ ############################################################# # -# Make a initramfs_list file to be used by gen_init_cpio -# gen_init_cpio is part of the 2.6 linux kernels to build an -# initial ramdisk filesystem based on cpio +# Build a kernel with an integrated initial ramdisk +# filesystem based on cpio. # ############################################################# -ifeq ($(BR2_ROOTFS_DEVICE_CREATION_STATIC),y) +ROOTFS_INITRAMFS_DEPENDENCIES += rootfs-cpio -define ROOTFS_INITRAMFS_ADD_INIT - if [ ! -e $(TARGET_DIR)/init ]; then \ - ln -sf sbin/init $(TARGET_DIR)/init; \ - fi -endef +ROOTFS_INITRAMFS_POST_TARGETS += linux26-rebuild-with-initramfs -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 +# The generic fs infrastructure isn't very useful here. -ROOTFS_INITRAMFS_PRE_GEN_HOOKS += ROOTFS_INITRAMFS_ADD_INIT +rootfs-initramfs: $(ROOTFS_INITRAMFS_DEPENDENCIES) $(ROOTFS_INITRAMFS_POST_TARGETS) -define ROOTFS_INITRAMFS_CMD - $(SHELL) fs/initramfs/gen_initramfs_list.sh -u 0 -g 0 $(TARGET_DIR) > $$@ -endef +rootfs-initramfs-show-depends: + @echo $(ROOTFS_INITRAMFS_DEPENDENCIES) -ROOTFS_INITRAMFS_POST_TARGETS += linux26-rebuild-with-initramfs +ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y) +TARGETS += rootfs-initramfs +endif -$(eval $(call ROOTFS_TARGET,initramfs))
linux/linux.mk +7 -10
@@ -126,13 +126,13 @@ define LINUX_CONFIGURE_CMDS $(call KCONFIG_ENABLE_OPT,CONFIG_AEABI,$(@D)/.config), $(call KCONFIG_DISABLE_OPT,CONFIG_AEABI,$(@D)/.config)) # As the kernel gets compiled before root filesystems are - # built, we create a fake initramfs file list. It'll be - # replaced later by the real list, and the kernel will be + # built, we create a fake cpio file. It'll be + # replaced later by the real cpio archive, and the kernel will be # rebuilt using the linux26-rebuild-with-initramfs target. $(if $(BR2_TARGET_ROOTFS_INITRAMFS), - touch $(BINARIES_DIR)/rootfs.initramfs + touch $(BINARIES_DIR)/rootfs.cpio $(call KCONFIG_ENABLE_OPT,CONFIG_BLK_DEV_INITRD,$(@D)/.config) - $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,\"$(BINARIES_DIR)/rootfs.initramfs\",$(@D)/.config) + $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,\"$(BINARIES_DIR)/rootfs.cpio\",$(@D)/.config) $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_UID,0,$(@D)/.config) $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_GID,0,$(@D)/.config) $(call KCONFIG_DISABLE_OPT,CONFIG_INITRAMFS_COMPRESSION_NONE,$(@D)/.config)
@@ -184,13 +184,10 @@ linux-menuconfig linux-xconfig linux-gconfig linux-nconfig linux26-menuconfig li $(subst linux-,,$(subst linux26-,,$@)) rm -f $(LINUX_DIR)/.stamp_{built,target_installed,images_installed} -# Support for rebuilding the kernel after the initramfs file list has -# been generated in $(BINARIES_DIR)/rootfs.initramfs. -$(LINUX_DIR)/.stamp_initramfs_rebuilt: $(LINUX_DIR)/.stamp_target_installed $(LINUX_DIR)/.stamp_images_installed $(BINARIES_DIR)/rootfs.initramfs +# Support for rebuilding the kernel after the cpio archive has +# been generated in $(BINARIES_DIR)/rootfs.cpio. +$(LINUX_DIR)/.stamp_initramfs_rebuilt: $(LINUX_DIR)/.stamp_target_installed $(LINUX_DIR)/.stamp_images_installed $(BINARIES_DIR)/rootfs.cpio @$(call MESSAGE,"Rebuilding kernel with initramfs") - # Remove the previously generated initramfs which was empty, - # to make sure the kernel will actually regenerate it. - $(RM) -f $(@D)/usr/initramfs_data.cpio* # Build the kernel. $(TARGET_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_IMAGE_NAME) # Copy the kernel image to its final destination
Signature · 1 line
1.7.5.4
PATCH 2/2 fs/initramfs: refactor with fs/cpio
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Arnout" == Arnout Vandecappelle (Essensium/Mind) <[email protected]> writes:
Arnout> From: "Arnout Vandecappelle (Essensium/Mind)" <[email protected]> Arnout> An initramfs is in fact the same as a cpio archive, but embedded in Arnout> the kernel. So instead of duplicating the cpio infrastructure, Arnout> we can simply build images/rootfs.cpio and link that into the Arnout> kernel.
Committed, thanks.
Signature · 1 line
Bye, Peter Korsgaard
PATCH 2/2 fs/initramfs: refactor with fs/cpio
In reply to Arnout Vandecappelle (Essensium/Mind)Hi Arnout,
Quoted 310 lines · Arnout Vandecappelle (Essensium/Mind)
From: "Arnout Vandecappelle (Essensium/Mind)" <[email protected]>
An initramfs is in fact the same as a cpio archive, but embedded in the kernel. ?So instead of duplicating the cpio infrastructure, we can simply build images/rootfs.cpio and link that into the kernel.
---?fs/initramfs/Config.in ? ? ? ? ? ? | ? 13 ++- ?fs/initramfs/gen_initramfs_list.sh | ?203 ------------------------------------ ?fs/initramfs/init ? ? ? ? ? ? ? ? ?| ? ?7 -- ?fs/initramfs/initramfs.mk ? ? ? ? ?| ? 35 ++---- ?linux/linux.mk ? ? ? ? ? ? ? ? ? ? | ? 17 ++--?5 files changed, 25 insertions(+), 250 deletions(-) ?delete mode 100644
fs/initramfs/gen_initramfs_list.sh?delete mode 100755fs/initramfs/initfs/initramfs/Config.in +0
-0@@ -1,20 +1,21 @@?config
BR2_TARGET_ROOTFS_INITRAMFS
? ? ? ?bool "initramfs for initial ramdisk of linux kernel" ? ? ? ?depends onBR2_LINUX_KERNEL
+ ? ? ? selectBR2_TARGET_ROOTFS_CPIO
? ? ? ?help
? ? ? ? ?Integrate the root filesystem generated by Buildroot as an ? ? ? ? ?initramfs inside the kernel image. This integration will ? ? ? ? ?take place automatically.- ? ? ? ? The rootfs.initramfs file generated in the images/ directory
- ? ? ? ? is only a text file describing the contents of the initramfs
- ? ? ? ? in a format understood by theCONFIG_INITRAMFS_SOURCEkernel
- ? ? ? ? configuration option.
+ ? ? ? ? A rootfs.cpio file will be generated in the images/ directory.
+ ? ? ? ? This is the archive that will be included in the kernel image.
+ ? ? ? ? The rootfs in the kernel will always be gzip'ed, regardless
+ ? ? ? ? of how buildroot's cpio archive is configured.- ? ? ? ? Note that enabling initramfs together with other filesystem
+ ? ? ? ? Note that enabling initramfs together with another filesystem ? ? ? ? ?formats doesn't make sense: you would end up having two ? ? ? ? ?identical root filesystems, one embedded inside the kernel
- ? ? ? ? image, and one separatly.
+ ? ? ? ? image, and one separately.?comment "initramfs requires a Linux kernel to be built" ? ? ? ?depends on !BR2_LINUX_KERNEL
fs/initramfs/gen_initramfs_list.sh deleted +0
-203@@ -1,203 +0,0 @@ -#!/bin/sh -# Copyright (C) Martin Schlemmer <[email protected]> -# Released under the terms of the GNU GPL -# -# Generate a newline separated list of entries from the file/directory -# supplied as an argument. -# -# If a file/directory is not supplied then generate a small dummy file. -# -# The output is suitable for gen_init_cpio built from usr/gen_init_cpio.c. -# - -default_initramfs() { - ? ? ? cat <<-EOF - ? ? ? ? ? ? ? # This is a very simple, default initramfs - - ? ? ? ? ? ? ? dir /dev 0755 0 0 - ? ? ? ? ? ? ? nod /dev/console 0600 0 0 c 5 1 - ? ? ? ? ? ? ? dir /root 0700 0 0 - ? ? ? EOF -} - -filetype() { - ? ? ? local argv1="$1" - - ? ? ? # symlink test must come before file test - ? ? ? if [ -L "$argv1" ]; then - ? ? ? ? ? ? ? echo "slink" - ? ? ? elif [ -f "$argv1" ]; then - ? ? ? ? ? ? ? echo "file" - ? ? ? elif [ -d "$argv1" ]; then - ? ? ? ? ? ? ? echo "dir" - ? ? ? elif [ -b "$argv1" -o -c "$argv1" ]; then - ? ? ? ? ? ? ? echo "nod" - ? ? ? elif [ -p "$argv1" ]; then - ? ? ? ? ? ? ? echo "pipe" - ? ? ? elif [ -S "$argv1" ]; then - ? ? ? ? ? ? ? echo "sock" - ? ? ? else - ? ? ? ? ? ? ? echo "invalid" - ? ? ? fi - ? ? ? return 0 -} - -print_mtime() { - ? ? ? local argv1="$1" - ? ? ? local mymtime="0" - - ? ? ? if [ -e "$argv1" ]; then - ? ? ? ? ? ? ? mymtime=$(find "$argv1" -printf "%T@\n" | sort -r | head -n 1) - ? ? ? fi - - ? ? ? echo "# Last modified: $mymtime" - ? ? ? echo -} - -parse() { - ? ? ? local location="$1" - ? ? ? local name=$(echo "$location" | sed -e "s,$srcdir,,") - ? ? ? # change '//' into '/' - ? ? ? name=$(echo $name | sed -e 's,/[/]*,/,g') - ? ? ? local mode="$2" - ? ? ? local uid="$3" - ? ? ? local gid="$4" - ? ? ? local ftype=$(filetype "$location") - ? ? ? # remap uid/gid to 0 if necessary - ? ? ? [ "x$uid" != "x" ] && [ $uid -eq $root_uid ] && uid=0 - ? ? ? [ "x$gid" != "x" ] && [ $gid -eq $root_gid ] && gid=0 - ? ? ? local str="$mode $uid $gid" - - ? ? ? [ "$ftype" = "invalid" ] && return 0 - ? ? ? [ "$location" = "$srcdir" ] && return 0 - - ? ? ? case "$ftype" in - ? ? ? ? ? ? ? "file") - ? ? ? ? ? ? ? ? ? ? ? str="$ftype $name $location $str" - ? ? ? ? ? ? ? ? ? ? ? ;; - ? ? ? ? ? ? ? "nod") - ? ? ? ? ? ? ? ? ? ? ? local devtype= - ? ? ? ? ? ? ? ? ? ? ? local maj=$(LC_ALL=C ls -l "$location" | \ - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? awk '{sub(/,/, "", $5); print $5}') - ? ? ? ? ? ? ? ? ? ? ? local min=$(LC_ALL=C ls -l "$location" | \ - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? awk '{print $6}') - - ? ? ? ? ? ? ? ? ? ? ? if [ -b "$location" ]; then - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? devtype="b" - ? ? ? ? ? ? ? ? ? ? ? else - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? devtype="c" - ? ? ? ? ? ? ? ? ? ? ? fi - ? ? ? ? ? ? ? ? ? ? ? str="$ftype $name $str $devtype $maj $min" - ? ? ? ? ? ? ? ? ? ? ? ;; - ? ? ? ? ? ? ? "slink") - ? ? ? ? ? ? ? ? ? ? ? local target=$(LC_ALL=C ls -l "$location" | \ - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? awk '{print $11}') - ? ? ? ? ? ? ? ? ? ? ? str="$ftype $name $target $str" - ? ? ? ? ? ? ? ? ? ? ? ;; - ? ? ? ? ? ? ? *) - ? ? ? ? ? ? ? ? ? ? ? str="$ftype $name $str" - ? ? ? ? ? ? ? ? ? ? ? ;; - ? ? ? esac - - ? ? ? echo "$str" - - ? ? ? return 0 -} - -usage() { - ? ? ? printf ? ?"Usage:\n" - ? ? ? printf ? ?"$0 [ [-u <root_uid>] [-g <root_gid>] [-d | <cpio_source>] ] . . .\n" - ? ? ? printf ? ?"\n" - ? ? ? printf -- "-u <root_uid> ?User ID to map to user ID 0 (root).\n" - ? ? ? printf ? ?" ? ? ? ? ? ? ? <root_uid> is only meaningful if <cpio_source>\n" - ? ? ? printf ? ?" ? ? ? ? ? ? ? is a directory.\n" - ? ? ? printf -- "-g <root_gid> ?Group ID to map to group ID 0 (root).\n" - ? ? ? printf ? ?" ? ? ? ? ? ? ? <root_gid> is only meaningful if <cpio_source>\n" - ? ? ? printf ? ?" ? ? ? ? ? ? ? is a directory.\n" - ? ? ? printf ? ?"<cpio_source> ?File list or directory for cpio archive.\n" - ? ? ? printf ? ?" ? ? ? ? ? ? ? If <cpio_source> is not provided then a\n" - ? ? ? printf ? ?" ? ? ? ? ? ? ? a default list will be output.\n" - ? ? ? printf -- "-d ? ? ? ? ? ? Output the default cpio list. ?If no <cpio_source>\n" - ? ? ? printf ? ?" ? ? ? ? ? ? ? is given then the default cpio list will be output.\n" - ? ? ? printf ? ?"\n" - ? ? ? printf ? ?"All options may be repeated and are interpreted sequentially\n" - ? ? ? printf ? ?"and immediately. ?-u and -g states are preserved across\n" - ? ? ? printf ? ?"<cpio_source> options so an explicit \"-u 0 -g 0\" is required\n" - ? ? ? printf ? ?"to reset the root/group mapping.\n" -} - -build_list() { - ? ? ? printf "\n#####################\n# $cpio_source\n" - - ? ? ? if [ -f "$cpio_source" ]; then - ? ? ? ? ? ? ? print_mtime "$cpio_source" - ? ? ? ? ? ? ? cat "$cpio_source" - ? ? ? elif [ -d "$cpio_source" ]; then - ? ? ? ? ? ? ? srcdir=$(echo "$cpio_source" | sed -e 's://*:/:g;s:/$::') - ? ? ? ? ? ? ? dirlist=$(find "$srcdir" -printf "%p %m %U %G\n" 2>/dev/null) - - ? ? ? ? ? ? ? # If $dirlist is only one line, then the directory is empty - ? ? ? ? ? ? ? if [ ?"$(echo "$dirlist" | wc -l)" -gt 1 ]; then - ? ? ? ? ? ? ? ? ? ? ? print_mtime "$cpio_source" - - ? ? ? ? ? ? ? ? ? ? ? echo "$dirlist" | \ - ? ? ? ? ? ? ? ? ? ? ? while read x; do - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? parse $x - ? ? ? ? ? ? ? ? ? ? ? done - ? ? ? ? ? ? ? else - ? ? ? ? ? ? ? ? ? ? ? # Failsafe in case directory is empty - ? ? ? ? ? ? ? ? ? ? ? default_initramfs - ? ? ? ? ? ? ? fi - ? ? ? else - ? ? ? ? ? ? ? echo " ?$0: Cannot open '$cpio_source'" >&2 - ? ? ? ? ? ? ? exit 1 - ? ? ? fi -} - - -root_uid=0 -root_gid=0 - -while [ $# -gt 0 ]; do - ? ? ? arg="$1" - ? ? ? shift - ? ? ? case "$arg" in - ? ? ? ? ? ? ? "-u") - ? ? ? ? ? ? ? ? ? ? ? root_uid="$1" - ? ? ? ? ? ? ? ? ? ? ? shift - ? ? ? ? ? ? ? ? ? ? ? ;; - ? ? ? ? ? ? ? "-g") - ? ? ? ? ? ? ? ? ? ? ? root_gid="$1" - ? ? ? ? ? ? ? ? ? ? ? shift - ? ? ? ? ? ? ? ? ? ? ? ;; - ? ? ? ? ? ? ? "-d") - ? ? ? ? ? ? ? ? ? ? ? default_list="$arg" - ? ? ? ? ? ? ? ? ? ? ? default_initramfs - ? ? ? ? ? ? ? ? ? ? ? ;; - ? ? ? ? ? ? ? "-h") - ? ? ? ? ? ? ? ? ? ? ? usage - ? ? ? ? ? ? ? ? ? ? ? exit 0 - ? ? ? ? ? ? ? ? ? ? ? ;; - ? ? ? ? ? ? ? *) - ? ? ? ? ? ? ? ? ? ? ? case "$arg" in - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "-"*) - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? printf "ERROR: unknown option \"$arg\"\n" >&2 - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? printf "If the filename validly begins with '-', then it must be prefixed\n" >&2 - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? printf "by './' so that it won't be interpreted as an option." >&2 - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? printf "\n" >&2 - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? usage >&2 - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? exit 1 - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ;; - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *) - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? cpio_source="$arg" - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? build_list - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ;; - ? ? ? ? ? ? ? ? ? ? ? esac - ? ? ? ? ? ? ? ? ? ? ? ;; - ? ? ? esac -done - -# spit out the default cpio list if a source hasn't been specified -[ -z "$cpio_source" -a -z "$default_list" ] && default_initramfs - -exit 0fs/initramfs/init deleted +0
-7@@ -1,7 +0,0 @@ -#!/bin/sh -# devtmpfs does not get automounted for initramfs -/bin/mount -t devtmpfs devtmpfs /dev -exec 0</dev/console -exec 1>/dev/console -exec 2>/dev/console -exec /sbin/init $*fs/initramfs/initramfs.mk +0
-0@@ -1,36 +1,23 @@?############################################################# ?#
fs/initramfs/initramfs.mk +2
-3-# Make a initramfs_list file to be used by gen_init_cpio -# gen_init_cpio is part of the 2.6 linux kernels to build an -# initial ramdisk filesystem based on cpio +# Build a kernel with an integrated initial ramdisk +# filesystem based on cpio.?# ?#############################################################
fs/initramfs/initramfs.mk +4
-16-ifeq ($(BR2_ROOTFS_DEVICE_CREATION_STATIC),y) +ROOTFS_INITRAMFS_DEPENDENCIES += rootfs-cpio -define ROOTFS_INITRAMFS_ADD_INIT - ? ? ? if [ ! -e $(TARGET_DIR)/init ]; then \ - ? ? ? ? ? ? ? ln -sf sbin/init $(TARGET_DIR)/init; \ - ? ? ? fi -endef +ROOTFS_INITRAMFS_POST_TARGETS += linux26-rebuild-with-initramfs -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 +# The generic fs infrastructure isn't very useful here. -ROOTFS_INITRAMFS_PRE_GEN_HOOKS += ROOTFS_INITRAMFS_ADD_INIT +rootfs-initramfs: $(ROOTFS_INITRAMFS_DEPENDENCIES) $(ROOTFS_INITRAMFS_POST_TARGETS)
fs/initramfs/initramfs.mk line 22
Quoted 10 lines
fs/initramfs/initramfs.mk +5
-4-define ROOTFS_INITRAMFS_CMD - ? ? ? $(SHELL) fs/initramfs/gen_initramfs_list.sh -u 0 -g 0 $(TARGET_DIR) > $$@ -endef +rootfs-initramfs-show-depends: + ? ? ? @echo $(ROOTFS_INITRAMFS_DEPENDENCIES) -ROOTFS_INITRAMFS_POST_TARGETS += linux26-rebuild-with-initramfs +ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y) +TARGETS += rootfs-initramfs +endif
After my upstep to buildroot-2012.02, I am experiencing problems with the kernel:
[ 0.053620] Kernel panic - not syncing: junk in compressed archive <=== [ 0.126574] Call Trace: [ 0.155738] [ec057f00] [c0006fe4] show_stack+0x78/0x18c (unreliable) [ 0.231769] [ec057f40] [c02f0db4] panic+0xc0/0x1e8 [ 0.289055] [ec057f90] [c03c4370] populate_rootfs+0x34/0xc8 [ 0.355714] [ec057fa0] [c0001cc0] do_one_initcall+0xf4/0x1ec [ 0.423418] [ec057fd0] [c03c2388] kernel_init+0x194/0x24c [ 0.488000] [ec057ff0] [c000dcd0] kernel_thread+0x4c/0x68 [ 0.552583] Rebooting in 5 seconds..
We are not putting the rootfs inside the kernel image, but next to it. The kernel is notified of the location of this image using the device tree.
Looking@the changes you did above, I'm a bit confused about when the target linux26-rebuild-with-initramfs is supposed to be built. In my case, BR2_TARGET_ROOTFS_INITRAMFS is not set (BR2_TARGET_ROOTFS_CPIO is), so the TARGETS variable does not contain target 'rootfs-initramfs'. This means the variable ROOTFS_INITRAMFS_POST_TARGETS is never considered.
Is this expected behavior?
I cannot yet prove that this patch caused the behavior I'm seeing (I'm currently investigating this further), but it would be nice to get some feedback already.
Thanks,
Thomas
Quoted 48 lines
-$(eval $(call ROOTFS_TARGET,initramfs))
linux/linux.mk +0
-0@@ -126,13 +126,13 @@ define LINUX_CONFIGURE_CMDS ? ? ? ? ? ? ? ?$(call KCONFIG_ENABLE_OPT,CONFIG_AEABI,$(@D)/.config), ? ? ? ? ? ? ? ?$(call KCONFIG_DISABLE_OPT,CONFIG_AEABI,$(@D)/.config))? ? ? ?# As the kernel gets compiled before root filesystems are
- ? ? ? # built, we create a fake initramfs file list. It'll be
- ? ? ? # replaced later by the real list, and the kernel will be
+ ? ? ? # built, we create a fake cpio file. It'll be
+ ? ? ? # replaced later by the real cpio archive, and the kernel will be
? ? ? ?# rebuilt using the linux26-rebuild-with-initramfs target.
? ? ? ?$(if $(BR2_TARGET_ROOTFS_INITRAMFS),
- ? ? ? ? ? ? ? touch $(BINARIES_DIR)/rootfs.initramfs
+ ? ? ? ? ? ? ? touch $(BINARIES_DIR)/rootfs.cpio
? ? ? ? ? ? ? ?$(call KCONFIG_ENABLE_OPT,CONFIG_BLK_DEV_INITRD,$(@D)/.config)
- ? ? ? ? ? ? ? $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,\"$(BINARIES_DIR)/rootfs.initramfs\",$(@D)/.config)
+ ? ? ? ? ? ? ? $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,\"$(BINARIES_DIR)/rootfs.cpio\",$(@D)/.config) ? ? ? ? ? ? ? ?$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_UID,0,$(@D)/.config)
? ? ? ? ? ? ? ?$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_GID,0,$(@D)/.config)
? ? ? ? ? ? ? ?$(call KCONFIG_DISABLE_OPT,CONFIG_INITRAMFS_COMPRESSION_NONE,$(@D)/.config)linux/linux.mk +3
-6@@ -184,13 +184,10 @@ linux-menuconfig linux-xconfig linux-gconfig linux-nconfig linux26-menuconfig li ? ? ? ? ? ? ? ?$(subst linux-,,$(subst linux26-,,$@)) ? ? ? ?rm -f $(LINUX_DIR)/.stamp_{built,target_installed,images_installed} -# Support for rebuilding the kernel after the initramfs file list has -# been generated in $(BINARIES_DIR)/rootfs.initramfs. -$(LINUX_DIR)/.stamp_initramfs_rebuilt: $(LINUX_DIR)/.stamp_target_installed $(LINUX_DIR)/.stamp_images_installed $(BINARIES_DIR)/rootfs.initramfs +# Support for rebuilding the kernel after the cpio archive has +# been generated in $(BINARIES_DIR)/rootfs.cpio. +$(LINUX_DIR)/.stamp_initramfs_rebuilt: $(LINUX_DIR)/.stamp_target_installed $(LINUX_DIR)/.stamp_images_installed $(BINARIES_DIR)/rootfs.cpio ? ? ? ?@$(call MESSAGE,"Rebuilding kernel with initramfs") - ? ? ? # Remove the previously generated initramfs which was empty, - ? ? ? # to make sure the kernel will actually regenerate it. - ? ? ? $(RM) -f $(@D)/usr/initramfs_data.cpio*? ? ? ?# Build the kernel.
? ? ? ?$(TARGET_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_IMAGE_NAME) ? ? ? ?# Copy the kernel image to its final destination
--
1.7.5.4_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
PATCH 2/2 fs/initramfs: refactor with fs/cpio
Quoted 4 lines · On Tuesday 13 March 2012 16:49:08 Thomas De Schampheleire wrote:
After my upstep to buildroot-2012.02, I am experiencing problems with the kernel:
[ 0.053620] Kernel panic - not syncing: junk in compressed archive <===
Looks like your cpio archive is compressed with an algorithm that is
not recognized by your kernel configuration... Can you check:
- that the generated rootfs.cpio.* is a valid compressed archive; and
- that the compression algorithm is configured in the kernel.
Quoted 14 lines
[ 0.126574] Call Trace: [ 0.155738] [ec057f00] [c0006fe4] show_stack+0x78/0x18c (unreliable) [ 0.231769] [ec057f40] [c02f0db4] panic+0xc0/0x1e8 [ 0.289055] [ec057f90] [c03c4370] populate_rootfs+0x34/0xc8 [ 0.355714] [ec057fa0] [c0001cc0] do_one_initcall+0xf4/0x1ec [ 0.423418] [ec057fd0] [c03c2388] kernel_init+0x194/0x24c [ 0.488000] [ec057ff0] [c000dcd0] kernel_thread+0x4c/0x68 [ 0.552583] Rebooting in 5 seconds..We are not putting the rootfs inside the kernel image, but next to it. The kernel is notified of the location of this image using the device tree.
Quoted 6 lines
Looking at the changes you did above, I'm a bit confused about when the target linux26-rebuild-with-initramfs is supposed to be built. In my case,
BR2_TARGET_ROOTFS_INITRAMFSis not set (BR2_TARGET_ROOTFS_CPIOis), so the TARGETS variable does not contain target 'rootfs-initramfs'. This means the variableROOTFS_INITRAMFS_POST_TARGETSis never considered.
If you're using an initramfs that is not linked into the kernel, then
you're not using the BR2_TARGET_ROOTFS_INITRAMFS infrastructure, so you shouldn't be affected by this patch.
linux26-rebuild-with-initramfs is only needed to create a kernel with
the embedded initramfs.
Quoted 5 lines
Is this expected behavior?
I cannot yet prove that this patch caused the behavior I'm seeing (I'm currently investigating this further), but it would be nice to get some feedback already.
This patch should be relatively easy to revert, no?
Regards,
Arnout
Signature · 9 lines
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: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20120313/acecf578/attachment-0001.html>
PATCH 2/2 fs/initramfs: refactor with fs/cpio
Hi,
Quoted 80 lines · Arnout Vandecappelle
Quoted 8 lines · On Tuesday 13 March 2012 16:49:08 Thomas De Schampheleire wrote:
After my upstep to buildroot-2012.02, I am experiencing problems with
the kernel:
[????0.053620] Kernel panic - not syncing: junk in compressed archive??<===
Looks like your cpio archive is compressed with an algorithm that is
not recognized by your kernel configuration... Can you check:
- that the generated rootfs.cpio.* is a valid compressed archive; and
- that the compression algorithm is configured in the kernel.
Quoted 32 lines
[????0.126574] Call Trace:
[????0.155738] [
ec057f00] [c0006fe4]show_stack+0x78/0x18c(unreliable)[????0.231769] [
ec057f40] [c02f0db4]panic+0xc0/0x1e8[????0.289055] [
ec057f90] [c03c4370]populate_rootfs+0x34/0xc8[????0.355714] [
ec057fa0] [c0001cc0]do_one_initcall+0xf4/0x1ec[????0.423418] [
ec057fd0] [c03c2388]kernel_init+0x194/0x24c[????0.488000] [
ec057ff0] [c000dcd0]kernel_thread+0x4c/0x68[????0.552583] Rebooting in 5 seconds..
We are not putting the rootfs inside the kernel image, but next to it.
The kernel is notified of the location of this image using the device
tree.
Looking at the changes you did above, I'm a bit confused about when
the target linux26-rebuild-with-initramfs is supposed to be built. In
Quoted 7 lines
my case,
BR2_TARGET_ROOTFS_INITRAMFSis not set(
BR2_TARGET_ROOTFS_CPIOis), so the TARGETS variable does not containtarget 'rootfs-initramfs'. This means the variable
ROOTFS_INITRAMFS_POST_TARGETSis never considered.If you're using an initramfs that is not linked into the kernel, then
you're not using the
BR2_TARGET_ROOTFS_INITRAMFSinfrastructure, so youshouldn't be affected by this patch.
linux26-rebuild-with-initramfs is only needed to create a kernel with
the embedded initramfs.
Quoted 3 lines
Is this expected behavior?
Quoted 8 lines
Quoted 5 lines
I cannot yet prove that this patch caused the behavior I'm seeing (I'm
currently investigating this further), but it would be nice to get
some feedback already.
This patch should be relatively easy to revert, no?
So, I figured it out. In the end, it was your patch that triggered my problem, but only indirectly. I don't think the patch is at fault.
linux/linux.mk contains:
$(if $(BR2_TARGET_ROOTFS_INITRAMFS),
touch $(BINARIES_DIR)/rootfs.cpio
$(call KCONFIG_ENABLE_OPT,CONFIG_BLK_DEV_INITRD,$(@D)/.config)
$(call
KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,\"$(BINARIES_DIR)/rootfs.cpio\",$(@D)/.config)
...This means that this code will be executed, even if BR2_TARGET_ROOTFS_INITRAMFS is explicitly set to 'n'. This may not be a common case, but I think it is valid to do so (I do so).
This is in fact the real problem, according to me. If I change the code to:
$(if $(filter y,$(BR2_TARGET_ROOTFS_INITRAMFS)),
touch $(BINARIES_DIR)/rootfs.cpio
$(call KCONFIG_ENABLE_OPT,CONFIG_BLK_DEV_INITRD,$(@D)/.config)
$(call
KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,\"$(BINARIES_DIR)/rootfs.cpio\",$(@D)/.config)
...Then everything is fine.
But even without Arnout's patch, this check was there. So why did it work for me?
Both the original code as the modified one make an empty file, either rootfs.initramfs or rootfs.cpio. This empty file is passed to the Linux kernel to create its internal initramfs.
The difference is that the scripts/gen_initramfs_list.sh will look at the filename to determine whether the input is an initramfs list or a cpio one. If it's not cpio, it will assume a file containing filenames. An empty file does not contain filenames, so the initramfs is empty. If it's a file containing .cpio, it will assume that it's a real cpio archive, which is not correct. The resulting initramfs will be corrupt.
I will send a patch to update the linux/linux.mk file to take into account =n properly.
Best regards,
Thomas
PATCH 2/2 fs/initramfs: refactor with fs/cpio
Quoted 11 lines · On Wednesday 14 March 2012 15:19:33 Thomas De Schampheleire wrote:
linux/linux.mkcontains:$(if $(BR2_TARGET_ROOTFS_INITRAMFS), touch $(BINARIES_DIR)/rootfs.cpio $(call KCONFIG_ENABLE_OPT,CONFIG_BLK_DEV_INITRD,$(@D)/.config) $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,\"$(BINARIES_DIR)/rootfs.cpio\",$(@D)/.config) ...This means that this code will be executed, even if
BR2_TARGET_ROOTFS_INITRAMFSis explicitly set to 'n'. This may not be a common case, but I think it is valid to do so (I do so).
I don't think it is valid to do so. There are many places where we
expect Kconfig booleans to be either unquoted 'y' or nothing. If you do need to override a config variable (in local.mk or on the command line), BR2_FOO= works well enough.
Regards,
Arnout
Signature · 6 lines
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: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
PATCH 1/2 cpio: fix boot with dynamic /dev
In reply to Arnout Vandecappelle (Essensium/Mind)Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Arnout" == Arnout Vandecappelle (Essensium/Mind) <[email protected]> writes:
Arnout> From: "Arnout Vandecappelle (Essensium/Mind)" <[email protected]>
Arnout> Devtmpfs doesn't get automounted by the kernel when an Arnout> initramfs is used. Since cpio archives are used almost Arnout> exclusively as an initramfs, the same fix should be applied to Arnout> it as for the initramfs.
Committed, thanks.
Signature · 1 line
Bye, Peter Korsgaard