Skip site navigation (1)Skip section navigation (2)
Date:      Fri,  5 Jan 1996 00:00:37 +0300 (MSK)
From:      "Maksim Stolyarov" <mns@td.lpi.ac.ru>
To:        doc@freebsd.org, questions@freebsd.org
Subject:   LinuxEmu Doc / Together?
Message-ID:  <AGr_3xmecE@td.lpi.ac.ru>

next in thread | raw e-mail | index | archive | help



According to:

> Date: Wed, 3 Jan 1996 13:08:08 -0800 (PST)
> From: Doug White <riley-net170-164.uoregon.edu!dwhite@td.lpi.ac.ru>
> Subject: Linux Emulation now operational! :)

> In any case, it IS working!  I am thinking of working up some formal docs 
> on how to get linuxemu up, and hopefully get it added to places like the 
> FAQ or Handbook.  

> Thanks all!  

> Doug White                              | University of Oregon  
> Internet:  dwhite@gladstone.uoregon.edu | Residence Networking Assistant
> http://gladstone.uoregon.edu/~dwhite    | Computer Science Major


	Hi All!

	I found in my mail-archive some semi-ready docs on LinuxEmu.
	Doug (and maybe authors of that docs also? somebody else?), we
	could fill this "white spot" in FAQ/Handbook. In principle
	I could coordinate this small sub-project but my English is	
	not very perfect for writing docs.


	Maybe these HOWTO(s) will be useful for someone in future
	mail-archive searches ...

	Please send any suggestions to  mns@lpi.ac.ru

	Best regards,
						Maksim.


	P.S. Sorry for such HUGE mail tail :-)


############################################################################
LinuxEmu/HOWTO 1/2
------------------

* Date: Wed, 20 Sep 1995 09:27:00 -0500
* From: Rich Murphey <rich@lamprey.utmb.edu>
* Subject: linux compatibility man page

I took netbsd's man page for linux compatibility and added a
brief installation guide.  I've sent Jordan the nroff source
for review.

Any suggestions are welcome!


Many thanks to Soren Schmidt for the emulator itself! Rich




COMPAT LINUX(8)          UNIX System Manager's Manual          COMPAT LINUX(8)
      -                                                              -

NAME
     COMPAT LINUX - setup procedure for running Linux binaries
           -

INSTALL
     In order to run static and dynamicly linked Linux binaries, you need a
     kernel configured with options COMPAT LINUX. Include options SYSVSHM as
                                          -
     well if you plan to run the linux version of doom.

     cd /sys/i386/conf
     echo options '"COMPAT LINUX"' >> GENERIC
                          -
     echo options SYSVSHM >> GENERIC
     config GENERIC
     cd /sys/compile/GENERIC
     make depend; make
     make install

     If you don't already have it, build the loadable kernel module
     /lkm/linux mod.o.
               -

     cd /usr/src/lkm/linux
     make all install clean

     Once you have both the kernel and lkm installed, invoke

     linux

     as root to load the emulator into the kernel.

TESTING
     To test the emulator using the linux version of the game doom, first get
     the linux shared libraries.

     mkdir /compat/linux
     cd /compat/linux
     ncftp ftp.freebsd.org:pub/FreeBSD/2.0.5-RELEASE/xperimnt/linux-emu/linux-emu.tar.gz
     tar xzf linux-emu.tar.gz
     rm -rf usr lkm linux-emu.tar.gz

     The lkm and usr portion of this tar file are redundant since you already
     have the lkm and /usr/bin/linux.  Next install doom itself.

     ncftp ftp.freebsd.org:pub/FreeBSD/2.0.5-RELEASE/xperimnt/linux-emu/linux-doom-1.8.tar.gz
     tar xzf linux-doom-1.8.tar.gz
     cd doom-1.8
     xdoom

