What is "systemd-binfmt" service and how to enable/disable it ?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux All Versions
  • systemd-binfmt.service
  • proc-sys-fs-binfmt_misc.mount
  • proc-sys-fs-binfmt_misc.automount

Issue

  • How to enable/disable systemd-binfmt.service service?
  • How to enable/disable binfmt_misc mount(s)?
  • What is the systemd-binfmt.service service?

Resolution

Enable the Service/Mount(s) for binfmt

1. Unmask all the associated service/mount(s) for binfmt: (optional)

Only needed if the service was previously masked via systemd commands

# systemctl unmask proc-sys-fs-binfmt_misc.mount
# systemctl unmask proc-sys-fs-binfmt_misc.automount
# systemctl unmask systemd-binfmt.service

2. Enable all the associated service/mount(s) for binfmt:

# systemctl enable proc-sys-fs-binfmt_misc.mount
# systemctl enable proc-sys-fs-binfmt_misc.automount
# systemctl enable systemd-binfmt.service

3. Start all the associated service/mount(s) for binfmt in the following order:

# systemctl start proc-sys-fs-binfmt_misc.mount
# systemctl start proc-sys-fs-binfmt_misc.automount
# systemctl start systemd-binfmt.service

4. Verify the the associated service/mount(s) for binfmt have been enabled/started:

# systemctl status proc-sys-fs-binfmt_misc.mount
# systemctl status proc-sys-fs-binfmt_misc.automount
# systemctl status systemd-binfmt.service

Disable the Service/Mount(s) for binfmt

1. Stop all the associated service/mount(s) for binfmt in the following order:

# systemctl stop systemd-binfmt.service
# systemctl stop proc-sys-fs-binfmt_misc.automount
# systemctl stop proc-sys-fs-binfmt_misc.mount

2. Disable all the associated service/mount(s) for binfmt:

# systemctl disable systemd-binfmt.service
# systemctl disable proc-sys-fs-binfmt_misc.automount
# systemctl disable proc-sys-fs-binfmt_misc.mount

3. Mask all the associated service/mount(s) for binfmt: (optional)

Important: Masking a service will unconditionally prevent a systemd service from being started

# systemctl mask systemd-binfmt.service
# systemctl mask proc-sys-fs-binfmt_misc.automount
# systemctl mask proc-sys-fs-binfmt_misc.mount

4. Verify the the associated service/mount(s) for binfmt have been disabled/masked:

# systemctl status systemd-binfmt.service
# systemctl status proc-sys-fs-binfmt_misc.automount
# systemctl status proc-sys-fs-binfmt_misc.mount

Additional information on Enabling/Disabling systemd services:

How to enable or disable a service in Red Hat Enterprise Linux?
Systemd Cheat Sheet (PDF)

Root Cause

What is the function of the systemd-binfmt.service ?

  • The systemd-binfmt.service is an early boot service that registers additional binary formats for executables in the kernel.

  • The systemd-binfmt service and associated binfmt_misc mount are part of a kernel feature which allows invoking almost every program by simply typing its name in the shell. It recognizes the binary-type by matching some bytes at the beginning of the file with a magic byte sequence (masking out specified bits) you have supplied.

  • This binfmt functionality can also be used to recognize a filename extension aka '.com' or '.exe'.

  • More information can be found in the man command / manual pages listed below:

$ man 8 systemd-binfmt

$ man 5 binfmt.d

Diagnostic Steps

Check Status of the Service/Mount(s) for binfmt

  • Check the mount status for the associated filesystem: binfmt_misc on /proc/sys/fs/binfmt_misc
Basic mount status:
# mount | grep -e "type binfmt_misc"

Check the systemd status of the `binfmt_misc` mount(s):
# systemctl status proc-sys-fs-binfmt_misc.mount
# systemctl status proc-sys-fs-binfmt_misc.automount
  • Check the service status for the associated service: systemd-binfmt.service
Check the systemd status of the `systemd-binfmt.service` service:
# systemctl status systemd-binfmt.service

Check the kernel status of the service: (optional)
# cat /proc/sys/fs/binfmt_misc/status

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments