Table of Contents
The NetBSD port for i386, alpha, mac68k, macppc and many others can execute a great number of native Linux programs, using the Linux emulation layer. Generally, when you think about emulation you imagine something slow and inefficient because, often, emulations must reproduce hardware instructions and even architectures (usually from old machines) in software. In the case of the Linux emulation this is radically different: it is only a thin software layer, mostly for system calls which are already very similar between the two systems. The application code itself is processed at the full speed of your CPU, so you don't get a degraded performance with the Linux emulation and the feeling is exactly the same as for native NetBSD applications.
This chapter explains how to configure the Linux emulation with an example: the installation of the well known Acrobat Reader version 4 program.
The installation of the Linux emulation is described in the compat_linux(8) man page; using the package system only two steps are needed.
Configuring the kernel.
Installing the Linux libraries.
Installing Linux applications like Acrobat Reader
If you use a GENERIC kernel you don't need to do anything because Linux compatibility is already enabled.
If you use a customized kernel, check that the following options are enabled:
option COMPAT_LINUX option EXEC_ELF32
when you have compiled a kernel with the previous options you can start installing the necessary software.
Usually, applications are linked against shared libraries, and for Linux applications, Linux shared libraries are needed. You can get the shared libraries from any Linux distribution, provided it's not too old, but the suggested method is to use the package system and install the libraries automatically (which uses SuSE libraries). When you install the libraries, the following happens:
A secondary root directory is created
which will be used for Linux programs.
This directory is
The Linux programs in emulation mode will use this directory
as their root directory and use files there. If a required
file is not found, it will be searched with
/ as root directory.
For example, if a Linux application opens
/etc/ld.so.conf, it will first be
/emul/linux/etc/ld.so.conf, and if
not found there in
The shared libraries for Linux are installed.
Most applications are linked dynamically and expect to find
the necessary libraries on the system.
For example, for Acrobat Reader,
if you go to the
/usr/pkgsrc/print/acroread and give the
make depends command, you get the
===> acroread-4.0 requires Linux glibc2 libraries - see compat_linux(8).
Both operations will be handled automatically by the package system, without the need of manual intervention from the user (I suppose that, by now, you have already begun to love the package system...). Note that this section describes manual installation of the Linux libraries.
To install the libraries, a program must be installed that
handles the RPM format: it is
rpm, which will be used to extract the
SuSE libraries. Execute make and
make install in the
/usr/pkgsrc/misc/rpm/ directory to
build and install rpm.
suse_base package must be
The SuSE RPM files can be downloaded by the package system or, if
you have a SuSE CD, you can copy them in the
/usr/pkgsrc/distfiles/suse directory and then run
make and make install
after going to the
With the same method install
The final configuration is:
pkg_info -a | grep susesuse_base-7.3nb5 Linux compatibility package suse_x11-7.3nb2 Linux compatibility package for X11 binaries suse_compat-7.3 Linux compatibility package with old shared libraries
Now everything is ready for the installation of the
Acrobat Reader program (or other Linux
/usr/pkgsrc/print/acroread and give the
To download and install Acrobat Reader you need to add the line
/etc/mk.conf to accept the Acrobat Reader
license, simply follow the instructions given after
If we examine the outcome of the installation of the Linux
libraries and programs we find that
/emul/linux is a symbolic link pointing to
/usr/pkg/emul/linux, where the following
directories have been created:
Please always refer to
/emul/linux and not
The latter is an implementation detail and may change in the
How much space is required for the Linux emulation software? On my system I get the following figure:
du -k linux... 214049 linux/
Acrobat Reader, the program, has been
installed in the usual directory for package binaries:
/usr/pkg/bin. It can be run just as any
Some Linux programs rely on a Linux-like
filesystem. The NetBSD procfs filesystem can emulate a
/proc filesystem that contains Linux-specific
pseudo-files. To accomplish this you can mount the procfs with
mount_procfs -o linux procfs /emul/linux/proc
In this example a Linux-like proc filesystem will be mounted to
/emul/linux/proc directory. You can also
let NetBSD mount it automatically during the booting process of
NetBSD, by adding the following line to
procfs /emul/linux/proc procfs ro,linux