=^.^=

OpenRC unable to exec init.d scripts: Exec format error

karma

I recently did a global update on an old VM and nearly shat myself when it came up with this on bootup:

   OpenRC 0.8.3 is starting up Gentoo Linux (i686) [XENU]

 * Mounting /proc ...
 [ ok ]
 * Caching service dependencies ...
 [ ok ]
unable to exec `/etc/init.d/sysfs': Exec format error
unable to exec `/etc/init.d/udev-mount': Exec format error
unable to exec `/etc/init.d/dmesg': Exec format error
unable to exec `/etc/init.d/udev': Exec format error
unable to exec `/etc/init.d/devfs': Exec format error
unable to exec `/etc/init.d/modules': Exec format error
unable to exec `/etc/init.d/fsck': Exec format error
unable to exec `/etc/init.d/root': Exec format error
unable to exec `/etc/init.d/mtab': Exec format error
unable to exec `/etc/init.d/localmount': Exec format error
unable to exec `/etc/init.d/sysctl': Exec format error
unable to exec `/etc/init.d/bootmisc': Exec format error
unable to exec `/etc/init.d/devfs': Exec format error
unable to exec `/etc/init.d/dmesg': Exec format error
unable to exec `/etc/init.d/hostname': Exec format error
unable to exec `/etc/init.d/net.lo': Exec format error
unable to exec `/etc/init.d/procfs': Exec format error
unable to exec `/etc/init.d/swap': Exec format error
unable to exec `/etc/init.d/sysfs': Exec format error
unable to exec `/etc/init.d/udev-mount': Exec format error
unable to exec `/etc/init.d/udev': Exec format error
unable to exec `/etc/init.d/urandom': Exec format error
INIT: Entering runlevel: 3
unable to exec `/etc/init.d/modules': Exec format error
unable to exec `/etc/init.d/fsck': Exec format error
unable to exec `/etc/init.d/root': Exec format error
unable to exec `/etc/init.d/mtab': Exec format error
unable to exec `/etc/init.d/localmount': Exec format error
unable to exec `/etc/init.d/sysctl': Exec format error
unable to exec `/etc/init.d/bootmisc': Exec format error
unable to exec `/etc/init.d/net.lo': Exec format error
unable to exec `/etc/init.d/netmount': Exec format error
unable to exec `/etc/init.d/mysql': Exec format error
unable to exec `/etc/init.d/hostname': Exec format error
unable to exec `/etc/init.d/metalog': Exec format error
unable to exec `/etc/init.d/sshd': Exec format error
unable to exec `/etc/init.d/apache2': Exec format error
unable to exec `/etc/init.d/devfs': Exec format error
unable to exec `/etc/init.d/dmesg': Exec format error
unable to exec `/etc/init.d/procfs': Exec format error
unable to exec `/etc/init.d/sendmail': Exec format error
unable to exec `/etc/init.d/snmpd': Exec format error
unable to exec `/etc/init.d/swap': Exec format error
unable to exec `/etc/init.d/udev-postmount': Exec format error
unable to exec `/etc/init.d/urandom': Exec format error
unable to exec `/etc/init.d/vixie-cron': Exec format error
unable to exec `/etc/init.d/vsftpd': Exec format error
unable to exec `/etc/init.d/local': Exec format error
unable to exec `/etc/init.d/sysfs': Exec format error
unable to exec `/etc/init.d/udev-mount': Exec format error
unable to exec `/etc/init.d/udev': Exec format error

It took me forever to figure out but upgrading the domU kernel from 2.6.18 to 2.6.38 did the trick. You can download a copy from this post:

Download: 32-bit Gentoo 2.6.38 PAE Xen 3.x+ Paravirtual DomU Kernel

Comments

karma

@Ben Peddell
Great information, thanks!

• Ben Peddell

It appears that the cause of this is OpenRC making the interpreter of /etc/init.d/* (/sbin/runscript) itself a script when selinux is enabled. The execve(2) man page forbids this, and kernels before commit bf2a9a39639b8b51377905397a5005f444e9a892 or version 2.6.28 forbade shell interpreter recursion.

As my VPS provider hasn't yet provided a more recent kernel or a way of running a more recent kernel, I had to work around this by replacing /sbin/runscript with a small C program that performs the same task as the wrapper script.