19d85025bSMauro Carvalho ChehabMono(tm) Binary Kernel Support for Linux 29d85025bSMauro Carvalho Chehab----------------------------------------- 39d85025bSMauro Carvalho Chehab 49d85025bSMauro Carvalho ChehabTo configure Linux to automatically execute Mono-based .NET binaries 59d85025bSMauro Carvalho Chehab(in the form of .exe files) without the need to use the mono CLR 69d85025bSMauro Carvalho Chehabwrapper, you can use the BINFMT_MISC kernel support. 79d85025bSMauro Carvalho Chehab 89d85025bSMauro Carvalho ChehabThis will allow you to execute Mono-based .NET binaries just like any 99d85025bSMauro Carvalho Chehabother program after you have done the following: 109d85025bSMauro Carvalho Chehab 119d85025bSMauro Carvalho Chehab1) You MUST FIRST install the Mono CLR support, either by downloading 1251e028e4SJonathan Neuschäfer a binary package, a source tarball or by installing from Git. Binary 139d85025bSMauro Carvalho Chehab packages for several distributions can be found at: 149d85025bSMauro Carvalho Chehab 15*93431e06SAlexander A. Klimov https://www.mono-project.com/download/ 169d85025bSMauro Carvalho Chehab 179d85025bSMauro Carvalho Chehab Instructions for compiling Mono can be found at: 189d85025bSMauro Carvalho Chehab 19*93431e06SAlexander A. Klimov https://www.mono-project.com/docs/compiling-mono/linux/ 209d85025bSMauro Carvalho Chehab 219d85025bSMauro Carvalho Chehab Once the Mono CLR support has been installed, just check that 229d85025bSMauro Carvalho Chehab ``/usr/bin/mono`` (which could be located elsewhere, for example 239d85025bSMauro Carvalho Chehab ``/usr/local/bin/mono``) is working. 249d85025bSMauro Carvalho Chehab 259d85025bSMauro Carvalho Chehab2) You have to compile BINFMT_MISC either as a module or into 269d85025bSMauro Carvalho Chehab the kernel (``CONFIG_BINFMT_MISC``) and set it up properly. 279d85025bSMauro Carvalho Chehab If you choose to compile it as a module, you will have 289d85025bSMauro Carvalho Chehab to insert it manually with modprobe/insmod, as kmod 299d85025bSMauro Carvalho Chehab cannot be easily supported with binfmt_misc. 309d85025bSMauro Carvalho Chehab Read the file ``binfmt_misc.txt`` in this directory to know 319d85025bSMauro Carvalho Chehab more about the configuration process. 329d85025bSMauro Carvalho Chehab 339d85025bSMauro Carvalho Chehab3) Add the following entries to ``/etc/rc.local`` or similar script 3407a37ba5SJani Nikula to be run at system startup: 3507a37ba5SJani Nikula 3607a37ba5SJani Nikula .. code-block:: sh 379d85025bSMauro Carvalho Chehab 389d85025bSMauro Carvalho Chehab # Insert BINFMT_MISC module into the kernel 399d85025bSMauro Carvalho Chehab if [ ! -e /proc/sys/fs/binfmt_misc/register ]; then 409d85025bSMauro Carvalho Chehab /sbin/modprobe binfmt_misc 419d85025bSMauro Carvalho Chehab # Some distributions, like Fedora Core, perform 429d85025bSMauro Carvalho Chehab # the following command automatically when the 439d85025bSMauro Carvalho Chehab # binfmt_misc module is loaded into the kernel 449d85025bSMauro Carvalho Chehab # or during normal boot up (systemd-based systems). 459d85025bSMauro Carvalho Chehab # Thus, it is possible that the following line 469d85025bSMauro Carvalho Chehab # is not needed at all. 479d85025bSMauro Carvalho Chehab mount -t binfmt_misc none /proc/sys/fs/binfmt_misc 489d85025bSMauro Carvalho Chehab fi 499d85025bSMauro Carvalho Chehab 509d85025bSMauro Carvalho Chehab # Register support for .NET CLR binaries 519d85025bSMauro Carvalho Chehab if [ -e /proc/sys/fs/binfmt_misc/register ]; then 529d85025bSMauro Carvalho Chehab # Replace /usr/bin/mono with the correct pathname to 539d85025bSMauro Carvalho Chehab # the Mono CLR runtime (usually /usr/local/bin/mono 549d85025bSMauro Carvalho Chehab # when compiling from sources or CVS). 559d85025bSMauro Carvalho Chehab echo ':CLR:M::MZ::/usr/bin/mono:' > /proc/sys/fs/binfmt_misc/register 569d85025bSMauro Carvalho Chehab else 579d85025bSMauro Carvalho Chehab echo "No binfmt_misc support" 589d85025bSMauro Carvalho Chehab exit 1 599d85025bSMauro Carvalho Chehab fi 609d85025bSMauro Carvalho Chehab 619d85025bSMauro Carvalho Chehab4) Check that ``.exe`` binaries can be ran without the need of a 629d85025bSMauro Carvalho Chehab wrapper script, simply by launching the ``.exe`` file directly 639d85025bSMauro Carvalho Chehab from a command prompt, for example:: 649d85025bSMauro Carvalho Chehab 659d85025bSMauro Carvalho Chehab /usr/bin/xsd.exe 669d85025bSMauro Carvalho Chehab 679d85025bSMauro Carvalho Chehab .. note:: 689d85025bSMauro Carvalho Chehab 699d85025bSMauro Carvalho Chehab If this fails with a permission denied error, check 709d85025bSMauro Carvalho Chehab that the ``.exe`` file has execute permissions. 71