fergusondavid6
Posts: 58
Joined: Sun Apr 21, 2013 3:36 pm

init=/bin/sh not working

Fri Mar 31, 2017 11:31 pm

I'm trying to experiment with adding init=/bin/sh to cmdline.txt, but I'm not having any luck getting it working.

Wha I've done is:
  • Written fresh Raspbian Lite image
  • Changed init=/usr/lib/raspi-config/init_resize.sh to init=/bin/sh
  • Put the SD card into the Pi (model B 512mb)
  • Booted it
But when I boot the Pi, the boot process stops just after it finds the USB devices - the last message is:

Code: Select all

usb-1-1.2.2: Product: Apple Keyboard
usb-1-1.2.2: Manufacture: Apple, Inc
random: nonblocking pool is initialized
After that it freezes, doesn't respond to keyboard input, and after a few minutes the screen goes black (some sort of screensaver perhaps?)

Any ideas what I'm doing wrong?

ktb
Posts: 1447
Joined: Fri Dec 26, 2014 7:53 pm

Re: init=/bin/sh not working

Sun Apr 02, 2017 7:02 am

Does init=/bin/bash exhibit the same problem?

What about trying either of the following in cmdline.txt:
systemd.unit=emergency.target
-or-
systemd.unit=rescue.target

jickup
Posts: 1
Joined: Tue Apr 18, 2017 2:18 am

Re: init=/bin/sh not working

Tue Apr 18, 2017 2:59 am

Thank you, @ktb! I was having this very same problem, but appending systemd.unit=rescue.target to my cmdline.txt file worked!

Further details: I'd get a variation of the following when I use init=/bin/sh or init=/bin/bash. It seemed to be starting the shell, but not associating it with the terminal properly:
(yada yada)
[ 3.025164] Indeed it is in host mode hprt0 = 00021501
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
root@(none):/#
[ 3.234920] usb 1-1: new full speed USB device number 3 using dwc_otg
(yada yada)
When I used systemd.unit=emergency.target, I did get a command line, but the filesystem was read-only.

Thanks again!

User avatar
davidcoton
Posts: 6623
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: init=/bin/sh not working

Tue Apr 18, 2017 9:07 am

fergusondavid6 wrote:Changed init=/usr/lib/raspi-config/init_resize.sh to init=/bin/sh
That suggests that you have not booted the system before, and that the file system has not been expanded. Try booting the system once with standard Raspbian Lite, before making this change (the original line will change automatically when the resize is completed). Then reboot.
Location: 345th cell on the right of the 210th row of L2 cache

Martin Frezman
Posts: 1009
Joined: Mon Oct 31, 2016 10:05 am

Re: init=/bin/sh not working

Tue Apr 18, 2017 9:23 am

When I used systemd.unit=emergency.target, I did get a command line, but the filesystem was read-only.
The normal fix for that is to do:

Code: Select all

mount -o remount,rw /
(Or something similar - not exactly sure what to use as the target of the mount - having not done this in a long time). You usually find this out when you try to change a password (since that's the usual reason for needing to do this in the first place) and you get an error message about "some kind of error manipulating tokens".

Regarding the original problem - where init=/bin/bash didn't seem to work: Be sure to hit enter once or twice once the boot has settled down. This will usually get you to a # prompt. The reason for this is that it has already gotten to the shell prompt, but then the prompt character gets lost in the shuffle of more booting messages. Try this; does it work?
If this post appears in the wrong forums category, my apologies.

Martin Frezman
Posts: 1009
Joined: Mon Oct 31, 2016 10:05 am

Re: init=/bin/sh not working

Tue Apr 18, 2017 9:28 am

bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
root@(none):/#
Also note: This is annoying, but can pretty much be ignored. The shell should still work (once you hit enter to get the prompt back).
If this post appears in the wrong forums category, my apologies.

Return to “Advanced users”