Ld linux x86 64 so 2 freebsd

Install Ubuntu base system into FreeBSD’s Linux Binary Compatibility.

Procedure for installing the Ubuntu base system into FreeBSD’s built-in Linux Binary Compatibility, so Ubuntu and Debian based desktop applications, such as Signal, Spotify and Netflix, can run directly on FreeBSD. Tested with Ubuntu 20.04 on FreeBSD 13.0 for 64-bit amd64 architecture.

What is FreeBSD’s Linux Binary Compatibility?

FreeBSD’s built-in Linux Binary Compatibility makes it possible for FreeBSD users, that are running the 32-bit i386, 64-bit amd64 or 64-bit arm64 architecture, to install and run 32-bit and 64-bit Linux binaries directly from the command line. This is done through a system call table, which means, that Linux applications can run without emulation nor virtualization. FreeBSD’s built-in Linux Binary Compatibility was introduced in the 90’s.

In the following example, Spotify desktop client for Linux is launched from the command line in FreeBSD.

$ /compat/ubuntu/usr/bin/spotify

Screenshot of Spotify desktop client, that is running in GNOME on FreeBSD 13.0.

Enable FreeBSD’s built-in Linux Binary Compatibility.

FreeBSD has built-in binary compatibility with Linux. This makes it possible to run Ubuntu and Linux binaries. It is enabled by loading the Linux kernel modules.

# kldload linux # kldload linux64 # kldload fdescfs # kldload linprocfs # kldload tmpfs # kldload linsysfs

To make this permanent, so it also works after reboot, configure the FreeBSD system bootstrap configuration information in loader.conf.

# nano /boot/loader.conf linux_load="YES" linux64_load="YES" fdescfs_load="YES" linprocfs_load="YES" tmpfs_load="YES" linsysfs_load="YES"

Prepare command script for Ubuntu base system.

Prepare a command script, that will be used to start and stop the Ubuntu base system.

# touch /usr/local/etc/rc.d/ubuntu # chmod +x /usr/local/etc/rc.d/ubuntu # nano /usr/local/etc/rc.d/ubuntu

Insert the following lines of shell script code into the command script.

#!/bin/sh # # PROVIDE: ubuntu # REQUIRE: archdep mountlate # KEYWORD: nojail # . /etc/rc.subr name="ubuntu" desc="Ubuntu for FreeBSD Linux Binary Compatibility" rcvar="ubuntu_enable" start_cmd="$_start" stop_cmd=":" unmounted() < [ `stat -f "%d" "$1"` == `stat -f "%d" "$1/.."` -a `stat -f "%i" "$1"` != `stat -f "%i" "$1/.."` ] >ubuntu_start() < local _tmpdir load_kld -e 'linux(aout|elf)' linux case `sysctl -n hw.machine_arch` in amd64) load_kld -e 'linux64elf' linux64 ;; esac if [ -x "/compat/ubuntu/sbin/ldconfigDisabled" ]; then _tmpdir=`mktemp -d -t linux-ldconfig` /compat/ubuntu/sbin/ldconfig -C $/ld.so.cache if ! cmp -s "$/ld.so.cache" "/compat/ubuntu/etc/ld.so.cache"; then cat "$/ld.so.cache" > "/compat/ubuntu/etc/ld.so.cache" fi rm -rf $ fi load_kld pty if [ `sysctl -ni kern.elf64.fallback_brand` -eq "-1" ]; then sysctl kern.elf64.fallback_brand=3 > /dev/null fi if [ `sysctl -ni kern.elf32.fallback_brand` -eq "-1" ]; then sysctl kern.elf32.fallback_brand=3 > /dev/null fi sysctl compat.linux.emul_path="/compat/ubuntu" unmounted "/compat/ubuntu/dev" && (mount -o nocover -t devfs devfs "/compat/ubuntu/dev" || exit 1) unmounted "/compat/ubuntu/dev/fd" && (mount -o nocover,linrdlnk -t fdescfs fdescfs "/compat/ubuntu/dev/fd" || exit 1) unmounted "/compat/ubuntu/dev/shm" && (mount -o nocover,mode=1777 -t tmpfs tmpfs "/compat/ubuntu/dev/shm" || exit 1) unmounted "/compat/ubuntu/home" && (mount -t nullfs /home "/compat/ubuntu/home" || exit 1) unmounted "/compat/ubuntu/proc" && (mount -o nocover -t linprocfs linprocfs "/compat/ubuntu/proc" || exit 1) unmounted "/compat/ubuntu/sys" && (mount -o nocover -t linsysfs linsysfs "/compat/ubuntu/sys" || exit 1) unmounted "/compat/ubuntu/tmp" && (mount -t nullfs /tmp "/compat/ubuntu/tmp" || exit 1) unmounted /dev/fd && (mount -o nocover -t fdescfs fdescfs /dev/fd || exit 1) unmounted /proc && (mount -o nocover -t procfs procfs /proc || exit 1) true > load_rc_config $name run_rc_command "$1"

