1 .\" $NetBSD: compat_linux.8,v 1.35 2007/12/02 21:44:58 wiz Exp $
3 .\" Copyright (c) 1995 Frank van der Linden
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. All advertising materials mentioning features or use of this software
15 .\" must display the following acknowledgement:
16 .\" This product includes software developed for the NetBSD Project
17 .\" by Frank van der Linden
18 .\" 4. The name of the author may not be used to endorse or promote products
19 .\" derived from this software without specific prior written permission
21 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 .Nd setup procedure for running Linux binaries
40 supports running Linux binaries.
41 This applies to amd64, arm, alpha, i386, m68k, and powerpc systems for now.
42 Both the a.out and ELF binary formats are supported.
43 Most programs should work, including the ones that use the Linux SVGAlib (only
46 amd64 can execute both 32bit and 64bit linux programs.
47 Programs that will not work include some that use
48 i386-specific calls, such as enabling virtual 8086 mode.
49 Currently, sound is only partially supported for Linux binaries (they will
50 probably run, depending on what Linux sound support features are used).
52 The Linux compatibility feature is active
53 for kernels compiled with the
56 If support for Linux a.out executables is desired, the
58 option should be enabled in addition to option
60 Similarly, if support for Linux 32-bit and/or 64-bit ELF executables
65 options (respectively) should be enabled in addition to
68 A lot of programs are dynamically linked.
69 This means that you will also need the Linux shared libraries that the
70 program depends on, and the runtime linker.
71 Also, you will need to create a
73 directory for Linux binaries on your
76 This directory is named
80 for 32bit emulation on 64bit systems.
81 Any file operations done by Linux programs run under
83 will look in this directory first.
84 So, if a Linux program opens, for example,
89 .Pa /emul/linux/etc/passwd ,
90 and if that does not exist open the
94 It is recommended that you install
95 Linux packages that include configuration files, etc under
97 to avoid naming conflicts with possible
100 Shared libraries should also be installed in the shadow tree.
101 Filenames that start "/../" are only looked up in the real root.
103 Generally, you will need to look for the shared libraries that Linux
104 binaries depend on only the first few times that you install a Linux
108 After a while, you will have a sufficient
109 set of Linux shared libraries on your system to be able to run newly
110 imported Linux binaries without any extra work.
111 .Ss Setting up shared libraries
112 How to get to know which shared libraries Linux binaries need, and where
113 to get them? Basically, there are 2 possibilities (when following
114 these instructions: you will need to be root on your
117 do the necessary installation steps).
120 For i386, you can simply install the SuSE shared libs using the
121 .Pa pkgsrc/emulators/suse100_linux
123 On PowerPC ports, the
124 .Pa pkgsrc/emulators/linuxppc_lib
125 will install the needed libraries.
126 If you are on other platforms, or this doesn't supply you with all
127 the needed libraries, read on.
129 You have access to a Linux system.
130 In this case you can temporarily install the binary there, see what
131 shared libraries it needs, and copy them to your
134 Example: you have just ftp-ed the Linux binary of Doom.
135 Put it on the Linux system you have access to, and check which shared libraries it
139 .Bl -tag -width 123 -compact -offset indent
140 .It (me@linux) ldd linuxxdoom
142 libXt.so.3 (DLL Jump 3.1) =\*[Gt] /usr/X11/lib/libXt.so.3.1.0
143 libX11.so.3 (DLL Jump 3.1) =\*[Gt] /usr/X11/lib/libX11.so.3.1.0
144 libc.so.4 (DLL Jump 4.5pl26) =\*[Gt] /lib/libc.so.4.6.29
148 You would need go get all the files from the last column, and
151 with the names in the first column
152 as symbolic links pointing to them.
153 This means you eventually have these files on your
158 .Pa /emul/linux/usr/X11/lib/libXt.so.3.1.0
160 .Pa /emul/linux/usr/X11/lib/libXt.so.3
161 (symbolic link to the above)
163 .Pa /emul/linux/usr/X11/lib/libX11.so.3.1.0
165 .Pa /emul/linux/usr/X11/lib/libX11.so.3
166 (symbolic link to the above)
168 .Pa /emul/linux/lib/libc.so.4.6.29
170 .Pa /emul/linux/lib/libc.so.4
171 (symbolic link to the above)
174 Note that if you already have a Linux shared library with a
175 matching major revision number to the first column of the
177 output, you won't need to copy the file named in the last column
178 to your system, the one you already have should work.
179 It is advisable to copy the shared library anyway if it is a newer version,
181 You can remove the old one, as long as you make the symbolic
182 link point to the new one.
183 So, if you have these libraries on your system:
187 .Pa /emul/linux/lib/libc.so.4.6.27
189 .Pa /emul/linux/lib/libc.so.4
191 .Pa /emul/linux/lib/libc.so.4.6.27
194 and you find that the
196 output for a new binary you want to install is:
199 libc.so.4 (DLL Jump 4.5pl26) =\*[Gt] /lib/libc.so.4.6.29
202 you won't need to worry about copying
203 .Pa /lib/libc.so.4.6.29
204 too, because the program should work fine with the slightly older version.
205 You can decide to replace the libc.so anyway, and that should leave
209 .Pa /emul/linux/lib/libc.so.4.6.29
211 .Pa /emul/linux/lib/libc.so.4
213 .Pa /emul/linux/lib/libc.so.4.6.29
216 Please note that the symbolic link mechanism is
218 needed for Linux binaries, the
220 runtime linker takes care of
221 looking for matching major revision numbers itself, you
222 don't need to worry about that.
224 Finally, you must make sure that you have the Linux runtime linker
225 and its config files on your system.
226 You should copy these
227 files from the Linux system to their appropriate place on your
238 .Pa /etc/ld.so.config
241 You don't have access to a Linux system.
242 In that case, you should get the extra files you need from various ftp sites.
243 Information on where to look for the various files is appended below.
244 For now, let's assume you know where to get the files.
246 Retrieve the following files (from _one_ ftp site to avoid
247 any version mismatches), and install them under
252 .Pa /emul/linux/foo/bar ) :
260 .Pa /lib/libc.so.x.y.z
268 don't necessarily need to be under
270 you can install them elsewhere in the system too.
271 Just make sure they don't conflict with their
274 A good idea would be to install them in
282 .Pa /emul/linux/etc/ld.so.conf ,
283 containing the directories in which the Linux runtime linker should look
285 It is a plain text file, containing a directory name on each line.
289 are standard, you could add the following:
297 Note that these are mapped to
302 code, and should exist as such on your system.
307 It should be statically
308 linked, so it doesn't need any shared libraries by itself.
309 It will create the file
310 .Pa /emul/linux/etc/ld.so.cache
311 You should rerun the Linux version of
313 each time you add a new shared library.
315 You should now be set up for Linux binaries which only need
317 You can test this by running the Linux
320 Suppose that you have it installed as
322 it should produce something like:
324 .Bl -tag -width 123 -compact -offset indent
325 .It (me@netbsd) ldd-linux `which ldd-linux`
326 libc.so.4 (DLL Jump 4.5pl26) =\*[Gt] /lib/libc.so.4.6.29
329 This being done, you are ready to install new Linux binaries.
330 Whenever you install a new Linux program, you should check
331 if it needs shared libraries, and if so, whether you have
332 them installed in the
335 To do this, you run the Linux
337 on the new program, and watch its output.
339 (see also the manual page for
342 of shared libraries that the program depends on, in the
353 it means that you need an extra library.
354 Which library this is, is shown in
356 which will be of the form libXXXX.so.\*[Lt]N\*[Gt]
357 You will need to find a libXXXX.so.\*[Lt]N\*[Gt].\*[Lt]mm\*[Gt] on a
358 Linux ftp site, and install it on your system.
361 (major revision number) should match; the minor number(s)
363 are less important, though it is advised to take the most recent version.
365 Set up linux specific devices:
367 .Bl -tag -width 123 -compact -offset indent
368 .It (me@netbsd) cd /usr/share/examples/emul/linux/etc
370 .It (me@netbsd) cp LINUX_MAKEDEV /emul/linux/dev
372 .It (me@netbsd) cd /emul/linux/dev \*[Am]\*[Am] sh LINUX_MAKEDEV all
375 .Ss Setting up procfs
376 Some Linux binaries expect procfs to be mounted and that it would
377 contain some Linux specific stuff.
378 If it's not the case, they behave unexpectedly or even crash.
382 using following command:
383 .Bl -tag -width 123 -offset indent
384 .It (me@netbsd) mount_procfs -o linux procfs /emul/linux/proc
387 You can also set up your system so that procfs is mounted automatically
388 on system boot, by putting an entry like the one below to
390 .Bl -tag -width 123 -offset indent
391 .It procfs /emul/linux/proc procfs ro,linux
396 for further information.
397 .Ss Setting up other files
398 Newer version of Linux use
399 .Pa /etc/nsswitch.conf
400 for network information, such as
403 You must create or get a valid copy of this file and put it in
404 .Pa /emul/linux/etc .
405 .Ss Finding the necessary files
407 the information below is valid as of the time this
408 document was first written (March, 1995), but certain details
409 such as names of ftp sites, directories and distribution names
410 may have changed by the time you read this.
412 Linux is distributed by several groups that make their own set
413 of binaries that they distribute.
414 Each distribution has its own name, like
418 The distributions are
419 available on a lot of ftp sites.
420 Sometimes the files are unpacked,
421 and you can get the individual files you need, but mostly they
422 are stored in distribution sets, usually consisting of subdirectories
423 with gzipped tar files in them.
424 The primary ftp sites for the distributions are:
425 .Bl -item -compact -offset indent
427 .Pa sunsite.unc.edu:/pub/Linux/distributions
429 .Pa tsx-11.mit.edu:/pub/linux/distributions
432 Some European mirrors:
433 .Bl -item -compact -offset indent
435 .Pa ftp.luth.se:/pub/linux/distributions
437 .Pa ftp.demon.co.uk:/pub/linux/distributions
439 .Pa src.doc.ic.ac.uk:/packages/linux/distributions
442 For simplicity, let's concentrate on Slackware here.
444 consists of a number of subdirectories, containing separate packages.
445 Normally, they're controlled by an install program, but you can
449 First of all, you will need to look in the
451 subdir of the distribution.
452 You will find a lot of small textfiles here describing the contents of
453 the separate packages.
454 The fastest way to look something up is to retrieve all the files in the
455 contents subdirectory, and grep through them for the file you need.
456 Here is an example of a list of files that you might need, and
457 in which contents-file you will find it by grepping through them:
459 .Bd -literal -offset indent
472 So, in this case, you will need the packages ldso, shlibs, xf_lib and oldlibs.
473 In each of the contents-files for these packages, look for a line saying
474 .Dq PACKAGE LOCATION ,
475 it will tell you on which
478 in our case it will tell us in which subdirectory we need to look.
479 For our example, we would find the following locations:
481 .Bd -literal -offset indent
495 of the distribution, others may be found in the
498 In this case, we could now retrieve the packages we need by retrieving
499 the following files (relative to the root of the Slackware distribution
503 .Pa slakware/a2/ldso.tgz
505 .Pa slakware/a2/shlibs.tgz
507 .Pa slakware/x6/oldlibs/tgz
509 .Pa slakware/x9/xf_lib.tgz
512 Extract the files from these gzipped tarfiles in your /emul/linux directory
513 (possibly omitting or afterwards removing files you don't need), and you
515 .Ss Programs using SVGAlib
516 SVGAlib binaries require some extra care.
518 .Cd options WSDISPLAY_COMPAT_USL
521 and you will also have to create
522 some symbolic links in the
527 .Pa /emul/linux/dev/console
531 .Pa /emul/linux/dev/mouse
532 -\*[Gt] whatever device your mouse is connected to
534 .Pa /emul/linux/dev/ttyS0
538 .Pa /emul/linux/dev/ttyS1
543 Be warned: the first link mentioned here makes SVGAlib binaries
544 work, but may confuse others, so you may have to remove it again at
547 The information about Linux distributions may become outdated.
549 Absolute pathnames pointed to by symbolic links are only looked up in the
550 shadow root when the symbolic link itself was found by an absolute
551 pathname inside the shadow root.
552 This is not consistent.
554 Linux executables cannot handle directory offset cookies \*[Gt] 32 bits.
555 Should such an offset occur, you will see the message
556 .Dq linux_getdents: dir offset too large for emulated program .
557 Currently, this can only
558 happen on NFS mounted file systems, mounted from servers that return
559 offsets with information in the upper 32 bits.
560 These errors should rarely happen, but can be avoided by mounting this
561 file system with offset translation enabled.
570 will also have the desired effect, but is less preferable.