DESCRIPTION
     Most Linux binaries should work, except programs that use Linux-specific
     features. These include the Linux /proc filesystem (which is different
     from the optional FreeBSD /proc filesystem), and i386-specific calls,
     such as enabling virtual 8086 mode.

     Many linux programs are dynamically linked. So you will also need the
     Linux shared libraries that the program depends on, and the runtime link-
     er.  Also, you will need to create a "shadow root" directory for Linux
     binaries on your FreeBSD system. This directory is named /compat/linux.
     Any file operations done by Linux programs run under FreeBSD will look in
     this directory first.  So, if a Linux program opens, for example,
     /etc/passwd, FreeBSD will first try to open /compat/linux/etc/passwd, and
     if that does not exist open the packages that include configuration
     files, etc under /compat/linux, to avoid naming conflicts with possible
     FreeBSD counterparts. Shared libraries should also be installed in the
     shadow tree.

     Generally, you will need to look for the shared libraries that Linux bi-
     naries depend on only the first few times that you install a Linux pro-
     gram on your FreeBSD system. After a while, you will have a sufficient
     set of Linux shared libraries on your system to be able to run newly im-
     ported 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 2 possibilities (when following these
     instructions: you will need to be root on your FreeBSD system to do the
     necessary installation steps).

     1.   If you have access to a Linux system, see what shared libraries it
          needs, and copy them to your FreeBSD system. Example: you have just
          ftp-ed the Linux binary of Doom. Put it on the Linux system you have
          access to, and check which shared libraries it needs by running `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

          You would need go get all the files from the last column, and put
          them under /compat/linux, with the names in the first column as sym-
          bolic links pointing to them. This means you eventually have these
          files on your FreeBSD system:

          /compat/linux/usr/X11/lib/libXt.so.3.1.0
          /compat/linux/usr/X11/lib/libXt.so.3 (symbolic link to the above)
          /compat/linux/usr/X11/lib/libX11.so.3.1.0
          /compat/linux/usr/X11/lib/libX11.so.3 (symbolic link to the above)
          /compat/linux/lib/libc.so.4.6.29
          /compat/linux/lib/libc.so.4 (symbolic link to the above)

          Note that if you already have a Linux shared library with a matching
          major revision number to the first column of the 'ldd' output, you
          won't need to copy the file named in the last column to your system,
          the one you already have should work. It is advisable to copy the
          shared library anyway if it is a newer version, though. You can re-
          move the old one, as long as you make the symbolic link point to the
          new one. So, if you have these libraries on your system:

          /compat/linux/lib/libc.so.4.6.27
          /compat/linux/lib/libc.so.4 -> /compat/linux/lib/libc.so.4.6.27

          and you find that the ldd output for a new binary you want to in-
          stall is:

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

          you won't need to worry about copying /lib/libc.so.4.6.29 too, be-
          cause the program should work fine with the slightly older version.
          You can decide to replace the libc.so anyway, and that should leave
          you with:

          /compat/linux/lib/libc.so.4.6.29
          /compat/linux/lib/libc.so.4 -> /compat/linux/lib/libc.so.4.6.29

          Please note that the symbolic link mechanism is only needed for Lin-
          ux binaries, the FreeBSD runtime linker takes care of looking for
          matching major revision numbers itself, you don't need to worry
          about that.

          Finally, you must make sure that you have the Linux runtime linker
          and its config files on your system. You should copy these files
          from the Linux system to their appropriate place on your FreeBSD
          system (to the /compat/linux tree):

          /lib/ld.so
          /etc/ld.so.cache
          /etc/ld.so.config

     2.   You don't have access to a Linux system. In that case, you should
          get the extra files you need from various ftp sites.  Information on
          where to look for the various files is appended below. For now,
          let's assume you know where to get the files.

          Retrieve the following files (all from the same ftp site to avoid
          any version mismatches), and install them under /compat/linux (i.e.
          /foo/bar is installed as /compat/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 /compat/linux,
          you can install them elsewhere in the system too. Just make sure
          they don't conflict with their FreeBSD counterparts. A good idea
          would be to install them in /usr/local/bin as ldconfig-linux and
          ldd-linux.

          Create the file /compat/linux/etc/ld.so.conf, containing the direc-
          tories 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, you could add the following:

          /usr/X11/lib
          /usr/local/lib

          Note that these are mapped to /compat/linux/XXXX by FreeBSD's compat
          code, and should exist as such on your 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 /compat/linux/etc/ld.so.cache You should rerun the Linux ver-
          sion of the ldconfig program each time you add a new shared library.

          You should now be set up for Linux binaries which only need a shared
          libc. You can test this by running the Linux ldd on itself. Suppose
          that you have it installed as ldd-linux, it should produce something
          like:

                (me@FreeBSD) ldd-linux `which ldd-linux`
                     libc.so.4 (DLL Jump 4.5pl26) => /lib/libc.so.4.6.29

          This being done, you are ready to install new Linux binaries.  When-
          ever you install a new Linux program, you should check if it needs
          shared libraries, and if so, whether you have them installed in the
          /compat/linux tree. To do this, you 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>) => <fullname>.

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


   Finding the necessary files.
     Note: the information below is valid as of the ime this document was
     written (March, 1995), but certain details such as names of ftp sites,
     directories and distribution names may have changed by the time you read
     this.

     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 you can get the individ-
     ual files you need, but mostly they are stored in distribution sets, usu-
     ally consisting of subdirectories with gzipped tar files in them. The
     primary ftp sites for the distributions are:

     sunsite.unc.edu:/pub/Linux/distributions
     tsx-11.mit.edu:/pub/linux/distributions

     Some European mirrors:

     ftp.luth.se:/pub/linux/distributions
     ftp.demon.co.uk:/pub/linux/distributions
     src.doc.ic.ac.uk:/packages/linux/distributions

     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 you can retrieve
     files "by hand" too. First of all, you will need to look in the "con-
     tents" subdir of the distribution. You will find a lot of small textfiles
     here describing the contents of the seperate packages. The fastest way to
     look something up is to retrieve all the files in the contents subdirec-
     tory, and grep through them for the file you need. Here is an example of
     a list of files that you might need, and in which contents-file you will
     find it by grepping through them:

           Needed                  Package

           ld.so                   ldso
           ldconfig                ldso
           ldd                     ldso
           libc.so.4               shlibs
           libX11.so.6.0           xf lib
                                     -
           libXt.so.6.0            xf lib
                                     -
           libX11.so.3             oldlibs
           libXt.so.3              oldlibs

     So, in this case, you will need the packages ldso, shlibs, xf lib and
                                                                  -
     oldlibs.  In each of the contents-files for these packages, look for a
     line saying "PACKAGE LOCATION", it will tell you on which 'disk' the
     package is, in our case it will tell us in which subdirectory we need to
     look.  For our example, we would find the following locations:

           Package                 Location

           ldso                    diska2
           shlibs                  diska2
           oldlibs                 diskx6
           xf lib                  diskx9
             -

     The locations called "diskXX" refer to the "slakware/XX" subdirectories
     of the distribution, others may be found in the "contrib" subdirectory.
     In this case, we could now retrieve the packages we need by retrieving
     the following files (relative to the root of the Slackware distribution
     tree):

     slakware/a2/ldso.tgz
     slakware/a2/shlibs.tgz
     slakware/x6/oldlibs/tgz
     slakware/x9/xf lib.tgz
                   -

     Extract the files from these gzipped tarfiles in your /compat/linux di-
     rectory (possibly omitting or afterwards removing files you don't need),
     and you are done.

BUGS
     The information about Linux distributions may become outdated.

SEE ALSO
     ftp.freebsd.org:pub/FreeBSD/2.0.5-RELEASE/xperimnt/linux-emu/README

     /usr/src/sys/i386/ibcs2/README.iBCS2

4th Berkeley Distribution        March 2, 1995

                               5

############################################################################
LinuxEmu/HOWTO 2/2
------------------



* Date: Wed, 3 Jan 1996 12:26:56 -0500
* From: Brian Clapper <telebase.com!bmc@td.lpi.ac.ru>
* Subject: Re: Linux Emulation


I just got the Linux version of Netscape (1.2) running with no problem on
FreeBSD 2.1.  (It's not that I actually want to *use* Linux's Netscape, but
it's a bloated enough application to make a good test case.)

Here are the steps I followed:

1. Build a new kernel, with the following option:

        options COMPAT_LINUX

2. Install the kernel and reboot.  (Of course.)

3. Load the Linux compatibility module:

        odo (/usr/local/bin) # modload -e linux_init /lkm/linux_mod.o
        Linux emulator installed
        Module loaded as ID 0
        odo (/usr/local/bin) # modstat
        Type     Id Off Loadaddr Size Info     Rev Module Name
        EXEC      0   3 f0925000 0018 f092a000   1 linux_emulator

4. Install the Linux compatibility libraries from the Ports collection:

    a. Get ftp://ftp.freebsd.org/pub/FreeBSD/FreeBSD-current/ports/emulators/linux_lib.tar.gz
    b. Extract it.
    c. Build it.
    d. Install it.  It creates files in /compat/linux/lib

5. Try to run your application.

Now, when I tried to run the Linux version of Netscape, it came up, but
aborted with the following errors:

        resolv+: "bind" is an invalid keyword
        resolv+: "hosts" is an invalid keyword

It turns out Linux has an "/etc/host.conf" and FreeBSD has one, but they
appear to be incompatible.  I moved my "/etc/host.conf" out of the way
(temporarily), and the Linux Netscape came up perfectly.  Of course, I
connected to "www.freebsd.org" as a test...

Perhaps there's a way to point the Linux executables at a separate /etc
tree which contains a Linux "host.conf".  If there is, I don't know how,
though.
----
Brian Clapper, bmc@telebase.com, http://www.netaxs.com/~bmc/
"In defeat, unbeatable; in victory, unbearable."
        -- Winston Curchill, of Montgomery




---
Maksim N. Stolyarov  -> mns@lpi.ac.ru <-  |  Vesso-Link pager
 Department of Theoretical Physics,       |  +7(095)974-0111, pager 4597
  Lebedev Physical Institute, RAS         |  Email -> Pager
Leninskii 53, 117924, Moscow, Russia      |  pager@vlpage.sovam.com
fax: +7(95)135-8533, tel: +7(95)132-6024  |  vl#4597 - first line of mail body




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AGr_3xmecE>