|COMPAT_LINUX(8)||System Manager's Manual||COMPAT_LINUX(8)|
The Linux compatibility feature is active for kernels compiled
COMPAT_LINUX option and kern.emul.linux
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 `real' /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 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 sufficient set of Linux shared libraries on the system to be able to run newly imported Linux binaries without any extra work.OpenBSD system to perform the necessary installation steps).
fedora/baseport contains the shared libraries, binaries, and other related files necessary to run Linux applications. Access to a Linux system is not needed.
(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 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.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 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):
/lib/ld.so /etc/ld.so.cache /etc/ld.so.config
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):
/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 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 added:
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`
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>) => <fullname>.
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 a 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.
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 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 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 files)./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.
compat_linux is currently only supported
on the i386.
|October 22, 2009||OpenBSD-5.1|