Diff for /wikisrc/guide/linux.mdwn between versions 1.1 and 1.2

version 1.1, 2013/03/08 23:38:45 version 1.2, 2013/03/08 23:44:42
Line 1 Line 1
 # Linux emulation  # Linux emulation
   
 The NetBSD port for i386, amd64, mac68k, macppc, and many others can execute a   The NetBSD port for i386, amd64, mac68k, macppc, and many others can execute a
 great number of native Linux programs, using the Linux emulation layer.   great number of native Linux programs, using the Linux emulation layer.
 Generally, when you think about emulation you imagine something slow and   Generally, when you think about emulation you imagine something slow and
 inefficient because, often, emulations must reproduce hardware instructions and   inefficient because, often, emulations must reproduce hardware instructions and
 even architectures (usually from old machines) in software. In the case of the   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,   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.   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   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   don't get a degraded performance with the Linux emulation and the feeling is
 exactly the same as for native NetBSD applications.  exactly the same as for native NetBSD applications.
   
 This chapter explains how to configure the Linux emulation with an example: the   This chapter explains how to configure the Linux emulation with an example: the
 installation of the well known Acrobat Reader version 7 program.  installation of the well known Acrobat Reader version 7 program.
   
 ## Emulation setup  ## Emulation setup
   
 The installation of the Linux emulation is described in the   The installation of the Linux emulation is described in the
 [compat\_linux(8)](http://netbsd.gw.com/cgi-bin/man-cgi?compat_linux+8+NetBSD-5.0.1+i386)   [compat\_linux(8)](http://netbsd.gw.com/cgi-bin/man-cgi?compat_linux+8+NetBSD-5.0.1+i386)
 man page; using the package system, only two steps are needed.  man page; using the package system, only two steps are needed.
   
  1. Configuring the kernel.   1. Configuring the kernel.
Line 26  man page; using the package system, only Line 26  man page; using the package system, only
   
 ### Configuring the kernel  ### Configuring the kernel
   
 If you use a GENERIC kernel you don't need to do anything because Linux   If you use a GENERIC kernel you don't need to do anything because Linux
 compatibility is already enabled.  compatibility is already enabled.
   
 If you use a customized kernel, check that the following options are enabled:  If you use a customized kernel, check that the following options are enabled:
Line 39  or the following options if you are goin Line 39  or the following options if you are goin
     option COMPAT_LINUX      option COMPAT_LINUX
     option EXEC_ELF64      option EXEC_ELF64
   
 When you have compiled a kernel with the previous options, you can start   When you have compiled a kernel with the previous options, you can start
 installing the necessary software.  installing the necessary software.
   
 ### Installing the Linux libraries  ### Installing the Linux libraries
   
 Usually, applications are linked against shared libraries, and for Linux   Usually, applications are linked against shared libraries, and for Linux
 applications, Linux shared libraries are needed. You can get the shared   applications, Linux shared libraries are needed. You can get the shared
 libraries from any Linux distribution, provided it's not too old, but the   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   suggested method is to use the package system and install the libraries
 automatically (which uses SUSE libraries). When you install the libraries, the   automatically (which uses SUSE libraries). When you install the libraries, the
 following happens:  following happens:
   
  * A *secondary root directory* is created which will be used for Linux    * A *secondary root directory* is created which will be used for Linux
    programs. This directory is `/emul/linux`. The Linux programs in emulation      programs. This directory is `/emul/linux`. The Linux programs in emulation
    mode will use this directory as their root directory and use files there. If      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.     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      For example, if a Linux application opens `/etc/ld.so.conf`, it will first be
    searched in `/emul/linux/etc/ld.so.conf`, and if not found there, in      searched in `/emul/linux/etc/ld.so.conf`, and if not found there, in
    `/etc/ld.so.conf`.     `/etc/ld.so.conf`.
   
  * The shared libraries for Linux are installed. Most applications are linked    * The shared libraries for Linux are installed. Most applications are linked
    dynamically and expect to find the necessary libraries on the system. For      dynamically and expect to find the necessary libraries on the system. For
    example, for Acrobat Reader, if you go to the `/usr/pkgsrc/print/acroread7`      example, for Acrobat Reader, if you go to the `/usr/pkgsrc/print/acroread7`
    and give the `make depends` command, pkgsrc will fetch and install all      and give the `make depends` command, pkgsrc will fetch and install all
    dependencies for Acrobat Reader.     dependencies for Acrobat Reader.
   
 Both operations will be handled automatically by the package system, without the   Both operations will be handled automatically by the package system, without the
 need of manual intervention from the user (we suppose that, by now, you have   need of manual intervention from the user (we suppose that, by now, you have
 already begun to love the package system...). Note that this section describes   already begun to love the package system...). Note that this section describes
 manual installation of the Linux libraries.  manual installation of the Linux libraries.
   
 To install the libraries, a program must be installed that handles the RPM   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   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   `make` and `make install` in the `/usr/pkgsrc/misc/rpm/` directory to build
 and install `rpm`.  and install `rpm`.
   
 Next the `suse121_base` package must be installed. The SUSE RPM files can be   Next the `suse121_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   downloaded by the package system or, if you have a SUSE CD, you can copy them in
 the `/usr/pkgsrc/distfiles/suse121` directory and then run `make` and  the `/usr/pkgsrc/distfiles/suse121` directory and then run `make` and
 `make install` after going to the `/usr/pkgsrc/emulators/suse121_base`   `make install` after going to the `/usr/pkgsrc/emulators/suse121_base`
 directory.  directory.
   
 With the same method install `suse121_compat` and `suse121_x11`. The final   With the same method install `suse121_compat` and `suse121_x11`. The final
 configuration is:  configuration is:
   
     # pkg_info -a | grep suse      # pkg_info -a | grep suse
Line 90  configuration is: Line 90  configuration is:
         suse_compat-12.1    Linux compatibility package with old shared libraries          suse_compat-12.1    Linux compatibility package with old shared libraries
         suse_x11-12.1       Linux compatibility package for X11          suse_x11-12.1       Linux compatibility package for X11
   
 *Note*: Of course you can also install the packages binary. To do this, you   *Note*: Of course you can also install the packages binary. To do this, you
 would either set the proper `PKG_PATH` and then  would either set the proper `PKG_PATH` and then
   
     # pkg_add rpm      # pkg_add rpm
Line 102  Or, using `pkgin`: Line 102  Or, using `pkgin`:
   
     # pkgin install rpm suse_base suse_compat suse_x11      # pkgin install rpm suse_base suse_compat suse_x11
   
 *Note*: You can also skip this step when you are installing a package from   *Note*: You can also skip this step when you are installing a package from
 pkgsrc which requires Linux emulation! A good example for this is the package   pkgsrc which requires Linux emulation! A good example for this is the package
 `www/opera`, which will automatically install the packages needed for emulating   `www/opera`, which will automatically install the packages needed for emulating
 the Linux version of the Opera browser.  the Linux version of the Opera browser.
   
 ### Installing Acrobat Reader  ### Installing Acrobat Reader
   
 Now everything is ready for the installation of the Acrobat Reader program (or   Now everything is ready for the installation of the Acrobat Reader program (or
 other Linux programs). Change to `/usr/pkgsrc/print/acroread7` and give the   other Linux programs). Change to `/usr/pkgsrc/print/acroread7` and give the
 usual commands.  usual commands.
   
     # make      # make
Line 118  usual commands. Line 118  usual commands.
   
 ### Note  ### Note
   
 To download and install Acrobat Reader you need to add the line   To download and install Acrobat Reader you need to add the line
 `ACCEPTABLE_LICENSES+=adobe-acrobat-license` to `/etc/mk.conf` to accept the   `ACCEPTABLE_LICENSES+=adobe-acrobat-license` to `/etc/mk.conf` to accept the
 Acrobat Reader license, simply follow the instructions given after `make`.  Acrobat Reader license, simply follow the instructions given after `make`.
   
 ## Directory structure  ## Directory structure
   
 If we examine the outcome of the installation of the Linux libraries and   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   programs we find that `/emul/linux` is a symbolic link pointing to
 `/usr/pkg/emul/linux`, where the following directories have been created:  `/usr/pkg/emul/linux`, where the following directories have been created:
   
  * `bin/`   * `bin/`
Line 139  programs we find that `/emul/linux` is a Line 139  programs we find that `/emul/linux` is a
  * `usr/`   * `usr/`
  * `var/`   * `var/`
   
 *Note*: Please always refer to `/emul/linux` and not to `/usr/pkg/emul/linux`.   *Note*: Please always refer to `/emul/linux` and not to `/usr/pkg/emul/linux`.
 The latter is an implementation detail and may change in the future.  The latter is an implementation detail and may change in the future.
   
 How much space is required for the Linux emulation software? On one system we   How much space is required for the Linux emulation software? On one system we
 got the following figure:  got the following figure:
   
     # cd /usr/pkg/emul      # cd /usr/pkg/emul
Line 150  got the following figure: Line 150  got the following figure:
     ...      ...
     127804  /emul/linux/      127804  /emul/linux/
   
 Acrobat Reader, the program, has been installed in the usual directory for   Acrobat Reader, the program, has been installed in the usual directory for
 package binaries: `/usr/pkg/bin`. It can be run just as any other program:  package binaries: `/usr/pkg/bin`. It can be run just as any other program:
   
     $ acroread netbsd.pdf       $ acroread netbsd.pdf
   
 ## Emulating /proc  ## Emulating /proc
   
 Some Linux programs rely on a Linux-like `/proc` filesystem. The NetBSD procfs   Some Linux programs rely on a Linux-like `/proc` filesystem. The NetBSD procfs
 filesystem can emulate a `/proc` filesystem that contains Linux-specific   filesystem can emulate a `/proc` filesystem that contains Linux-specific
 pseudo-files. To accomplish this you can mount the procfs with the   pseudo-files. To accomplish this you can mount the procfs with the
 `linux`-option:  `linux`-option:
   
     # mount_procfs -o linux procfs /emul/linux/proc      # mount_procfs -o linux procfs /emul/linux/proc
   
 In this example a Linux-like proc filesystem will be mounted to the   In this example a Linux-like proc filesystem will be mounted to the
 `/emul/linux/proc` directory. You can also let NetBSD mount it automatically   `/emul/linux/proc` directory. You can also let NetBSD mount it automatically
 during the booting process of NetBSD, by adding the following line to   during the booting process of NetBSD, by adding the following line to
 `/etc/fstab`:  `/etc/fstab`:
   
     procfs /emul/linux/proc procfs ro,linux      procfs /emul/linux/proc procfs ro,linux
   
 ## Using Linux browser plugins  ## Using Linux browser plugins
   
 Linux plugins for Mozilla-based browsers can be used on native NetBSD Firefox   Linux plugins for Mozilla-based browsers can be used on native NetBSD Firefox
 builds through nspluginwrapper, a wrapper that translates between the native   builds through nspluginwrapper, a wrapper that translates between the native
 browser and a foreign plugin. At the moment, nspluginwrapper only works reliably   browser and a foreign plugin. At the moment, nspluginwrapper only works reliably
 on Mozilla-based browsers that link against GTK2+ (GTK1+ is not supported).   on Mozilla-based browsers that link against GTK2+ (GTK1+ is not supported).
 nspluginwrapper can be installed through pkgsrc:  nspluginwrapper can be installed through pkgsrc:
   
     # cd /usr/pkgsrc/www/nspluginwrapper      # cd /usr/pkgsrc/www/nspluginwrapper
     # make install      # make install
   
 Plugins can then be installed in two steps: first, the plugin has to be   Plugins can then be installed in two steps: first, the plugin has to be
 installed on the system (e.g. through pkgsrc). After that the plugin should be   installed on the system (e.g. through pkgsrc). After that the plugin should be
 registered with the `nspluginwrapper` by the users who want to use that   registered with the `nspluginwrapper` by the users who want to use that
 plugin.  plugin.
   
 In this short example we will have a look at installing the Macromedia Flash   In this short example we will have a look at installing the Macromedia Flash
 plugin. We can fullfill the first step by installing the Flash plugin through   plugin. We can fullfill the first step by installing the Flash plugin through
 pkgsrc:  pkgsrc:
   
     # cd /usr/pkgsrc/multimedia/ns-flash      # cd /usr/pkgsrc/multimedia/ns-flash
Line 198  After that an unprivileged user can regi Line 198  After that an unprivileged user can regi
   
     $ nspluginwrapper -i /usr/pkg/lib/netscape/plugins/libflashplayer.so      $ nspluginwrapper -i /usr/pkg/lib/netscape/plugins/libflashplayer.so
   
 The plugin should then be registered correctly. You can check this by using the   The plugin should then be registered correctly. You can check this by using the
 `-l` option of `nspluginwrapper` (`nspluginwrapper -l`). If the plugin is   `-l` option of `nspluginwrapper` (`nspluginwrapper -l`). If the plugin is
 listed, you can restart Firefox, and verify that the plugin was installed by   listed, you can restart Firefox, and verify that the plugin was installed by
 entering `about:plugins` in the location bar.  entering `about:plugins` in the location bar.
   
 ## Further reading  ## Further reading

Removed from v.1.1  
changed lines
  Added in v.1.2


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb