blob: 59e6d59f0ed9ef145df5c0f94861c1509d0ab69b [file] [log] [blame]
Mauro Carvalho Chehab9cdda3d2016-09-23 13:52:05 -03001Mono(tm) Binary Kernel Support for Linux
2-----------------------------------------
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
4To configure Linux to automatically execute Mono-based .NET binaries
5(in the form of .exe files) without the need to use the mono CLR
6wrapper, you can use the BINFMT_MISC kernel support.
7
8This will allow you to execute Mono-based .NET binaries just like any
9other program after you have done the following:
10
111) You MUST FIRST install the Mono CLR support, either by downloading
Jonathan Neuschäfer51e028e2017-12-09 17:21:04 +010012 a binary package, a source tarball or by installing from Git. Binary
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 packages for several distributions can be found at:
14
Jonathan Neuschäfer51e028e2017-12-09 17:21:04 +010015 http://www.mono-project.com/download/
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
17 Instructions for compiling Mono can be found at:
18
Jonathan Neuschäfer51e028e2017-12-09 17:21:04 +010019 http://www.mono-project.com/docs/compiling-mono/linux/
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21 Once the Mono CLR support has been installed, just check that
Mauro Carvalho Chehab9cdda3d2016-09-23 13:52:05 -030022 ``/usr/bin/mono`` (which could be located elsewhere, for example
23 ``/usr/local/bin/mono``) is working.
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
252) You have to compile BINFMT_MISC either as a module or into
Mauro Carvalho Chehab9cdda3d2016-09-23 13:52:05 -030026 the kernel (``CONFIG_BINFMT_MISC``) and set it up properly.
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 If you choose to compile it as a module, you will have
28 to insert it manually with modprobe/insmod, as kmod
Mauro Carvalho Chehab9cdda3d2016-09-23 13:52:05 -030029 cannot be easily supported with binfmt_misc.
30 Read the file ``binfmt_misc.txt`` in this directory to know
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 more about the configuration process.
32
Mauro Carvalho Chehab9cdda3d2016-09-23 13:52:05 -0300333) Add the following entries to ``/etc/rc.local`` or similar script
Jani Nikula07a37ba2016-11-03 11:43:29 +020034 to be run at system startup:
35
36 .. code-block:: sh
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Mauro Carvalho Chehab9cdda3d2016-09-23 13:52:05 -030038 # Insert BINFMT_MISC module into the kernel
39 if [ ! -e /proc/sys/fs/binfmt_misc/register ]; then
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 /sbin/modprobe binfmt_misc
41 # Some distributions, like Fedora Core, perform
42 # the following command automatically when the
Lucas De Marchi970e2482012-03-30 13:37:16 -070043 # binfmt_misc module is loaded into the kernel
44 # or during normal boot up (systemd-based systems).
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 # Thus, it is possible that the following line
Lucas De Marchi970e2482012-03-30 13:37:16 -070046 # is not needed at all.
47 mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
Mauro Carvalho Chehab9cdda3d2016-09-23 13:52:05 -030048 fi
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Mauro Carvalho Chehab9cdda3d2016-09-23 13:52:05 -030050 # Register support for .NET CLR binaries
51 if [ -e /proc/sys/fs/binfmt_misc/register ]; then
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 # 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 Chehab9cdda3d2016-09-23 13:52:05 -030056 else
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 echo "No binfmt_misc support"
58 exit 1
Mauro Carvalho Chehab9cdda3d2016-09-23 13:52:05 -030059 fi
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Mauro Carvalho Chehab9cdda3d2016-09-23 13:52:05 -0300614) 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 Torvalds1da177e2005-04-16 15:20:36 -070064
65 /usr/bin/xsd.exe
66
Mauro Carvalho Chehab9cdda3d2016-09-23 13:52:05 -030067 .. note::
68
69 If this fails with a permission denied error, check
70 that the ``.exe`` file has execute permissions.