*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->OpenBSD man pages -> compat_linux (8)              



NAME    [Toc]    [Back]

     compat_linux - setup for running Linux binaries under emulation

DESCRIPTION    [Toc]    [Back]

     OpenBSD  supports running Linux binaries.  This only applies
to i386 systems
 for now.  Both the a.out and  ELF  binary  formats  are
supported.  Most
     programs  should work, including the ones that use the Linux
SVGAlib.  Additionally,
 OSS audio is emulated, so Linux binaries can access the native
  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 OpenBSD
  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
     /etc/passwd  file.   It  is  recommended that Linux packages
that include
     configuration files, etc., be installed  under  /emul/linux,
to avoid naming
  conflicts  with  possible OpenBSD counterparts.  Shared
     should also be installed in the shadow tree.

     Generally, it will only be necessary to look for the  shared
     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 sufficient
 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    [Toc]    [Back]
     How to get to know which  shared  libraries  Linux  binaries
need, and where
     to  get  them?  Basically, there are 3 possibilities.  (When
     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
          redhat/base in the emulators category.  The redhat/base
port contains
 the shared libraries, binaries, and other related
files necessary
 to run Linux applications.  Access to a Linux system is not

     2.    Access to a Linux system: In this case temporarily install the binary
 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 running
 `ldd linuxxdoom':

                (me@linux) ldd linuxxdoom

                libXt.so.3       (DLL      Jump      3.1)      =>
                libX11.so.3      (DLL      Jump      3.1)      =>
                libc.so.4      (DLL      Jump     4.5pl26)     =>

          Get all the files from the last column,  and  put  them
          /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 (symbolic link
to the above)
                /emul/linux/usr/X11/lib/libX11.so.3     (symbolic
link to the above)
                /emul/linux/lib/libc.so.4  (symbolic  link to the

          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      ->      /emul/linux/lib/libc.so.4.6.27

          and the ldd output for a new binary is:

                libc.so.4      (DLL      Jump     4.5pl26)     =>

          it isn't necessary to copy /lib/libc.so.4.6.29 too, because the program
  should work fine with the slightly older version.
libc.so can
          be replaced anyway, and that should leave:

                /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 Linux
 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 present
 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):


     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 version
  mismatches),  and  install them under /emul/linux
(i.e. /foo/bar
          is installed as /emul/linux/foo/bar):


          ldconfig and ldd don't necessarily  need  to  be  under
          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 ldconfiglinux and

          Create the file /emul/linux/etc/ld.so.conf,  containing
the directories
  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


          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 only
 need a shared libc.  Test this by running the  Linux
ldd on itself.
   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)      =>

          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 depends
  on,  in the form  <majorname> (<jumpversion>) =>

          If it prints "not found" instead of <fullname> it means
that an extra
 library is needed.  Which library this is, is shown
in <majorname>,
 which will be of the form libXXXX.so.<N>.   Find
          libXXXX.so.<N>.<mm> on a Linux ftp site, and install it
on the
          OpenBSD system.  The XXXX (name) and <N>  (major  revision number)
          should  match; the minor number(s) <mm> are less important, though it
          is advised to take the most recent version.

   Finding the necessary files    [Toc]    [Back]
     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 binaries
 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 consisting
 of subdirectories with gzipped tar  files  in  them.
The primary
     ftp sites for the distributions are:


     Some European mirrors:


     For  simplicity,  let's concentrate on Slackware here.  This
     consists of a number of subdirectories, containing  separate
     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 packages
  needed  from the following files (relative to the root
of the Slackware
 distribution tree):


     Extract  the  files  from  these  gzipped  tarfiles  in  the
/emul/linux directory
  (possibly  omitting  or  afterwards removing unnecessary

   Programs using SVGAlib    [Toc]    [Back]
     SVGAlib binaries require some extra care.  The pcvt  virtual
console driver
  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

   Programs using OSS (Linux) audio    [Toc]    [Back]
     Only the DSP device is emulated, the following  link  should
be created:

           /emul/linux/dev/dsp -> /dev/audio

   Other links Linux binaries may require    [Toc]    [Back]
     CD-ROM  support requires a link to the cdrom device, similar

           /emul/linux/dev/cdrom -> /dev/cd0a (first CD-ROM)

   File systems    [Toc]    [Back]
     Many Linux binaries expect /proc to have procfs  mounted  on
it.  Some binaries
  will require it to be mounted using the -o linux option.

BUGS    [Toc]    [Back]

     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,

           % elf2olf -o linux <linux_binary>

     compat_linux is currently only supported on the i386.

OpenBSD      3.6                           March      2,     1995
[ Back ]
 Similar pages
Name OS Title
compat_osf1 OpenBSD setup for running OSF/1 binaries under emulation
compat_hpux OpenBSD setup for running HP-UX binaries under emulation
compat_bsdos OpenBSD setup for running BSDI binaries under emulation
compat_ibcs2 OpenBSD setup for running iBCS2 binaries under emulation
compat_freebsd OpenBSD setup for running FreeBSD binaries under emulation
compat_sunos OpenBSD setup for running SunOS binaries under emulation
compat_ultrix OpenBSD setup for running Ultrix binaries under emulation
compat_svr4 OpenBSD setup for running SVR4/iBCS2 binaries under emulation
compat_aout OpenBSD setup for running a.out OpenBSD binaries on ELF systems
install OpenBSD install binaries
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service