upstart and booting with init=/bin/bash

January 9, 2010

linux

One of the oldest tricks in the sys admin’s arsenal is booting with init=/bin/bash. You’ll need this when you want to reset the password for root for instance.

It used to go like this: Boot with init=/bin/bash and after some time you greeted with a prompt ala

root@(none):/# 

Most often I then took the following steps:

mount -o rw,remount /
/etc/init.d/networking start

Now you also have networking, so you may upgrade the system with apt-get or whatever… You are now a happy puppy.

upstart

Now enter upstart, the new init-replacement from Ubuntu, while I like the idea some things are of course changed for the worse. When you boot a system with upstart in init=/bin/bash-mode, the following happens:

root@(none):/# mount -o rw,remount /
root@(none):/# /etc/init.d/networking start
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service networking start

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start networking
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service networking start

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start networking
start: Unable to connect to Upstart: Failed to connect to socket
/com/ubuntu/upstart: Connection refused

Go figure; you don’t have a upstart running because “init” is now bash. But this leaves me with a problem.

How do you start networking in this case?

ifup eth0 or /etc/init.d/network-manager start all complain with

start: Unable to connect to Upstart: Failed to connect to socket
/com/ubuntu/upstart: Connection refused

I have my server configured with DHCP, so as an act of final desperation I used:

dhclient eth0

and that did the trick.

If you have your interfaces specified in /etc/network/interfaces you may need to cut&paste it and use the go’old ifconfig program. If you are lame enough to use network-manager and have configured it with a static IP address you are on your own.

Single user mode

You may be able to get away with all this crap, by starting your system in single user mode (just a S to your grub line). But Debian/Ubuntu may then ask you for the root password. I never really like this single user mode - I want the power of init=/bin/bash.

None