You are not logged in.

#1 2013-01-30 03:21:53

lostmahmind
Member
Registered: 2013-01-24
Posts: 5

[Solved] systemd service startup issue on boot

Issue resolved, easy fix, just had to read up on the documentation, . : )

In sshd.service under the [Unit] section, add network.target to Wants. (Wants=network.target)

---------------------------------

Edit 2: I may have the solution, won't know until I reboot server which I don't really want to do right now, I'll post back on success if it works out. Details below.

---------------------------------


I'm experiencing an issue on boot where sshd fails to start because the IP I've configured it to bind to isn't yet assigned. I can see that shortly after the attempt to start sshd occurs all of the network stuff kicks in. After the system boots up and I login I can start sshd without problems.

I need sshd to try to startup after the network stuff has happened and the additional IP's on my system have been assigned.

I have two pieces of information which seem to contradict each other. One is the output of my boot log wich shows dhcpcd starting after sshd, the other is systemctl --order output which shows dhcpcd before sshd in the service list.

Can someone help me understand what's happening and how to adjust the bootup sequence?

Here's the section of interest within my startup log (sshd before dhcpcd):

# this section repeats a dozen times or so
Jan 29 21:20:00 pickles systemd[1]: Started SSH Key Generation.
Jan 29 21:20:00 pickles systemd[1]: Starting OpenSSH Daemon...
Jan 29 21:20:00 pickles systemd[1]: sshd.service: main process exited, code=exited, status=255/n/a
Jan 29 21:20:00 pickles systemd[1]: Unit sshd.service entered failed state
Jan 29 21:20:00 pickles systemd[1]: sshd.service holdoff time over, scheduling restart.
Jan 29 21:20:00 pickles systemd[1]: Stopping OpenSSH Daemon...

# after a dozen or so attempts we get this
Jan 29 21:20:00 pickles systemd[1]: sshd.service start request repeated too quickly, refusing to start
Jan 29 21:20:00 pickles systemd[1]: Failed to start OpenSSH Daemon.
Jan 29 21:20:00 pickles systemd[1]: Unit sshd.service entered failed state
Jan 29 21:20:03 pickles systemd[1]: Started Netcfg multi-profile daemon.
Jan 29 21:20:05 pickles systemd[1]: Started dhcpcd on eth0.
Jan 29 21:20:05 pickles systemd[1]: Starting Network.
Jan 29 21:20:05 pickles systemd[1]: Reached target Network.

# If sshd tried starting up here it would succeed, but how do I control the order of the process startup?

And the section of interest from systemctl --order (dhcpcd before sshd):

dev-hugepages.mount         loaded active mounted   Huge Pages File System
dev-mqueue.mount            loaded active mounted   POSIX Message Queue File System
sys-fs-f...onnections.mount loaded active mounted   FUSE Control File System
sys-kernel-config.mount     loaded active mounted   Configuration File System
sys-kernel-debug.mount      loaded active mounted   Debug File System
tmp.mount                   loaded active mounted   Temporary Directory
systemd-...ord-console.path loaded active waiting   Dispatch Password Requests to Console Directory Watch
systemd-...ssword-wall.path loaded active waiting   Forward Password Requests to Wall Directory Watch
dbus.service                loaded active running   D-Bus System Message Bus
dhcpcd@eth0.service         loaded active running   dhcpcd on eth0
getty@tty1.service          loaded active running   Getty on tty1
httpd.service               loaded active running   Apache Web Server
iptables.service            loaded active exited    Packet Filtering Framework
netcfg.service              loaded active exited    Netcfg multi-profile daemon
ntpd.service                loaded active running   Network Time Service
serial-getty@hvc0.service   loaded active running   Serial Getty on hvc0
sshd.service                loaded active running   OpenSSH Daemon
sshguard.service            loaded active running   Block hacking attempts
systemd-journald.service    loaded active running   Journal Service
systemd-logind.service      loaded active running   Login Service
systemd-remount-fs.service  loaded active exited    Remount Root and Kernel File Systems
systemd-sysctl.service      loaded active exited    Apply Kernel Variables
systemd-...es-setup.service loaded active exited    Recreate Volatile Files and Directories
systemd-...-trigger.service loaded active exited    udev Coldplug all Devices
systemd-udevd.service       loaded active running   udev Kernel Device Manager
systemd-...sessions.service loaded active exited    Permit User Sessions
systemd-...le-setup.service loaded active exited    Setup Virtual Console
xinetd.service              loaded active running   A secure replacement for inetd
dbus.socket                 loaded active running   D-Bus System Message Bus Socket
systemd-initctl.socket      loaded active listening /dev/initctl Compatibility Named Pipe
systemd-journald.socket     loaded active running   Journal Socket
systemd-shutdownd.socket    loaded active listening Delayed Shutdown Socket
systemd-...d-control.socket loaded active listening udev Control Socket
systemd-udevd-kernel.socket loaded active running   udev Kernel Socket
dev-xvdb.swap               loaded active active    /dev/xvdb
basic.target                loaded active active    Basic System
cryptsetup.target           loaded active active    Encrypted Volumes
getty.target                loaded active active    Login Prompts
graphical.target            loaded active active    Graphical Interface
local-fs-pre.target         loaded active active    Local File Systems (Pre)
local-fs.target             loaded active active    Local File Systems
multi-user.target           loaded active active    Multi-User
network.target              loaded active active    Network
remote-fs.target            loaded active active    Remote File Systems
sockets.target              loaded active active    Sockets
swap.target                 loaded active active    Swap
sysinit.target              loaded active active    System Initialization
systemd-...iles-clean.timer loaded active waiting   Daily Cleanup of Temporary Directories

-----------------------------
Edit:

If it helps, here's systemctl --order dot output for sshd:

	"sshd.service"->"sshdgenkeys.service" [color="green"];
	"sshd.service"->"systemd-journald.socket" [color="green"];
	"sshd.service"->"basic.target" [color="green"];

My first guess, now that I see that, is that I need to make dhcpcd@eth0.service a dependency for sshd.service? I'll see if I can do that.

----------------------------
Edit 2:

There's a [Unit] section in the sshd.service definition, it has a Wants= section where in I added 'network.target', this will supposedly control the startup sequence so that sshd won't try to startup until dhcpcd does. (That is, if I understood the documentation correctly.)

Will post back on success/failure after I reboot (some time later).

Last edited by lostmahmind (2013-01-31 14:45:32)

Offline

Board footer

Powered by FluxBB