免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1602 | 回复: 0
打印 上一主题 下一主题

COMPAT_LINUX(8) OpenBSD Man [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-01-23 11:54 |只看该作者 |倒序浏览
COMPAT_LINUX(8)         OpenBSD System Manager's Manual        COMPAT_LINUX(8)
NAME
     compat_linux - setup for running Linux binaries under emulation
DESCRIPTION
     OpenBSD supports running Linux binaries.  This only applies to i386 sys-
     tems for now.  Both the a.out and ELF binary formats are supported.  Most
     programs should work, including the ones that use the Linux SVGAlib.  Ad-
     ditionally, OSS audio is emulated, so Linux binaries can access the na-
     tive audio transparently.  Programs that will not work include those that
     use i386-specific calls, such as enabling virtual 8086 mode.
     The Linux compatibility feature is active for kernels compiled with the
     COMPAT_LINUX option and kern.emul.linux
sysctl(8)
enabled.
     A lot of programs are dynamically linked.  This means that the Linux
     shared libraries that the programs depend on and the runtime linker are
     also needed.  Additionally, a "shadow root" directory for Linux binaries
     on the OpenBSD system will have to be created.  This directory is named
     /emul/linux.  Any file operations done by Linux programs run under OpenB-
     SD will look in this directory first.  So, if a Linux program opens, for
     example, /etc/passwd, OpenBSD will first try to open
     /emul/linux/etc/passwd, and if that does not exist open the `real'
     /etc/passwd file.  It is recommended that Linux packages that include
     configuration files, etc., be installed under /emul/linux, to avoid nam-
     ing conflicts with possible OpenBSD counterparts.  Shared libraries
     should also be installed in the shadow tree.
     Generally, it will only be necessary to look for the shared libraries
     that Linux binaries depend on the first few times that Linux programs are
     installed on the OpenBSD system.  After a while, there will be a suffi-
     cient set of Linux shared libraries on the system to be able to run newly
     imported Linux binaries without any extra work.
   Setting up shared libraries
     How to get to know which shared libraries Linux binaries need, and where
     to get them?  Basically, there are 3 possibilities.  (When following
     these instructions, root privileges are required on the OpenBSD system to
     perform the necessary installation steps).
     1.   Access to the OpenBSD
ports(7)
system: Install the port named
          redhat/base in the emulators category.  The redhat/base port con-
          tains the shared libraries, binaries, and other related files neces-
          sary to run Linux applications.  Access to a Linux system is not
          needed.
     2.   Access to a Linux system: In this case temporarily install the bina-
          ry there, see what shared libraries it needs, and copy them to the
          OpenBSD system.  Example: ftp the Linux binary of Doom.  Put it on
          the Linux system, and check which shared libraries it needs by run-
          ning `ldd linuxxdoom':
                (me@linux) ldd linuxxdoom
                libXt.so.3 (DLL Jump 3.1) => /usr/X11/lib/libXt.so.3.1.0
                libX11.so.3 (DLL Jump 3.1) => /usr/X11/lib/libX11.so.3.1.0
                libc.so.4 (DLL Jump 4.5pl26) => /lib/libc.so.4.6.29
          Get all the files from the last column, and put them under
          /emul/linux, with the names in the first column as symbolic links
          pointing to them.  The following files would therefore be required
          on the OpenBSD system:
                /emul/linux/usr/X11/lib/libXt.so.3.1.0
                /emul/linux/usr/X11/lib/libXt.so.3 (symbolic link to the above)
                /emul/linux/usr/X11/lib/libX11.so.3.1.0
                /emul/linux/usr/X11/lib/libX11.so.3 (symbolic link to the above)
                /emul/linux/lib/libc.so.4.6.29
                /emul/linux/lib/libc.so.4 (symbolic link to the above)
          Note that if a Linux shared library with a matching major revision
          number to the first column of the 'ldd' output is already present,
          it isn't necessary to copy the file named in the last column to the
          OpenBSD system; the one already there should work.  It is advisable
          to copy the shared library anyway, if it is a newer version.  The
          old one can be removed, as long as the symbolic link points to the
          new one.  So, if these libraries exist on the system:
                /emul/linux/lib/libc.so.4.6.27
                /emul/linux/lib/libc.so.4 -> /emul/linux/lib/libc.so.4.6.27
          and the ldd output for a new binary is:
                libc.so.4 (DLL Jump 4.5pl26) => /lib/libc.so.4.6.29
          it isn't necessary to copy /lib/libc.so.4.6.29 too, because the pro-
          gram should work fine with the slightly older version.  libc.so can
          be replaced anyway, and that should leave:
                /emul/linux/lib/libc.so.4.6.29
                /emul/linux/lib/libc.so.4 -> /emul/linux/lib/libc.so.4.6.29
          Please note that the symbolic link mechanism is only needed for Lin-
          ux binaries, the OpenBSD runtime linker takes care of looking for
          matching major revision numbers itself.
          Finally, the Linux runtime linker and its config files must be pre-
          sent on the system.  These files should be copied from the Linux
          system to their appropriate place on the OpenBSD system (in the
          /emul/linux tree):
                /lib/ld.so
                /etc/ld.so.cache
                /etc/ld.so.config
     3.   No access to a Linux system: In that case, get the extra files from
          various ftp sites.  Information on where to look for the various
          files is appended below.
          Retrieve the following files (from _one_ ftp site to avoid any ver-
          sion mismatches), and install them under /emul/linux (i.e. /foo/bar
          is installed as /emul/linux/foo/bar):
                /sbin/ldconfig
                /usr/bin/ldd
                /lib/libc.so.x.y.z
                /lib/ld.so
          ldconfig and ldd don't necessarily need to be under /emul/linux,
          they can be installed elsewhere in the system too.  Just make sure
          they don't conflict with their OpenBSD counterparts.  A good idea
          would be to install them in /usr/local/bin as ldconfig-linux and
          ldd-linux.
          Create the file /emul/linux/etc/ld.so.conf, containing the directo-
          ries in which the Linux runtime linker should look for shared libs.
          It is a plain text file, containing a directory name on each line.
          /lib and /usr/lib are standard; the following could be added:
                /usr/X11/lib
                /usr/local/lib
          Note that these are mapped to /emul/linux/XXXX by the OpenBSD compat
          code, and should exist as such on the OpenBSD system.
          Run the Linux ldconfig program.  It should be statically linked, so
          it doesn't need any shared libraries by itself.  It will create the
          file /emul/linux/etc/ld.so.cache.  The Linux version of the ldconfig
          program should be rerun each time a new shared library is added.
          The OpenBSD system should now be set up for Linux binaries which on-
          ly need a shared libc.  Test this by running the Linux ldd on it-
          self.  Suppose that it is installed as ldd-linux, it should produce
          something like:
                % ldd-linux `which ldd-linux`
                libc.so.4 (DLL Jump 4.5pl26) => /lib/libc.so.4.6.29
          This being done, new Linux binaries can now be installed.  Whenever
          a new Linux program is installed, it should be determined if it
          needs shared libraries, and if so, whether they are installed in the
          /emul/linux tree.  To do this, run the Linux version ldd on the new
          program, and watch its output.  ldd (see also the manual page for
         
ldd(1)
) will print a list of shared libraries that the program de-
          pends on, in the form   () => .
          If it prints "not found" instead of  it means that an ex-
          tra library is needed.  Which library this is, is shown in , which will be of the form libXXXX.so..  Find a
          libXXXX.so.. on a Linux ftp site, and install it on the
          OpenBSD system.  The
XXXX (name)
and  (major revision number)
          should match; the minor number(s)  are less important, though it
          is advised to take the most recent version.
   Finding the necessary files
     Note: the information below is valid as of Feb 2003, but certain details
     such as names of ftp sites, directories and distribution names may have
     changed since then.  It is much easier to use the OpenBSD
ports(7)
system
     (possibility 1, above).
     Linux is distributed by several groups that make their own set of bina-
     ries that they distribute.  Each distribution has its own name, like
     "Slackware" or "Yggdrasil".  The distributions are available on a lot of
     ftp sites.  Sometimes the files are unpacked, and individual files can be
     retrieved, but mostly they are stored in distribution sets, usually con-
     sisting of subdirectories with gzipped tar files in them.  The primary
     ftp sites for the distributions are:
           ftp.ibiblio.org:/pub/Linux/distributions
           distro.ibiblio.org:/pub/Linux/distributions
     Some European mirrors:
           ftp.sunet.se:/pub/Linux/distributions
           src.doc.ic.ac.uk:/packages/linux
     For simplicity, let's concentrate on Slackware here.  This distribution
     consists of a number of subdirectories, containing separate packages.
     Normally, they're controlled by an install program, but the files can be
     retrieved "by hand" too.  The fastest way to find something is to
grep(1)
     the file FILELIST.TXT for the files needed.  Here is an example of a list
     of files that might be needed, and in which package it can be found:
           Needed                  Package
           ld-2.2.5.so             glibc
           ldconfig                glibc
           ldd                     glibc
           libc.so.6               glibc
           libX11.so.6             xfree
           libXt.so.6              xfree
     So, in this case, the packages glibc and xfree will be needed.
     FILELIST.TXT also gives the location of the packages.  Retrieve the pack-
     ages needed from the following files (relative to the root of the Slack-
     ware distribution tree):
           slackware/l/glibc-2.2.5-i386.2.tgz
           slackware/x/xfree-4.2.0-i386.5.tgz
     Extract the files from these gzipped tarfiles in the /emul/linux directo-
     ry (possibly omitting or afterwards removing unnecessary files).
   Programs using SVGAlib
     SVGAlib binaries require some extra care.  The pcvt virtual console driv-
     er has to be in the kernel for them to work, and some symbolic links in
     the /emul/linux/dev directory will have to be created, namely:
           /emul/linux/dev/console -> /dev/tty
           /emul/linux/dev/mouse -> whatever device the mouse is connected to
           /emul/linux/dev/ttyS0 -> /dev/tty00
           /emul/linux/dev/ttyS1 -> /dev/tty01
     Be warned: the first link mentioned here makes SVGAlib binaries work, but
     may confuse others, so it may be necessary to remove it again at some
     point.
   Programs using
OSS (Linux)
audio
     Only the DSP device is emulated, the following link should be created:
           /emul/linux/dev/dsp -> /dev/audio
   Other links Linux binaries may require
     CD-ROM support requires a link to the CD-ROM device, similar to:
           /emul/linux/dev/cdrom -> /dev/cd0a (first CD-ROM)
   File systems
     Many Linux binaries expect /proc to have procfs mounted on it.  Some bi-
     naries will require it to be mounted using the -o linux option.
BUGS
     The information about Linux distributions may become outdated.
     Linux ELF binaries may be detected as SVR4 binaries.  This can usually be
     fixed with
elf2olf(1)
by setting the OLF opsys tag to Linux, e.g.
           % elf2olf -o linux
     compat_linux is currently only supported on the i386.
OpenBSD 4.0                      March 2, 1995                               4
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/22965/showart_236495.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP