`
onedada
  • 浏览: 103398 次
  • 性别: Icon_minigender_1
  • 来自: 宁波
社区版块
存档分类
最新评论

freebsd兼容linux

    博客分类:
  • Unix
 
阅读更多

本文转载自:    http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/linuxemu-lbc-install.html

 

 

FreeBSD Handbook
Prev Chapter 11 Linux® Binary Compatibility Next

11.2 Installation

Linux® libararies are not installed on FreeBSD by default and Linux binary compatibility is not enabled by default. Linux libraries can be installed using the FreeBSD Ports Collection. Alternately, Linux libraries can be installed manually.

Using the Ports Collection is by far the easiest way to install Linux libraries:

# cd
/usr/ports/emulators/linux_base-f10# make install distclean

Once the port is installed, enable Linux binary compatibility by loading the linux module. Type the following as root:

# kldload linux

In order for Linux compatibility to always be enabled at boot time, add the following line to /etc/rc.conf:

linux_enable="YES"

To verify that the module is loaded, use kldstat(8):

% kldstat
Id Refs Address    Size     Name
 1    2 0xc0100000 16bdb8   kernel
 7    1 0xc24db000 d000     linux.ko

Users who prefer to statically link Linux binary compatibility into the kernel should add options COMPAT_LINUX to the custom kernel configuration file. Compile and install the new kernel as described in .

11.2.1 Installing Libraries Manually

While using the Ports Collection is recommended, Linux libraries can be installed manually. The Linux shared libraries required by a program and the runtime linker should be copied to /compat/linux. Any shared libraries opened by Linux programs run under FreeBSD will look in this directory first. For example, if a Linux program loads /lib/libc.so, FreeBSD will first try to open /compat/linux/lib/libc.so, and if that does not exist, it will then try /lib/libc.so. Shared libraries should be installed to /compat/linux/lib rather than to the paths that the Linux ld.so reports.

Generally, one will need to look for the shared libraries that Linux binaries depend on only the first few times that a Linux program is installed on FreeBSD. 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.

11.2.1.1 How to Install Additional Shared Libraries

If the linux_base port is installed and an application still complains about missing shared libraries, there are two methods root can use to determine which shared libraries the Linux binaries need.

If a Linux system is available, determine which shared libraries the application needs, and copy them to the FreeBSD system.

In this example, FTP was used to download the Linux binary of Doom on a Linux system . To check which shared libraries it needs, run ldd linuxdoom:

% ldd linuxdoom
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

Copy all the files in the last column into /compat/linux on the FreeBSD system, with the names in the first column as symbolic links pointing to them. This example will result in the following files on the FreeBSD system:

/compat/linux/usr/X11/lib/libXt.so.3.1.0
/compat/linux/usr/X11/lib/libXt.so.3 -> libXt.so.3.1.0
/compat/linux/usr/X11/lib/libX11.so.3.1.0
/compat/linux/usr/X11/lib/libX11.so.3 -> libX11.so.3.1.0
/compat/linux/lib/libc.so.4.6.29
/compat/linux/lib/libc.so.4 -> libc.so.4.6.29

Note: If a Linux shared library already exists with a matching major revision number to the first column of the ldd output, it does not need to be copied to the file named in the last column, as the existing library should work. It is advisable to copy the shared library if it is a newer version, though. The old one can be removed, as long as the symbolic link points to the new one. For example, these libraries exist on the system:

/compat/linux/lib/libc.so.4.6.27
/compat/linux/lib/libc.so.4 -> libc.so.4.6.27

and a binary claims to require a later version according to the output of ldd:

libc.so.4 (DLL Jump 4.5pl26) -> libc.so.4.6.29

If it is only one or two versions out of date in the trailing digit, do not worry about copying /lib/libc.so.4.6.29, because the program should work fine with the slightly older version. However, it is safe to replace the libc.so:

/compat/linux/lib/libc.so.4.6.29
/compat/linux/lib/libc.so.4 -> libc.so.4.6.29

Note: The symbolic link mechanism is only needed for Linux binaries as the FreeBSD runtime linker takes care of looking for matching major revision numbers.

11.2.2 Installing Linux® ELF Binaries

ELF binaries sometimes require an extra step of “branding”. If an unbranded ELF binary is executed, it will generate an error message like the following:

% ./my-linux-elf-binary
ELF binary type not known
Abort

To help the FreeBSD kernel distinguish between a FreeBSD ELF binary and a Linux binary, use brandelf(1):

% brandelf -t Linux my-linux-elf-binary

Since the GNU toolchain places the appropriate branding information into ELF binaries automatically, this step is usually not necessary.

11.2.3 Installing a Linux RPM Based Application

FreeBSD uses its own package database to track all software installed from the Ports Collection. However, the Linux RPM database is not supported.

In order to install a Linux RPM-based application, first install the archivers/rpm2cpio package or port. Once installed, root can use this command to install a .rpm as follows:

# cd /compat/linux# rpm2cpio -q < /path/to/linux.archive.rpm | cpio -id

If necessary, brandelf the installed ELF binaries, but not the libraries. Note that this will prevent a clean uninstall.

11.2.4 Configuring the Hostname Resolver

If DNS does not work or this error appears:

resolv+: "bind" is an invalid keyword resolv+:
"hosts" is an invalid keyword

Configure /compat/linux/etc/host.conf as follows:

order hosts, bind
multi on

This order specifies that /etc/hosts is searched first and DNS is searched second. When /compat/linux/etc/host.conf does not exist, Linux applications use /etc/host.conf and complain about the incompatible FreeBSD syntax. Remove bind if a name server is not configured using /etc/resolv.conf.


Prev Home Next
Linux® Binary Compatibility Up Installing Mathematica®

 

 

 

 

 

 

 

 

 

分享到:
评论

相关推荐

    为什么Linux比FreeBSD更流行.pdf

    此外,FreeBSD对程序兼容性的支持使其能运行许多Linux程序,但随着虚拟化技术的进步,这一优势逐渐减弱。 开源协议也是影响两者流行度的一个因素。Linux遵循GPL协议,要求任何基于Linux的修改必须开源,这在某种...

    PC-BSD解决了Flash播放问题的FreeBSD

    他们采用了FreeBSD的Linux兼容层(通常是名为“Linuxulator”的技术)来实现这一目标,使得Linux版本的Flash播放器能在FreeBSD环境下运行。Linux兼容层允许FreeBSD执行某些专为Linux设计的二进制代码,从而扩展了...

    FreeBSD和Linux有什么相似处和区别-综合文档

    此外,FreeBSD能够运行大量的Linux应用,它可以安装一个Linux的兼容层,这个兼容层可以在编译FreeBSD时加入或者通过下载已编译了Linux兼容层的FreeBSD系统来得到。 然而,FreeBSD和Linux也有许多不同之处。他们的...

    64位操作系统点评-Windows,Linux,FreeBSD,Solaris

    本文主要分析了四个64位操作系统:Windows、Linux(以SuSE Enterprise Server 9为例)、FreeBSD和Solaris,侧重于它们在服务器领域的应用和企业级特性。 首先,微软的Windows x64操作系统,特别是Windows 2003 x64...

    FreeBSD CCPP开发环境

    3. FreeBSD与Linux的对比:文章提到,FreeBSD在稳定性方面胜过Linux,并且运行速度更快。这使它成为一个在服务器和桌面计算中有竞争力的选择。 搭建C++开发环境的步骤: 1. 系统安装前的准备:在安装FreeBSD系统...

    The.Complete.FreeBSD

    - **FreeBSD与Linux的比较**:分析了FreeBSD与Linux在技术实现和社区文化等方面的异同。 - **FreeBSD系统文档**:介绍了如何阅读和利用FreeBSD提供的官方文档,这对深入学习系统功能非常有帮助。 - **FreeBSD社区**...

    TCP/IP协议栈在Linux与FreeBSD中的实现分析.pdf

    在FreeBSD中,TCP/IP协议栈的实现遵循传统的BSD模型,而Linux则自成一体,但在接口级别上与传统模型保持兼容。图1展示了TCP/IP协议栈在FreeBSD中的实现概览,可以看出,不论应用程序调用哪个输出函数,最终都会归结...

    freebsd u盘安装 教程

    ### FreeBSD U盘安装教程知识点详解 #### 一、前言 FreeBSD是一款强大的类Unix操作系统,因其稳定性、安全性和性能优化...总之,在面对特定硬件或驱动兼容性问题时,从U盘安装FreeBSD不失为一个有效且可靠的解决方案。

    FreeBSD完全学习

    与其他免费UNIX类系统如Linux相比,FreeBSD在性能、安全性及稳定性方面有其独到之处。 ### 2. 系统文档与社区资源 FreeBSD拥有丰富的系统文档,包括在线手册、GNU info以及来自社区的其他文档,为用户提供详尽的...

    FreeBSD 7.2使用手册中文版

    首先,手册会介绍 FreeBSD 的基本概念,包括它的起源、哲学以及与其它操作系统(如 Linux 和 macOS)的区别。这部分将帮助读者理解 FreeBSD 的核心价值,比如其开源社区的贡献模式和它对 BSD 许可证的遵循。 接着,...

    freebsd教程

    4. **硬件支持**:讨论FreeBSD对各种硬件的兼容性,包括显卡、声卡、网卡等的驱动程序安装和配置。 5. **防火墙和安全**:讲解如何使用ipfw或pf防火墙规则来保护系统,以及设置SSH安全连接。 6. **文件系统和存储*...

    freebsd的入门配置和命令

    FreeBSD 支持 Linux 兼容模式,这意味着很多 Linux 下的软件也能在 FreeBSD 上运行。对于复杂软件的安装,推荐使用 Ports 树,它包含了大量的预编译源代码,通过 Ports 可以方便地构建和安装软件。例如,要安装 Vim ...

    FreeBSD操作系统

    5. **硬件兼容性**:尽管FreeBSD主要针对x86架构,但也有对ARM和其他架构的良好支持,使其能够在各种硬件平台上运行。 6. **文件系统**:FreeBSD采用UFS作为默认文件系统,同时支持ZFS和Btrfs等现代文件系统,提供...

    FreeBSD使用大全.第2版

    1. **FreeBSD简介**:介绍FreeBSD的历史、设计理念以及与其它类UNIX系统(如Linux)的区别,包括其特有的Berkeley Software Distribution (BSD) 许可协议。 2. **安装与配置**:详细讲解FreeBSD的安装过程,包括...

    六个系统安装方法及其应用.rar_Linux 安装_freebsd_solaris_系统安装_网络安装系统

    本文将详细介绍标题提及的"六个系统安装方法及其应用",包括Linux、FreeBSD、Solaris等,以及网络安装系统的基本概念。 首先,让我们从Linux安装开始。Linux是一个开源的类UNIX操作系统,具有高度可定制性和灵活性...

    Freebsd 手册word 版

    FreeBSD是一款基于BSD UNIX的操作系统,能够在多种架构的计算机上运行,包括Intel兼容个人计算机、DEC Alpha以及PC98等。作为一套免费的操作系统,FreeBSD能够将个人计算机转变为强大的工作站,并稳定地提供所需的...

    FreeBSD学习笔记整理

    静态链接Linux二进制兼容模式** - 在内核配置文件中添加:`options COMPAT_LINUX` **15. 设置网卡IP地址** - 设置IP地址:`ifconfig em0 inet 192.0.2.10 netmask 255.255.255.0` **16. 添加网卡别名IP地址** ...

    linuxLinux基础与应用

    此外,Linux在PC机上的使用通常更为便利,例如FreeBSD与Linux兼容,但Linux对用户更友好。 【Linux的获取】 获取Linux的方式多种多样,可以购买Red Hat的安装光盘,或者通过官方FTP站点(如ftp://ftp.RedHat.com)...

    FreeBSD 7.0 内核源代码1 (共两部分)

    4. **compat**:兼容性层,FreeBSD为了与其他系统(如Linux、NetBSD等)的软件兼容,会提供一些接口模拟。例如,`linux`子目录下的代码是为了让FreeBSD可以运行一些设计为在Linux上运行的应用程序。 5. **dev**:...

Global site tag (gtag.js) - Google Analytics