Raspberry Pi – Stuck in boot after installing upstart

I  installed upstart so I could run a script at startup [native /etc/init/*.conf]  with sudo apt-get install upstart and I then rebooted my RPi.

Afterwards my RPi running Debian-Jessie was pretty much unresponsive via the network. Right after connecting it to my monitor I then realised that it was stuck on boot.

CODE:

[   17.777252] init: samba-ad-dc main process (513) terminated with status 1
[  133.770712] init: failsafe main process (364_ killed by TERM signal
[info] Using makefile-style concurrent boot in runlevel S
...
[info] Loading kernel module fuse.

Only at that moment, I started realising that I should have probably backed up my SD Card before, but then it was already too late. It then struck me – So I will have to redo it all over again with a new and fresh raspbian installation. That was not something I was looking forward to do ,especially not after I have invested my time to this project I have undertaken myself on[apts, pips and nodes].

And then it hit me, A while ago – I had more or less the same issue on my Xubuntu 12.04 install and managed to get away with it via chroot which then worked, then started researching as to if it is possible to chroot my ARM Raspbian install from an Wbuntu system. To my revelation it was…And below is how I managed to rollback to Systemd-sysv without having to burn a new raspbian image to my sd card.

First, install two packages on your Ubuntu system: qemu-user, and proot.

sudo apt-get install -y qemu-user proot

After you mount the Raspbian SD card, you can do the equivalent of a ‘chroot‘ with:

 sudo proot -q qemu-arm  -r /mnt/raspbian_sd_card

I was then able to chroot/proot to my raspbian install and removed upstart:

sudo apt-get -y purge --auto-remove upstart

This command will also automatically re-install systemd-sysv

Advertisements

System V init script(start-stop-daemon)

I’ve been looking for efficient ways to start at boot my NodeJS dependent applications, with inspiration from https://gist.github.com/alobato/1968852, I modified it to my own needs.

Link might interest you as well:
http://big-elephants.com/2013-01/writing-your-own-init-scripts/
https://www.cyberciti.biz/tips/linux-write-sys-v-init-script-to-start-stop-service.html

Copy template to /etc/init.d and rename it to something meaningful. Then edit the script and enter that name after Provides:(between ### BEGIN INIT INFO and ### END INIT INFO).

#!/bin/bash
# Inspired by https://gist.github.com/alobato/1968852
# Needs Provides, Descriptions

### BEGIN INIT INFO
# Provides:
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description:
# Description:
### END INIT INFO

set -e
NAME=""
PIDFILE="/run/$NAME/$NAME.pid"
# Application one wants to upstart
DAEMON=""
DAEMON_OPTS=""
# Run as user
RUN_USER=""
RUN_GROUP=""
function daemon_run {
	mkdir -p /run/$NAME
	chown $RUN_USER:$RUN_GROUP /run/$NAME
	start-stop-daemon --start --background --quiet --chuid $RUN_USER:$RUN_GROUP --chdir /run/$NAME --pidfile $PIDFILE --make-pidfile --exec $DAEMON $DAEMON_OPTS
}
exec > /var/log/$NAME.log 2>&1

case "$1" in
start)
	echo -n "Starting $NAME ... "
	daemon_run
	echo "done."
;;

silent)
	echo -n "Starting $NAME in silent mode ... "
	daemon_run
	echo "done."
;;

stop)
	echo -n "Stopping $NAME ... "
	start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --remove-pidfile
	echo "done."
;;
restart|force-reload)
	echo -n "Restarting $NAME ... "
	start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $PIDFILE --remove-pidfile
	alexa_run
	echo "done."
;;
*)
	echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0

When done,

sudo systemctl enable 'name_of_filename'
reboot

Mpho