Chapter 16. Linux emulation

Table of Contents
16.1. Emulation setup
16.2. Directory structure

The NetBSD port for i386 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.

16.1. Emulation setup

The installation of the Linux emulation is described in the compat_linux(8) man page; using the package system only two steps are needed.

16.1.2. Installing the Linux libraries

You can get the linux 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 (the Suse libraries are used.) When you install the libraries, the following happens:

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...)

To install the libraries, a program must be installed that handles the RPM format: it is rpm-2.5.4, which will be used to extract the Suse libraries.

Next the suse_base package must be installed. 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.

With the same method install suse_compat, suse_libc5 and suse_x11. The final configuration is:

# pkg_info -a | grep suse
suse_base-6.1p1     Linux compatibility package
suse_x11-6.1p1      Linux compatibility package for X11 binaries
suse_compat-6.1p1   Linux compatibility package with old shared libraries
suse_libc5-6.1p1    Linux compatibility package for libc5 binaries      

16.2. Directory structure

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:

bin/
boot/
cdrom/
dev/
etc/
floppy/
home/
lib/
mnt/
opt/
proc/
root/
sbin/
usr/    

How much space is required for the Linux emulation software? On my system I get the following figure:

# cd /usr/pkg/emul
# du -k linux
...
60525   linux/    

Acrobat Reader, the program, has been installed in the usual directory for package binaries: /usr/pkg/bin/.