Fixing “proc-sys-fs-binfmt_misc.automount failed (Result: resources)” Error in Ubuntu with systemd


2 views

The binfmt_misc is a crucial Linux kernel feature that allows the system to recognize and execute various binary formats through user-space interpreters. This is particularly useful for:

  • Running Windows executables via Wine
  • Executing Java .class files
  • Handling other non-native binary formats

When you encounter the failed (Result: resources) status for proc-sys-fs-binfmt_misc.automount, it typically means systemd couldn't properly mount the binfmt_misc pseudo-filesystem at boot time. Let's examine the key components:

$ lsmod | grep binfmt
binfmt_misc             20480  1

First, verify if the module is loaded and the mount point exists:

$ ls -l /proc/sys/fs/binfmt_misc
$ cat /proc/sys/fs/binfmt_misc/status

If these commands fail, the kernel module likely isn't loaded. Try loading it manually:

$ sudo modprobe binfmt_misc
$ sudo systemctl restart proc-sys-fs-binfmt_misc.automount

For a persistent fix, consider these approaches:

1. Ensure module loads at boot

Add the module to /etc/modules:

# /etc/modules: kernel modules to load at boot time
binfmt_misc

2. Modify the systemd unit file

Create an override configuration:

$ sudo systemctl edit proc-sys-fs-binfmt_misc.automount

[Unit]
ConditionPathExists=/proc/sys/fs/binfmt_misc/
ConditionPathIsReadWrite=/proc/sys/
Requires=systemd-modules-load.service
After=systemd-modules-load.service

3. Alternative mounting method

Create a custom mount unit if automount continues to fail:

# /etc/systemd/system/binfmt_misc.mount
[Unit]
Description=binfmt_misc filesystem

[Mount]
What=binfmt_misc
Where=/proc/sys/fs/binfmt_misc
Type=binfmt_misc
Options=defaults

After implementing any solution, verify with:

$ systemctl status proc-sys-fs-binfmt_misc.automount
$ mount | grep binfmt
$ ls /proc/sys/fs/binfmt_misc

If issues persist, check kernel messages:

$ dmesg | grep -i binfmt
$ journalctl -u proc-sys-fs-binfmt_misc.automount

The proc-sys-fs-binfmt_misc.automount service is responsible for mounting the binfmt_misc filesystem, which allows Linux to recognize and handle various executable file formats through kernel support. This is particularly useful when dealing with:

  • Windows PE binaries through Wine
  • Java .class files
  • Python or other interpreted language scripts

In Ubuntu 14.10 with systemd, this error typically occurs because:

1. The binfmt_misc kernel module isn't loaded
2. /proc/sys/fs/binfmt_misc isn't properly accessible
3. Systemd version compatibility issues
4. Filesystem permissions problems

First, verify if the binfmt_misc module is loaded:

lsmod | grep binfmt_misc

Check current mounts:

mount | grep binfmt_misc

Here's how to properly fix this:

1. Manual Module Loading

sudo modprobe binfmt_misc
echo "binfmt_misc" | sudo tee -a /etc/modules

2. Alternative Mount Method

Create a custom systemd unit file at /etc/systemd/system/binfmt_misc.automount:

[Unit]
Description=binfmt_misc automount
After=local-fs.target

[Automount]
Where=/proc/sys/fs/binfmt_misc
TimeoutIdleSec=0

[Install]
WantedBy=multi-user.target

3. Verify and Enable

sudo systemctl daemon-reload
sudo systemctl restart proc-sys-fs-binfmt_misc.automount
sudo systemctl enable proc-sys-fs-binfmt_misc.automount

For custom binary format handling, create register scripts in /etc/binfmt.d/:

# Example for Java .class files
:Java:M::\xca\xfe\xba\xbe::/usr/bin/java:
  • Check kernel logs with dmesg | grep binfmt
  • Verify filesystem permissions on /proc/sys/fs/binfmt_misc
  • Consider updating systemd if using very old versions