I have been using "exec switch_root /mnt/new_root /sbin/init" from an initramfs successfully with hush / busybox 1.15.3 and earlier versions. But this command stopped working when I upgraded to 1.16.0 today... sh: can't execute 'switch_root': No such file or directory Kernel panic - not syncing: Attempted to kill init! Simple workarounds are to use ash instead of hush or not to use the standalone shell mode. This issue was introduced with the following commit: http://git.busybox.net/busybox/commit/?id=3ef4f77620a9f5f9a7c1247e29ea9c14e07b8a30 Steps to reproduce: * Compile latest busybox using... CONFIG_HUSH=y CONFIG_FEATURE_SH_STANDALONE=y CONFIG_INSTALL_APPLET_DONT=y * start hush and exec an applet, e.g. hush itself... $ busybox hush -c 'exec hush' hush: can't execute 'hush': No such file or directory The expected result is the same result as with either of these: $ busybox hush -c 'exec busybox hush' $ busybox ash -c 'exec hush'
You also need CONFIG_FEATURE_PREFER_APPLETS=y With the following config: # grep ^CON .config CONFIG_HAVE_DOT_CONFIG=y CONFIG_INCLUDE_SUSv2=y CONFIG_FEATURE_BUFFERS_USE_MALLOC=y CONFIG_SHOW_USAGE=y CONFIG_FEATURE_COMPRESS_USAGE=y CONFIG_SUBST_WCHAR=0 CONFIG_LAST_SUPPORTED_WCHAR=0 CONFIG_LONG_OPTS=y CONFIG_FEATURE_DEVPTS=y CONFIG_FEATURE_PREFER_APPLETS=y CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe" CONFIG_CROSS_COMPILER_PREFIX="" CONFIG_EXTRA_CFLAGS="" CONFIG_NO_DEBUG_LIB=y CONFIG_INSTALL_APPLET_SYMLINKS=y CONFIG_PREFIX="./_install" CONFIG_PASSWORD_MINLEN=6 CONFIG_MD5_SIZE_VS_SPEED=2 CONFIG_FEATURE_EDITING_MAX_LEN=0 CONFIG_FEATURE_EDITING_HISTORY=0 CONFIG_FEATURE_NON_POSIX_CP=y CONFIG_FEATURE_COPYBUF_KB=4 CONFIG_MONOTONIC_SYSCALL=y CONFIG_IOCTL_HEX2STR_ERROR=y CONFIG_FEATURE_HWIB=y CONFIG_ECHO=y CONFIG_FEATURE_FANCY_ECHO=y CONFIG_DEFAULT_SETFONT_DIR="" CONFIG_FEATURE_VI_MAX_LEN=0 CONFIG_FEATURE_KILL_DELAY=0 CONFIG_TELINIT_PATH="" CONFIG_USE_BB_CRYPT=y CONFIG_FIRST_SYSTEM_ID=0 CONFIG_LAST_SYSTEM_ID=0 CONFIG_DEFAULT_MODULES_DIR="" CONFIG_DEFAULT_DEPMOD_FILE="" CONFIG_FSCK_MINIX=y CONFIG_FEATURE_MINIX2=y CONFIG_FEATURE_BEEP_FREQ=0 CONFIG_FEATURE_BEEP_LENGTH_MS=0 CONFIG_FEATURE_CROND_DIR="" CONFIG_FEATURE_LESS_MAXLINES=0 CONFIG_IFUPDOWN_IFSTATE_PATH="" CONFIG_DHCPD_LEASES_FILE="" CONFIG_UDHCP_DEBUG=0 CONFIG_UDHCPC_DEFAULT_SCRIPT="" CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS=0 CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS="" CONFIG_FEATURE_MIME_CHARSET="" CONFIG_SV_DEFAULT_SERVICE_DIR="" CONFIG_FEATURE_SH_IS_NONE=y CONFIG_HUSH=y CONFIG_HUSH_BASH_COMPAT=y CONFIG_HUSH_INTERACTIVE=y CONFIG_SH_MATH_SUPPORT=y CONFIG_FEATURE_SH_STANDALONE=y CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=0 I see the following behavior: "cp" fails as expected (I dont have this applet enabled, and PATH is ""), but enabled applet "fsck.minix" works: # PATH= ./busybox hush BusyBox v1.17.0.git (2010-03-21 19:15:47 CET) hush - the humble shell /.1/usr/srcdevel/bbox/fix/busybox.z7 # cp hush: can't execute 'cp': No such file or directory /.1/usr/srcdevel/bbox/fix/busybox.z7 # fsck.minix BusyBox v1.17.0.git (2010-03-21 19:15:47 CET) multi-call binary. Usage: fsck.minix [-larvsmf] BLOCKDEV /.1/usr/srcdevel/bbox/fix/busybox.z7 #
(In reply to comment #1) > You also need CONFIG_FEATURE_PREFER_APPLETS=y > Yes, I have that one enabled as well. Pretty much goes without saying since FEATURE_SH_STANDALONE depends on: (MSH || LASH || HUSH || ASH) && FEATURE_PREFER_APPLETS > I see the following behavior: "cp" fails as expected (I dont have this applet > enabled, and PATH is ""), but enabled applet "fsck.minix" works: > > # PATH= ./busybox hush > > > BusyBox v1.17.0.git (2010-03-21 19:15:47 CET) hush - the humble shell > > /.1/usr/srcdevel/bbox/fix/busybox.z7 # cp > hush: can't execute 'cp': No such file or directory > /.1/usr/srcdevel/bbox/fix/busybox.z7 # fsck.minix > BusyBox v1.17.0.git (2010-03-21 19:15:47 CET) multi-call binary. > > Usage: fsck.minix [-larvsmf] BLOCKDEV > > /.1/usr/srcdevel/bbox/fix/busybox.z7 # > Here is what I get using your .config: ~/src/busybox-git$ PATH= ./busybox hush BusyBox v1.17.0.git (2010-03-21 21:53:25 CET) hush - the humble shell /home/simon/src/busybox-git $ cp hush: can't execute 'cp': No such file or directory /home/simon/src/busybox-git $ fsck.minix BusyBox v1.17.0.git (2010-03-21 21:53:25 CET) multi-call binary. Usage: fsck.minix [-larvsmf] BLOCKDEV /home/simon/src/busybox-git $ exec fsck.minix hush: can't execute 'fsck.minix': No such file or directory ~/src/busybox-git$ No problem at all until I try to "exec" an applet that worked without "exec". This only fails with hush, never ash, and only from commit 3ef4f77620a9f5f9a7c1247e29ea9c14e07b8a30 and onwards.
AHA! The fix is simple. Try this: http://busybox.net/downloads/fixes-1.16.0/busybox-1.16.0-hush.patch
(In reply to comment #3) > AHA! > > The fix is simple. > > Try this: > > http://busybox.net/downloads/fixes-1.16.0/busybox-1.16.0-hush.patch > That patch did the trick. It works great on my end. Thanks a lot!