요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
Mono(tm) Binary Kernel Support for Linux
-----------------------------------------
To configure Linux to automatically execute Mono-based .NET binaries
(in the form of .exe files) without the need to use the mono CLR
wrapper, you can use the BINFMT_MISC kernel support.
This will allow you to execute Mono-based .NET binaries just like any
other program after you have done the following:
1) You MUST FIRST install the Mono CLR support, either by downloading
a binary package, a source tarball or by installing from Git. Binary
packages for several distributions can be found at:
https://www.mono-project.com/download/
Instructions for compiling Mono can be found at:
https://www.mono-project.com/docs/compiling-mono/linux/
Once the Mono CLR support has been installed, just check that
``/usr/bin/mono`` (which could be located elsewhere, for example
``/usr/local/bin/mono``) is working.
2) You have to compile BINFMT_MISC either as a module or into
the kernel (``CONFIG_BINFMT_MISC``) and set it up properly.
If you choose to compile it as a module, you will have
to insert it manually with modprobe/insmod, as kmod
cannot be easily supported with binfmt_misc.
Read the file ``binfmt_misc.txt`` in this directory to know
more about the configuration process.
3) Add the following entries to ``/etc/rc.local`` or similar script
to be run at system startup:
.. code-block:: sh
# Insert BINFMT_MISC module into the kernel
if [ ! -e /proc/sys/fs/binfmt_misc/register ]; then
/sbin/modprobe binfmt_misc
# Some distributions, like Fedora Core, perform
# the following command automatically when the
# binfmt_misc module is loaded into the kernel
# or during normal boot up (systemd-based systems).
# Thus, it is possible that the following line
# is not needed at all.
mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
fi
# Register support for .NET CLR binaries
if [ -e /proc/sys/fs/binfmt_misc/register ]; then
# Replace /usr/bin/mono with the correct pathname to
# the Mono CLR runtime (usually /usr/local/bin/mono
# when compiling from sources or CVS).
echo ':CLR:M::MZ::/usr/bin/mono:' > /proc/sys/fs/binfmt_misc/register
else
echo "No binfmt_misc support"
exit 1
fi
4) Check that ``.exe`` binaries can be ran without the need of a
wrapper script, simply by launching the ``.exe`` file directly
from a command prompt, for example::
/usr/bin/xsd.exe
.. note::
If this fails with a permission denied error, check
that the ``.exe`` file has execute permissions.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Mono binary 자동 실행 개요
1-10Linux에서 `.exe` 형식의 Mono 기반 .NET binary를 `mono` CLR wrapper 명령 없이 자동 실행하려면 kernel의 `BINFMT_MISC` 지원을 사용할 수 있습니다. 다음 설정을 마치면 일반 program처럼 Mono 기반 .NET binary를 직접 실행할 수 있습니다.
Mono CLR 설치
11-23가장 먼저 Mono CLR 지원을 설치해야 합니다. Binary package, source tarball 또는 Git 설치를 사용할 수 있으며 distribution용 package와 Linux compile 지침은 다음 주소에서 제공합니다.
- Mono binary packages
https://www.mono-project.com/download/ - Compiling Mono on Linux
https://www.mono-project.com/docs/compiling-mono/linux/
설치 후 `/usr/bin/mono`가 동작하는지 확인합니다. 설치 방식에 따라 runtime은 `/usr/local/bin/mono` 같은 다른 경로에 있을 수 있습니다.
BINFMT_MISC kernel 지원
24-31`CONFIG_BINFMT_MISC`를 kernel built-in 또는 module로 compile하고 올바르게 설정해야 합니다. Module로 만들었다면 `kmod`를 `binfmt_misc`와 쉽게 연동할 수 없으므로 `modprobe` 또는 `insmod`로 수동 삽입합니다. 자세한 구성 절차는 같은 directory의 `binfmt_misc.txt`를 참고합니다.
Boot script 등록
32-60System startup 때 실행되는 `/etc/rc.local` 또는 동등한 script에 다음 내용을 추가합니다. 먼저 register interface가 없으면 `binfmt_misc` module을 load하고 filesystem을 mount합니다. Fedora Core 같은 일부 distribution과 systemd 기반 system은 이 mount를 자동 수행하므로 해당 줄이 필요 없을 수 있습니다.
# Insert BINFMT_MISC module into the kernel
if [ ! -e /proc/sys/fs/binfmt_misc/register ]; then
/sbin/modprobe binfmt_misc
# Some distributions, like Fedora Core, perform
# the following command automatically when the
# binfmt_misc module is loaded into the kernel
# or during normal boot up (systemd-based systems).
# Thus, it is possible that the following line
# is not needed at all.
mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
fi
# Register support for .NET CLR binaries
if [ -e /proc/sys/fs/binfmt_misc/register ]; then
# Replace /usr/bin/mono with the correct pathname to
# the Mono CLR runtime (usually /usr/local/bin/mono
# when compiling from sources or CVS).
echo ':CLR:M::MZ::/usr/bin/mono:' > /proc/sys/fs/binfmt_misc/register
else
echo "No binfmt_misc support"
exit 1
fi
Register interface가 준비되면 `MZ` magic을 가진 .NET CLR binary의 interpreter로 `/usr/bin/mono`를 등록합니다. Source 또는 CVS build라면 실제 Mono CLR 경로가 보통 `/usr/local/bin/mono`이므로 환경에 맞게 바꿉니다.
직접 실행 확인
61-70Wrapper script 없이 command prompt에서 `.exe` 파일을 직접 실행해 등록을 확인합니다.
/usr/bin/xsd.exe
`permission denied`가 발생하면 `.exe` 파일에 execute permission이 있는지 확인하십시오.
설정 순서
mono.rst:1-70Mono CLR을 설치하고 `CONFIG_BINFMT_MISC`를 활성화한 뒤 `MZ` binary magic과 Mono interpreter를 register하면 `.exe`를 직접 실행할 수 있습니다.