Create ZFS dataset for Linux compatibility directory.

If the benefits of ZFS dataset is of interest, then create a ZFS dataset. This will also make it possible to use snapshots, safely delete files without crossing mountpoints and safely delete the entire volume, if necessary.

# zfs create -o compression=on -o mountpoint=/compat zroot/compat

The snapshot feature of ZFS can be used as a kind of quick backup before changes.

# zfs snapshot -r zroot/compat@2022-04-22

Create directories for the Ubuntu base system.

Prepare directories for Ubuntu.

Читайте также:  Oracle linux install kernel headers

Start Ubuntu base system.

Enable Ubuntu chroot jail and make it automatically enabled at boot time.

Start Ubuntu base system in its chroot jail.

# service ubuntu start compat.linux.emul_path: /compat/linux -> /compat/ubuntu

Install Ubuntu base system into the Linux compatibility directory.

Install Debootstrap. This will be used to download and install Ubuntu base systems by specifying the Ubuntu target, such as focal for Focal Fossa, which is version 20.04 LTS of Ubuntu. The different targets and releases of Ubuntu are listed at List of releases at Ubuntu Wiki.

Download and install Ubuntu base system into Linux compatibility directory.

# debootstrap --arch=amd64 --no-check-gpg focal /compat/ubuntu I: Base system installed successfully.

Restart Ubuntu chroot jail.

# service ubuntu restart compat.linux.emul_path: /compat/ubuntu -> /compat/ubuntu

Fix the dynamic linker (ELF interpreter) with a symbolic link.

# cd /compat/ubuntu/lib64/ # rm ./ld-linux-x86-64.so.2 # ln -s ../lib/x86_64-linux-gnu/ld-2.31.so ld-linux-x86-64.so.2

Configure Ubuntu.

Enter the chroot jail, which will restrict the following processes to the Ubuntu base filesystem. If Ubuntu shows a message about a missing group ID, this can just be ignored. You will see, that the prompt changes.

# chroot /compat/ubuntu /bin/bash
/# printf "%b\n" "0.0 0 0.0\n0\nUTC" > /etc/adjtime /# dpkg-reconfigure tzdata
/# printf "APT::Cache-Start 251658240;" > /etc/apt/apt.conf.d/00aptitude

Add repositories. In this example, the target focal is used. Change as necessary.

/# printf "deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse" > /etc/apt/sources.list

Install and run Ubuntu and Debian based application and binaries.

You have now enabled the Linux Binary Compatibility in FreeBSD and installed the Ubuntu base system into it. You can install Ubuntu and Debian based application and binaries by entering the Ubuntu chroot jail and using Ubuntu’s package manager apt.

If you would like to install the Signal desktop application on FreeBSD, then see my guide in Install and run Signal desktop application on FreeBSD.

Читайте также:  Linux ubuntu настройки монитора

Update Ubuntu and Debian based applications.

# chroot /compat/ubuntu /bin/bash /# apt update /# apt list --upgradable /# apt upgrade /# apt autoremove /# apt clean

Safely deleting the Ubuntu base system and Linux Binary Compatibility in FreeBSD.

If necessary, the Ubuntu base system in FreeBSDs Linux Binary Compatibility can be safely deleted by first disabling the automatic start of Ubuntu base system, then rebooting FreeBSD and then deleting the Ubuntu base system directory or destroying the ZFS volume. I recommend deleting without crossing mountpoints for extra safety measure. If the Ubuntu base system is running, while attempting to delete it, FreeBSD will crash and FreeBSD disk related services will core dump.

# nano /etc/rc.conf # reboot # cd /compat # rm -rxv ubuntu

More about Linux Binary Compatibility in FreeBSD.

Would you like to treat me a cup of coffee?

If you would like to treat me a cup of coffee, then please consider making a small donation to My Bitcoin (BTC) Address. It would be greatly appreciated.

This page was last updated 2022-10-09.

Published by Micski

Micski lives in Copenhagen, which is the capitol city of Denmark, where he’s a system administrator of information technology and a semi-professional poker player. View all posts by Micski

