17

After attempting setting up Raspberry Pi bluetooth to be bluetooth receiver for stereo, now whenever I start it up I can't SSH at all, I can't use the desktop at all or CTRL+ALT+Fnumber key to get to a terminal.

I tried startx=0 in config with shift key at startup, but that doesn't prevent it from freezing completely.

I see a failed message on booting so I think last tweak broke bluetooth... but how can I possibly get to a root console to fix it again? Even in Shift recovery mode, Ctrl+Alt+F1 does not let me log in as it rejects the password. This is on up-to-date Pi3.

NoBugs
  • 271
  • 1
  • 2
  • 7
  • 1
    I'm not sure if I've used recovery mode on Raspbian or not, but as a guess it only allows root logins and is rejecting the password because you have no root password set. There are two variations on this; one (the default) means you cannot log in root at all. The other is that you can log in without a password; you can make it so this way: http://raspberrypi.stackexchange.com/a/47129/5538 – goldilocks Feb 07 '17 at 11:32
  • @goldilocks Even so how would I log in when it immediately goes to desktop? – NoBugs Feb 08 '17 at 03:03
  • @NoBugs After it boots try going to another terminal with Ctrl + Alt + F2 – NULL Feb 13 '17 at 14:49
  • @NULL That's exactly what I had hoped would fix it... No response though, unless in Shift recovery mode and then it doesn't want to let me in... – NoBugs Feb 14 '17 at 02:51
  • Did you try to remove the SD and insert it to the computer to remove config file (easier to do on Linux machine that on Windows machine). – NonStandardModel Feb 19 '17 at 15:33
  • @NonStandardModel On my Ubuntu machine yeah, I tried to undo some changes. Why remove a config file? – NoBugs Feb 21 '17 at 03:17
  • Somebody correct me if I am wrong plese. If you remove the config file it will be regenerated with default settings. You lose all customization, but also by reseting it ti default, you get rid of all errors due to bad settings. – NonStandardModel Feb 21 '17 at 08:36

3 Answers3

14

This Answer is out of date (Raspbian now uses PARTUUID to identify root partition) and uses /bin/bash rather than the POSIX compliant /bin/sh

It may work to repair the partition, but changing cmdline.txt to contain root=/dev/mmcblk0p2 (without a matching change to etc/fstab) may cause subsequent boot problems.

One way to get in to a safe mode of sorts can be accomplished by booting directly in to bash.

  1. Unplug and take the card out
  2. Mount it on a computer
  3. Open the drive, edit the cmdline.txt file and append "init=/bin/bash" at the end of the existing command.

Example:

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 
rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait init=/bin/bash
  1. Unmount the card, put it back in your pi, and boot up. For me, the availability of a command line was not apparent until I pressed Enter on the keyboard.

  2. You will likely find that the card is not writable.

You can remount it as readable/writable by doing (adjust the device name if necessary):

mount -o remount,rw /dev/mmcblk0p2 /
  1. Track down that boo boo, exit the bash session, and unplug the pi
  2. Remount the card on your computer and remove " init=/bin/bash" from cmdline.txt and hopefully voila! Lather, rinse, and repeat if necessary.
goetz
  • 103
  • 3
Kevin Reilly
  • 241
  • 2
  • 4
  • 2
    I would add to this command should be "mount -o remount,rw /dev/mmcblk0p2 /" – Keith Phillips Feb 08 '18 at 01:53
  • In my case, I had to do mount -o remount,rw /dev/mmcblk0p2 / else it throws not mounted or invalid option error – palaniraja Jun 22 '18 at 08:47
  • Interesting! Not certain if something changed or what, but I've updated the post accordingly. Thanks for the heads up. – Kevin Reilly Nov 08 '18 at 23:31
  • where is the cmdline.txt ? it has to be created at root ? – snoob dogg Dec 18 '18 at 21:00
  • 1
    @snoobdogg When you mount the SD card on a computer, it should be in the root directory of the browsable filesystem. It is worth noting I have only confirmed this on the Raspbian distribution. – Kevin Reilly Dec 19 '18 at 22:20
  • Almost all the guides say this, but it doesn't work :/ – NoBugs Mar 01 '20 at 04:48
  • Adding that to the end of my cmdline.txt just gave me the error

    /bin/sh: 0: can't access tty; job control turned off

    And a completely unresponsive system.

    – digitig Oct 01 '23 at 20:59
4

The traditional way to get into "Safe" mode, otherwise known as "single user" mode, is to add an "S" to the end of the command line.

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait S

Instead of bypassing all the system can do, this tells init the runlevel is "S", and it can then do special things to support this case. I just tested this with my semi-ancient installation of Jessie.

The boot command line can typically be found in "/boot/cmdline.txt".

Hack Saw
  • 156
  • 3
  • 2
    This actually works, unlike the other howtos that I've seen... You should make a note that this is boot/cmdline.txt when you mount it on an Ubuntu machine (and might be possible on Windows too I don't know?) – NoBugs Mar 01 '20 at 04:57
4

Since you probably updated your raspian in the process, you might have been caught by this change:

As of the November 2016 release, Raspbian has the SSH server disabled by default. You will have to enable it manually.

The solution to this is quite simple: Put the SD card into some other machine and place an empty file called "ssh" into the boot partition (aka the only partition you see on a windows computer).

dube
  • 149
  • 3
  • I got caught by this so plugged it into an HDMI monitor, mouse & keyboard, and booted up then went to raspi-config to re-enable it. – SDsolar Mar 20 '18 at 00:54