bsd.md
1 ## Using "AM" on freeBSD and derivatives 2 3 Since version 9.4, "AM" is compatible with BSD-based systems. 4 5 However, the compatibility of Linux programs on your BSD system must be done manually. 6 7 There are several guides on this subject, the one available on the FreeBSD site is an example https://docs.freebsd.org/en/books/handbook/linuxemu, but I will try to adapt [this one](https://unixdigest.com/tutorials/how-to-install-signal-desktop-on-freebsd-using-the-linux-binary-compatibility.html) as much as possible to the use of Debian in `debootstrap`, which is the most familiar distribution for me. 8 9 I will divide this quick guide highlighting the essential steps 10 11 ------------------------------------------------------------------------ 12 - [1. Enable Linux Compatibility Layout](#1-enable-linux-compatibility-layout) 13 - [2. Install Debian layout compatibiliti in BSD](#2-install-debian-layout-compatibiliti-in-bsd) 14 - [3. Configure and mount the Linux compatibility layout on BSD](#3-configure-and-mount-the-linux-compatibility-layout-on-bsd) 15 - [4. Configure Debian](#4-configure-debian) 16 - [5. Chroot Debian](#5-chroot-debian) 17 - [6. Update Debian](#6-update-debian) 18 - [7. Install needed packages in Debian](#7-install-needed-packages-in-debian) 19 - [8. Exit the chroot](#8-exit-the-chroot) 20 - [9. Fix ELF interpreter error](#9-fix-elf-interpreter-error) 21 - [10. Allow AppImages to use FUSE without root privileges](#10-allow-appimages-to-use-fuse-without-root-privileges) 22 23 - [Troubleshooting](#troubleshooting) 24 - [Chromium-based applications](#chromium-based-applications) 25 - [Missing libraries](#missing-libraries) 26 27 ------------------------------------------------------------------------ 28 ## 1. Enable Linux Compatibility Layout 29 First we need to enable the Linux compatibility layer, to do so we need to run these commands **as root**, no reboot needed: 30 ``` 31 sysrc linux_enable="YES" 32 service linux start 33 ``` 34 35 ------------------------------------------------------------------------ 36 ## 2. Install Debian layout compatibiliti in BSD 37 Then we need to install and use debootstrap, a program that can be used to install different Debian versions in a system without using an installation disk. 38 39 As I mentioned at the beginning, I will be using Debian, "Stable" branch 40 41 Using the PKG package manager, install "debootstrap" 42 ``` 43 pkg install debootstrap 44 ``` 45 ...then we need to setup the correct installation path for debootstrap. Use your favorite text editor and insert the following line in /etc/sysctl.conf 46 ``` 47 compat.linux.emul_path="/compat/debian" 48 ``` 49 ...and finally, we use debootstrap to install the Debian base tools for the Debian Stable, **as root** 50 ``` 51 debootstrap stable /compat/debian 52 ``` 53 54 ------------------------------------------------------------------------ 55 ## 3. Configure and mount the Linux compatibility layout on BSD 56 In order for the contents of the home directory to be shared and in order to be able to run X11 applications, the directories /home and /tmp should be mounted in the Linux compat area using nullfs for loopback. 57 58 In BSD, edit /etc/fstab and insert the following: 59 ``` 60 # Device Mountpoint FStype Options Dump Pass# 61 devfs /compat/debian/dev devfs rw,late 0 0 62 tmpfs /compat/debian/dev/shm tmpfs rw,late,size=1g,mode=1777 0 0 63 fdescfs /compat/debian/dev/fd fdescfs rw,late,linrdlnk 0 0 64 linprocfs /compat/debian/proc linprocfs rw,late 0 0 65 linsysfs /compat/debian/sys linsysfs rw,late 0 0 66 /tmp /compat/debian/tmp nullfs rw,late 0 0 67 /home /compat/debian/home nullfs rw,late 0 0 68 ``` 69 Then execute mount in order to mount everything, **as root**: 70 ``` 71 mount -al 72 ``` 73 74 ------------------------------------------------------------------------ 75 ## 4. Configure Debian 76 Edit and update the APT repositories located in /compat/debian/etc/apt/sources.list 77 ``` 78 deb https://deb.debian.org/debian stable contrib main 79 deb https://deb.debian.org/debian stable-updates contrib main 80 deb https://deb.debian.org/debian stable-backports contrib main 81 deb https://deb.debian.org/debian-security stable-security contrib main 82 ``` 83 I also prefer to disable recommended and suggested packages in /compat/debian/etc/apt/apt.conf 84 ``` 85 APT::Install-Recommends "false"; 86 APT::AutoRemove::RecommendsImportant "false"; 87 APT::AutoRemove::SuggestsImportant "false"; 88 ``` 89 90 ------------------------------------------------------------------------ 91 ## 5. Chroot Debian 92 Now we're ready to use chroot to access the Linux system. **As root**, do 93 ``` 94 chroot /compat/debian /bin/bash 95 ``` 96 Now its time to setup Debian. 97 98 ------------------------------------------------------------------------ 99 ## 6. Update Debian 100 Keep Debian updated via APT 101 ``` 102 apt update 103 ``` 104 If you get a lot of packages that need upgrading, you can do that before you continue with 105 ``` 106 apt full-upgrade 107 ``` 108 109 ------------------------------------------------------------------------ 110 ## 7. Install needed packages in Debian 111 AppImages require FUSE to work. For older implementations (which are still the most popular) install with APT `libfuse2` or `libfuse2t64` (depending on the package made available in the repositories), while for all implementations, even the most recent ones, install `fuse3` and later (the latter brings with it `fusermount`). 112 ``` 113 apt install libfuse2 fuse3 114 ``` 115 Since they are written for Linux, they will surely require substantial dependencies. The safest way to get them is to install packages that end with "-dev". 116 117 For example, "Brave AppImage" requires "`libnss3`", to be sure to use "`libnss3-dev`" instead 118 ``` 119 apt install libnss3-dev 120 ``` 121 ...also, "`pulseaudio`" brings with it several core libraries that can be required in different programs 122 ``` 123 apt install pulseaudio 124 ``` 125 ...not to mention that many programs, including the official versions of Firefox and Thunderbird, require some GTK3 or earlier libraries 126 ``` 127 apt install libgtk-3-dev libgtk2.0-dev 128 ``` 129 ...I also suggest Xorg 130 ``` 131 apt install xorg 132 ``` 133 ...if you want to use special fonts, you need to get at least the basic ones 134 ``` 135 apt install fonts-freefont-ttf 136 ``` 137 Is it too much? I know. 138 139 The reason for this is that different programs require different libraries on the host, which are almost always present on Linux. This list will continue to be updated until we discover more common packages that may be needed to run the portable Linux programs managed by "AM" and "AppMan". 140 141 ------------------------------------------------------------------------ 142 ## 8. Exit the chroot 143 To exit the chroot and return to the main BSD shell, you can use the "`exit`" command 144 ``` 145 exit 146 ``` 147 148 ------------------------------------------------------------------------ 149 ## 9. Fix ELF interpreter error 150 To prevent errors like this one... 151 ``` 152 ELF interpreter /lib64/ld-linux-x86-64.so.2 not found, error 2 153 ``` 154 ...do 155 ``` 156 cd /compat/debian/lib64/ 157 rm ./ld-linux-x86-64.so.2 158 ln -s ../lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 ld-linux-x86-64.so.2 159 ``` 160 This change requires a reboot (as does the next point, which is the most important one for AppImages, so... wait and keep read). 161 162 ------------------------------------------------------------------------ 163 ## 10. Allow AppImages to use FUSE without root privileges 164 Edit the file /etc/sysctl.conf by adding this line 165 ``` 166 vfs.usermount=1 167 ``` 168 This change requires a reboot. 169 170 ------------------------------------------------------------------------ 171 ## Troubleshooting 172 This section lists common problems that may arise. "AM" does not guarantee miracles. 173 174 ### Chromium-based applications 175 Run Chromium-based apps with the `--no-sandbox` flag, for example 176 ``` 177 $ brave --no-sandbox 178 ``` 179 180 ### Missing libraries 181 Always check the terminal output, also using `LD_DEBUG=lib` if necessary, to see which libraries a program requires to run. 182 183 Search for such libraries in APT, also with `apt search {keyword}` or by searching on the internet, to locate the package to install. 184 185 Remember to always chroot to install packages via APT 186 ``` 187 chroot /compat/debian /bin/bash 188 apt install {package} 189 ``` 190 191 ------------------------------------------------------------------------ 192 193 | [Back to "Guides and tutorials"](../../README.md#guides-and-tutorials) | [Back to "Main Index"](../../README.md#main-index) | ["Portable Linux Apps"](https://portable-linux-apps.github.io/) | [ "AppMan" ](https://github.com/ivan-hc/AppMan) | 194 | - | - | - | - | 195 196 ------------------------------------------------------------------------