Categories

  • Adventure (44)
  • Ancestry (1)
  • Cerwin-Vega (1)
  • Chess (11)
  • Death (3)
  • FreeBSD (37)
  • Fun (4)
  • General (3)
  • Photography (9)
  • Poker (19)
  • System Administration (54)

Источник

What is /lib64/ld-linux-x86-64.so.2 and why can it be used to execute file?

That’s the dynamic linker; if you run it on its own, it will tell you what it does:

Usage: ld.so [OPTION]. EXECUTABLE-FILE [ARGS-FOR-PROGRAM. ]

You have invoked ‘ld.so’, the helper program for shared library executables. This program usually lives in the file /lib/ld.so , and special directives in executable files using ELF shared libraries tell the system’s program loader to load the helper program from this file. This helper program loads the shared libraries needed by the program executable, prepares the program to run, and runs it. You may invoke this helper program directly from the command line to load and run an ELF executable file; this is like executing that file itself, but always uses this helper program from the file you specified, instead of the helper program file specified in the executable file you run. This is mostly of use for maintainers to test new versions of this helper program; chances are you did not intend to run this program.

The linker is used to run dynamically-linked programs. When you run chmod , the kernel effectively runs the equivalent of /lib64/ld-linux-x86-64.so.2 /bin/chmod , as you did manually; the latter works even if the chmod binary isn’t executable because the check for execute permission is done by the execve() system call on the file that it is being told to execute and in the /lib64/ld-linux-x86-64.so.2 /bin/chmod shell command line, the path passed by the shell to execve() is /lib64/ld-linux-x86-64.so.2 , not /bin/chmod , and it’s the one that is checked for execute permission, /bin/chmod is only passed as an argument to the linker. It’s the same thing in /bin/sh ./some-script where ./some-script doesn’t need to be executable.

Читайте также:  Build arm linux toolchain

You’ll find much more detail on this in the excellent How programs get run: ELF binaries article.

Источник

qemu-x86_64: Could not open ‘/lib64/ld-linux-x86-64.so.2’: No such file or directory

I have a Rancher Deskop(dockerd) on M1 MacOS and when I am trying to build below dockerfile I am getting an error such as below. Here is the command how I am trying to build the image docker build -t te-grafana-dashboards-toolchain —no-cache . I tried to change the platforms but nonae of them worked for me. I am a bit lost about this platform issue for M1 but any help will be appreciated, What I am doing wrong? What might the root cause of this?

Removing intermediate container 70af516d5d6b ---> a69229847153 Step 5/6 : RUN GO111MODULE="on" go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb; ln -s $(go env GOPATH)/bin/jb /usr/bin/jb ---> Running in 13545862fffe qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory Removing intermediate container 13545862fffe 
FROM --platform=linux/amd64 ubuntu:focal RUN apt update; apt install -y curl jq build-essential python3.8 python3-pip docker-compose jsonnet bison mercurial RUN ln -s /usr/bin/python3.8 /usr/bin/python RUN curl -OL https://golang.org/dl/go1.17.linux-amd64.tar.gz; mkdir /etc/golang; tar -xvzf go1.17.linux-amd64.tar.gz -C /etc/golang; ln -s /etc/golang/go/bin/go /usr/bin/go; rm -f go1.17.linux-amd64.tar.gz RUN GO111MODULE="on" go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb; ln -s $(go env GOPATH)/bin/jb /usr/bin/jb WORKDIR /workspace 

Источник

/lib64/ld-linux-x86-64.so.2: No such file or directory error

enter image description here

Background I am using docker to do a school project. Specifically, I pulled an ubuntu image and here is the system config: I then logged into the docker container (ubuntu) and set up elasticsearch. When I try to run

/lib64/ld-linux-x86-64.so.2: No such file or directory 

Please show the exact steps you are running with a copy and paste from the command line. Include the command run, it’s output, and post it as formatted text rather than a screenshot. This should include the steps taken to start ubuntu and install/setup elasticsearch.

4 Answers 4

If you are running this on an M1 macbook, it’s possible that you are running a native Arm image of ubuntu, instead of the emulated x86 image. If the elasticsearch distribution you are trying to install is for x86_64, then it attempts to link to the x86-64-native ld.so, which of course isn’t present on different platforms.

Either install the package for the arm platform specifically if they provide one, or — more likely — run docker explicitly as the emulated x86_64 platform:

docker run --platform linux/x86_64

many hours of searching, and finally found this, it was the missing piece of the puzzle. My use case was a bit different, but ultimately same root cause.

thank you so much, I’ve encountered the same problem on M1 with docker build command. docker build —platform linux/x86_64 helped!

Источник

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