162306a36Sopenharmony_ciMono(tm) Binary Kernel Support for Linux
262306a36Sopenharmony_ci-----------------------------------------
362306a36Sopenharmony_ci
462306a36Sopenharmony_ciTo configure Linux to automatically execute Mono-based .NET binaries
562306a36Sopenharmony_ci(in the form of .exe files) without the need to use the mono CLR
662306a36Sopenharmony_ciwrapper, you can use the BINFMT_MISC kernel support.
762306a36Sopenharmony_ci
862306a36Sopenharmony_ciThis will allow you to execute Mono-based .NET binaries just like any
962306a36Sopenharmony_ciother program after you have done the following:
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci1) You MUST FIRST install the Mono CLR support, either by downloading
1262306a36Sopenharmony_ci   a binary package, a source tarball or by installing from Git. Binary
1362306a36Sopenharmony_ci   packages for several distributions can be found at:
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci	https://www.mono-project.com/download/
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci   Instructions for compiling Mono can be found at:
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci	https://www.mono-project.com/docs/compiling-mono/linux/
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci   Once the Mono CLR support has been installed, just check that
2262306a36Sopenharmony_ci   ``/usr/bin/mono`` (which could be located elsewhere, for example
2362306a36Sopenharmony_ci   ``/usr/local/bin/mono``) is working.
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci2) You have to compile BINFMT_MISC either as a module or into
2662306a36Sopenharmony_ci   the kernel (``CONFIG_BINFMT_MISC``) and set it up properly.
2762306a36Sopenharmony_ci   If you choose to compile it as a module, you will have
2862306a36Sopenharmony_ci   to insert it manually with modprobe/insmod, as kmod
2962306a36Sopenharmony_ci   cannot be easily supported with binfmt_misc.
3062306a36Sopenharmony_ci   Read the file ``binfmt_misc.txt`` in this directory to know
3162306a36Sopenharmony_ci   more about the configuration process.
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci3) Add the following entries to ``/etc/rc.local`` or similar script
3462306a36Sopenharmony_ci   to be run at system startup:
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci   .. code-block:: sh
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci    # Insert BINFMT_MISC module into the kernel
3962306a36Sopenharmony_ci    if [ ! -e /proc/sys/fs/binfmt_misc/register ]; then
4062306a36Sopenharmony_ci        /sbin/modprobe binfmt_misc
4162306a36Sopenharmony_ci	# Some distributions, like Fedora Core, perform
4262306a36Sopenharmony_ci	# the following command automatically when the
4362306a36Sopenharmony_ci	# binfmt_misc module is loaded into the kernel
4462306a36Sopenharmony_ci	# or during normal boot up (systemd-based systems).
4562306a36Sopenharmony_ci	# Thus, it is possible that the following line
4662306a36Sopenharmony_ci	# is not needed at all.
4762306a36Sopenharmony_ci	mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
4862306a36Sopenharmony_ci    fi
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci    # Register support for .NET CLR binaries
5162306a36Sopenharmony_ci    if [ -e /proc/sys/fs/binfmt_misc/register ]; then
5262306a36Sopenharmony_ci	# Replace /usr/bin/mono with the correct pathname to
5362306a36Sopenharmony_ci	# the Mono CLR runtime (usually /usr/local/bin/mono
5462306a36Sopenharmony_ci	# when compiling from sources or CVS).
5562306a36Sopenharmony_ci        echo ':CLR:M::MZ::/usr/bin/mono:' > /proc/sys/fs/binfmt_misc/register
5662306a36Sopenharmony_ci    else
5762306a36Sopenharmony_ci        echo "No binfmt_misc support"
5862306a36Sopenharmony_ci        exit 1
5962306a36Sopenharmony_ci    fi
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci4) Check that ``.exe`` binaries can be ran without the need of a
6262306a36Sopenharmony_ci   wrapper script, simply by launching the ``.exe`` file directly
6362306a36Sopenharmony_ci   from a command prompt, for example::
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci	/usr/bin/xsd.exe
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci   .. note::
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci      If this fails with a permission denied error, check
7062306a36Sopenharmony_ci      that the ``.exe`` file has execute permissions.
71