Команды freebsd от linux

Chapter 12. Linux Binary Compatibility

FreeBSD provides optional binary compatibility with Linux®, commonly referred to as Linuxulator, allowing users to install and run unmodified Linux binaries. It is available for the x86 (both 32 and 64 bit) and AArch64 architectures. Some Linux-specific operating system features are not yet supported; this mostly happens with functionality specific to hardware or related to system management, such as cgroups or namespaces.

Before reading this chapter, you should:

After reading this chapter, you will know:

  • How to enable Linux binary compatibility on a FreeBSD system.
  • How to install additional Linux shared libraries.
  • How to install Linux applications on a FreeBSD system.
  • The implementation details of Linux compatibility in FreeBSD.

12.2. Configuring Linux Binary Compatibility

By default, linux(4) binary compatibility is not enabled.

To enable the Linux ABI at boot time, execute the following command:

Once enabled, it can be started without rebooting executing the following command:

This is enough for statically linked Linux binaries to work.

The Linux service will load necessary kernel modules and mount filesystems expected by Linux applications under /compat/linux . They can be started in the same way native FreeBSD binaries can; they behave almost exactly like native processes and can be traced and debugged the usual way.

The current content of /compat/linux can be checked executing the following command:

The output should be similar to the following:

total 1 dr-xr-xr-x 13 root wheel 512 Apr 11 19:12 dev dr-xr-xr-x 1 root wheel 0 Apr 11 21:03 proc dr-xr-xr-x 1 root wheel 0 Apr 11 21:03 sys

12.3. Linux userlands

Linux software requires more than just an ABI to work. In order to run Linux software a Linux userland must be installed first.

Читайте также:  Linux clear log file

If all that is wanted is to run some software already included in the Ports tree, it can be installed via package manager and pkg(8) will automatically setup the required Linux userland.

For example, to install Sublime Text 4, along with all the Linux libraries it depends on, run this command:

12.3.1. CentOS Base System from FreeBSD Packages

To install the CentOS userland execute the following command:

emulators/linux_base-c7 will place the base system derived from CentOS 7 into /compat/linux .

After installing the package, the contents of /compat/linux can be verified by running the following command to check that the CentOS userland has been installed:

The output should be similar to the following:

total 30 lrwxr-xr-x 1 root wheel 7 Apr 11 2018 bin -> usr/bin drwxr-xr-x 13 root wheel 512 Apr 11 21:10 dev drwxr-xr-x 25 root wheel 64 Apr 11 21:10 etc lrwxr-xr-x 1 root wheel 7 Apr 11 2018 lib -> usr/lib lrwxr-xr-x 1 root wheel 9 Apr 11 2018 lib64 -> usr/lib64 drwxr-xr-x 2 root wheel 2 Apr 11 21:10 opt dr-xr-xr-x 1 root wheel 0 Apr 11 21:25 proc lrwxr-xr-x 1 root wheel 8 Feb 18 02:10 run -> /var/run lrwxr-xr-x 1 root wheel 8 Apr 11 2018 sbin -> usr/sbin drwxr-xr-x 2 root wheel 2 Apr 11 21:10 srv dr-xr-xr-x 1 root wheel 0 Apr 11 21:25 sys drwxr-xr-x 8 root wheel 9 Apr 11 21:10 usr drwxr-xr-x 16 root wheel 17 Apr 11 21:10 var

12.3.2. Debian / Ubuntu Base System with debootstrap

An alternative way of providing Linux shared libraries is by using sysutils/debootstrap. This has the advantage of providing a full Debian or Ubuntu distribution.

Читайте также:  Creating make file in linux

To install debootstrap execute the following command:

debootstrap(8) needs linux(4) ABI enabled. Once enabled, execute the following command to install Ubuntu or Debian in /compat/ubuntu :

While it is technically possible to install into /compat/linux instead, it’s discouraged due to possible clashes with CentOS-based packages. Instead, derive the directory name from the distribution or version name, e.g., /compat/ubuntu .

The output should be similar to the following:

I: Retrieving InRelease I: Checking Release signature I: Valid Release signature (key id F6ECB3762474EDA9D21B7022871920D1991BC93C) I: Retrieving Packages I: Validating Packages I: Resolving dependencies of required packages. I: Resolving dependencies of base packages. I: Checking component main on http://archive.ubuntu.com/ubuntu. [. ] I: Configuring console-setup. I: Configuring kbd. I: Configuring ubuntu-minimal. I: Configuring libc-bin. I: Configuring ca-certificates. I: Base system installed successfully.

Then set up mounts in /etc/fstab .

If the contents of the home directory should be shared and to be able to run X11 applications, /home and /tmp should be mounted in the linux compat area using nullfs(5) for loopback.

The following example can be added to /etc/fstab :

# Device Mountpoint FStype Options Dump Pass# devfs /compat/ubuntu/dev devfs rw,late 0 0 tmpfs /compat/ubuntu/dev/shm tmpfs rw,late,size=1g,mode=1777 0 0 fdescfs /compat/ubuntu/dev/fd fdescfs rw,late,linrdlnk 0 0 linprocfs /compat/ubuntu/proc linprocfs rw,late 0 0 linsysfs /compat/ubuntu/sys linsysfs rw,late 0 0 /tmp /compat/ubuntu/tmp nullfs rw,late 0 0 /home /compat/ubuntu/home nullfs rw,late 0 0

Источник

21.1. Краткий обзор

В этой главе будет рассказано о том, каким образом можно запускать приложения, изначально написанные для Linux, под FreeBSD и что нужно для этого сделать.

Возможно, Вы спрашиваете себя, зачем FreeBSD нужно уметь работать с приложениями, написанными для Linux. Ответ на этот вопрос достаточно прост: многие компании и разработчики производят программное обеспечение только для Linux, так как эта операционная система очень быстро завоевала огромную популярность в компьютерном мире. Пользователям же FreeBSD приходится обращаться к этим компаниям и разработчикам с просьбами выпустить версии своих программ специально для FreeBSD. Проблема в том, что большинство производителей программного обеспечения не осознают, насколько бы увеличился их рынок сбыта, выпускай они FreeBSD версии наряду с Linux версиями, и продолжают разрабатывать только под Linux. Что же делать пользователям FreeBSD? В этой ситуации на помощь приходит Linux эмуляция.

Читайте также:  Linux create dev files

Вкратце, FreeBSD позволяет Вам работать с 90% приложений для Linux без каких-либо модификаций последних. Среди них: Star Office, Linux версия Netscape, Adobe Acrobat, RealPlayer 5 и 7, VMWare, Oracle, WordPerfect, Doom, Quake и многие другие. Есть сведения, что в некоторых ситуациях эти Linux программы показывали более высокую производительность при работе под FreeBSD, чем под Linux.

Конечно, существует некоторые особенности Linux, которые (пока) не поддерживаются в полной мере FreeBSD. Например, так обстоят дела с приложениями Linux, использующими файловую систему /proc , так как реализация последней сильно отличается от таковой в FreeBSD (однако, ситуация меняется к лучшему: в FreeBSD-CURRENT поддержка Linux procfs уже встроена в систему). Существуют также системные вызовы, специфичные для i386, как, например, переключение в режим V86.

О том, как установить поддержку запуска Linux программ, читайте в следующей секции .

Источник

Оцените статью
Adblock
detector