Mauro Carvalho Chehab | 9cdda3d | 2016-09-23 13:52:05 -0300 | [diff] [blame] | 1 | Mono(tm) Binary Kernel Support for Linux |
| 2 | ----------------------------------------- |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | |
| 4 | To configure Linux to automatically execute Mono-based .NET binaries |
| 5 | (in the form of .exe files) without the need to use the mono CLR |
| 6 | wrapper, you can use the BINFMT_MISC kernel support. |
| 7 | |
| 8 | This will allow you to execute Mono-based .NET binaries just like any |
| 9 | other program after you have done the following: |
| 10 | |
| 11 | 1) You MUST FIRST install the Mono CLR support, either by downloading |
Jonathan Neuschäfer | 51e028e | 2017-12-09 17:21:04 +0100 | [diff] [blame] | 12 | a binary package, a source tarball or by installing from Git. Binary |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | packages for several distributions can be found at: |
| 14 | |
Jonathan Neuschäfer | 51e028e | 2017-12-09 17:21:04 +0100 | [diff] [blame] | 15 | http://www.mono-project.com/download/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
| 17 | Instructions for compiling Mono can be found at: |
| 18 | |
Jonathan Neuschäfer | 51e028e | 2017-12-09 17:21:04 +0100 | [diff] [blame] | 19 | http://www.mono-project.com/docs/compiling-mono/linux/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
| 21 | Once the Mono CLR support has been installed, just check that |
Mauro Carvalho Chehab | 9cdda3d | 2016-09-23 13:52:05 -0300 | [diff] [blame] | 22 | ``/usr/bin/mono`` (which could be located elsewhere, for example |
| 23 | ``/usr/local/bin/mono``) is working. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
| 25 | 2) You have to compile BINFMT_MISC either as a module or into |
Mauro Carvalho Chehab | 9cdda3d | 2016-09-23 13:52:05 -0300 | [diff] [blame] | 26 | the kernel (``CONFIG_BINFMT_MISC``) and set it up properly. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | If you choose to compile it as a module, you will have |
| 28 | to insert it manually with modprobe/insmod, as kmod |
Mauro Carvalho Chehab | 9cdda3d | 2016-09-23 13:52:05 -0300 | [diff] [blame] | 29 | cannot be easily supported with binfmt_misc. |
| 30 | Read the file ``binfmt_misc.txt`` in this directory to know |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | more about the configuration process. |
| 32 | |
Mauro Carvalho Chehab | 9cdda3d | 2016-09-23 13:52:05 -0300 | [diff] [blame] | 33 | 3) Add the following entries to ``/etc/rc.local`` or similar script |
Jani Nikula | 07a37ba | 2016-11-03 11:43:29 +0200 | [diff] [blame] | 34 | to be run at system startup: |
| 35 | |
| 36 | .. code-block:: sh |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
Mauro Carvalho Chehab | 9cdda3d | 2016-09-23 13:52:05 -0300 | [diff] [blame] | 38 | # Insert BINFMT_MISC module into the kernel |
| 39 | if [ ! -e /proc/sys/fs/binfmt_misc/register ]; then |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | /sbin/modprobe binfmt_misc |
| 41 | # Some distributions, like Fedora Core, perform |
| 42 | # the following command automatically when the |
Lucas De Marchi | 970e248 | 2012-03-30 13:37:16 -0700 | [diff] [blame] | 43 | # binfmt_misc module is loaded into the kernel |
| 44 | # or during normal boot up (systemd-based systems). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | # Thus, it is possible that the following line |
Lucas De Marchi | 970e248 | 2012-03-30 13:37:16 -0700 | [diff] [blame] | 46 | # is not needed at all. |
| 47 | mount -t binfmt_misc none /proc/sys/fs/binfmt_misc |
Mauro Carvalho Chehab | 9cdda3d | 2016-09-23 13:52:05 -0300 | [diff] [blame] | 48 | fi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
Mauro Carvalho Chehab | 9cdda3d | 2016-09-23 13:52:05 -0300 | [diff] [blame] | 50 | # Register support for .NET CLR binaries |
| 51 | if [ -e /proc/sys/fs/binfmt_misc/register ]; then |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | # Replace /usr/bin/mono with the correct pathname to |
| 53 | # the Mono CLR runtime (usually /usr/local/bin/mono |
| 54 | # when compiling from sources or CVS). |
| 55 | echo ':CLR:M::MZ::/usr/bin/mono:' > /proc/sys/fs/binfmt_misc/register |
Mauro Carvalho Chehab | 9cdda3d | 2016-09-23 13:52:05 -0300 | [diff] [blame] | 56 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | echo "No binfmt_misc support" |
| 58 | exit 1 |
Mauro Carvalho Chehab | 9cdda3d | 2016-09-23 13:52:05 -0300 | [diff] [blame] | 59 | fi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | |
Mauro Carvalho Chehab | 9cdda3d | 2016-09-23 13:52:05 -0300 | [diff] [blame] | 61 | 4) Check that ``.exe`` binaries can be ran without the need of a |
| 62 | wrapper script, simply by launching the ``.exe`` file directly |
| 63 | from a command prompt, for example:: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
| 65 | /usr/bin/xsd.exe |
| 66 | |
Mauro Carvalho Chehab | 9cdda3d | 2016-09-23 13:52:05 -0300 | [diff] [blame] | 67 | .. note:: |
| 68 | |
| 69 | If this fails with a permission denied error, check |
| 70 | that the ``.exe`` file has execute permissions. |