What is binfmt_misc and how to enable/disable it ?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux

Issue

  • What is binfmt_misc ?
  • How to enable/disable binfmt_misc ?

Resolution

What is binfmt_misc?

  • binfmt_misc is a kernel feature which allows invoking almost every program by simply typing its name in the shell. It recognises 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.

  • binfmt_misc can also recognize a filename extension aka '.com' or '.exe'.

How to enable/disable it ?

  • Firstly need to make sure it is mounted:
# grep binfmt /proc/mounts
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
  • If it is not then mount it with below command:
# mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
  • To enable it run below command:
# echo 1 > /proc/sys/fs/binfmt_misc/status
  • To disable it run below command:
# echo 0 > /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