Skip to content

V15.0 - systemd inithook.service fails to initialize appliance when running in a container #1071

@Dude4Linux

Description

@Dude4Linux

@JedMeister - I mentioned earlier that I was having difficulty getting v15.0 appliances to initialize when running systemd in a container. I believe I've tracked down the cause and am looking for advice on how to fix the problem. After starting a container and waiting for initialization, the systemd journalctl shows the following:

# journalctl -xe
May 01 16:09:48 tkldev-test systemd[1]: inithooks.service: Failed to set invocation ID on control group /system.slice/inithooks.service, ignoring
May 01 16:09:48 tkldev-test systemd[523]: inithooks.service: Failed at step STDIN spawning /bin/sh: No such file or directory
-- Subject: Process /bin/sh could not be executed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- The process /bin/sh could not be executed and failed.
-- 
-- The error number returned by this process is 2.
May 01 16:09:48 tkldev-test systemd[1]: Starting inithooks: firstboot and everyboot initialization scripts...
-- Subject: Unit inithooks.service has begun start-up
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- Unit inithooks.service has begun starting up.
May 01 16:09:48 tkldev-test systemd[1]: inithooks.service: Main process exited, code=exited, status=208/STDIN
May 01 16:09:48 tkldev-test systemd[1]: Failed to start inithooks: firstboot and everyboot initialization scripts.
-- Subject: Unit inithooks.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- Unit inithooks.service has failed.
-- 
-- The result is failed.
May 01 16:09:48 tkldev-test systemd[1]: inithooks.service: Unit entered failed state.
May 01 16:09:48 tkldev-test systemd[1]: inithooks.service: Failed with result 'exit-code'.
May 01 16:17:01 tkldev-test CRON[614]: pam_unix(cron:session): session opened for user root by (uid=0)
May 01 16:17:01 tkldev-test CRON[615]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
May 01 16:17:01 tkldev-test CRON[614]: pam_unix(cron:session): session closed for user root
May 01 17:17:01 tkldev-test CRON[669]: pam_unix(cron:session): session opened for user root by (uid=0)
May 01 17:17:01 tkldev-test CRON[670]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
May 01 17:17:01 tkldev-test CRON[669]: pam_unix(cron:session): session closed for user root
May 01 18:17:01 tkldev-test CRON[725]: pam_unix(cron:session): session opened for user root by (uid=0)
May 01 18:17:01 tkldev-test CRON[726]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
May 01 18:17:01 tkldev-test CRON[725]: pam_unix(cron:session): session closed for user root

At first I couldn't figure out why /bin/sh couldn't be found as implied by the error message. Finally found a post where someone pointed out the the error message is misleading. Taking a look at the inithooks.service file shows:

# cat /lib/systemd/system/inithooks.service 
[Unit]
Description=inithooks: firstboot and everyboot initialization scripts
After=getty@tty8.service
ConditionKernelCommandLine=!noinithooks

[Service]
Type=oneshot
StandardInput=tty-force
TTYPath=/dev/tty8
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
EnvironmentFile=/etc/default/inithooks
ExecStart=/bin/sh -c '\
    FGCONSOLE=$(fgconsole); \
    openvt -f -c 8 -s -w -- ${INITHOOKS_PATH}/run; \
    chvt $FGCONSOLE'

[Install]
WantedBy=basic.target

After doing some checking, I realized that the TTYPath i.e. /dev/tty8 is what was missing. In doing the updates for the LXC appliance and images for LXD, I tried to cleanup and remove as much cruft as possible. I believe that confconsole and the /dev/tty's had already been removed in v14.2, but that was not an issue because we never ran systemd in the containers. So my question is what do. I see three options:

  1. Restore /dev/tty8 so that inithooks.service can run unmodified.
  2. Modify inithooks.service in containers to use /dev/console which was retained.
  3. Modify inithooks.service in containers so it runs without user input.
    I think 3 is the most desirable mode for containers as we are already pre-seeding inithooks and redirecting the output to /var/log/inithooks.log. Looking for a second opinion.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions