BerandaComputers and TechnologyHow to Run Google Chrome (Linux-Binary) on FreeBSD – The FreeBSD Forums

How to Run Google Chrome (Linux-Binary) on FreeBSD – The FreeBSD Forums

Important notes:


1) Tested upon FreeBSD 12.2-RELEASE. Used Ubuntu-based linux compat instead of default CentOS one.


2) Sound, webcam, microphone, hardware acceleration all properly work. Widevine support too (Netflix, Spotify, Amazon Prime Video, HBO Max, etc).


3) The

/home

and

/tmp

directories will be shared between FreeBSD and Linux apps.


4) To successfully run Google Chrome, we rely on

games/linux-steam-utils

workarounds.


5) Due to all sorts of problems encountered while using

/compat/ubuntu

as the chroot location, I’ve opted to use

/compat/linux

instead, although it’s discouraged as it conflicts with CentOS-based ports. This means you need to remove any linux-c7* port you may have and avoid installing them afterwards too.


6) It’s recommended to use a tmpfs

/tmp

. This is not the case when using ZFS default installation, but can be easily fixed. Assuming the ZFS pool is named “zroot”:

su


# Unmount and destroy /tmp from zroot:

umount /tmp && zfs destroy -f zroot/tmp


# Add entry to /etc/fstab to use tmpfs for /tmp:

printf "tmpfst/tmpttmpfstrw,mode=1777t0t0n" >> /etc/fstab

Let’s begin:

su


# Enable linux compatibility layer:

sysrc linux_enable=YES

# Start linux service:

service linux start

# Install linux-steam-utils:

pkg install linux-steam-utils

# Copy the useful files to a temporary folder:

cp -R /usr/local/steam-utils /usr/local/steam-utils-bak

# Uninstall linux-steam-utils and all its dependencies:

pkg delete linux-steam-utils && pkg autoremove

# Move back /usr/local/steam-utils-bak to the correct location:

mv /usr/local/steam-utils-bak/ /usr/local/steam-utils

# Just to be sure to start clean:

rm -Rf /compat/linux

# Create necessary mount points for a working linuxulator:

mkdir -p /compat/linux/dev/fd && mkdir /compat/linux/dev/shm && mkdir /compat/linux/proc && mkdir /compat/linux/sys && mkdir /compat/linux/home && mkdir /compat/linux/tmp

# Make sure your

/etc/fstab

looks like this:

Code:

tmpfs                   /tmp            tmpfs           rw,mode=1777            0       0
procfs                  /proc           procfs          rw,late                 0       0
fdescfs                 /dev/fd         fdescfs         rw,late                 0       0
linprocfs       /compat/linux/proc      linprocfs       rw,late                 0       0
linsysfs        /compat/linux/sys       linsysfs        rw,late                 0       0
devfs           /compat/linux/dev       devfs           rw,late                 0       0
fdescfs         /compat/linux/dev/fd    fdescfs         rw,late,linrdlnk        0       0
tmpfs           /compat/linux/dev/shm   tmpfs           rw,late,mode=1777       0       0
/home           /compat/linux/home      nullfs          rw,late                 0       0
/tmp            /compat/linux/tmp       nullfs          rw,late                 0       0

# Mount needed filesystems:

mount -al

# Install debootstrap:

pkg install debootstrap

# Install Ubuntu 20.04 into

/compat/linux

:

debootstrap --arch=amd64 --no-check-gpg focal /compat/linux

# Fix APT package manager:

printf "APT::Cache-Start 251658240;" > /compat/linux/etc/apt/apt.conf.d/00aptitude

# Enable more repositories:

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

# Add Chrome repository:

printf "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /compat/linux/etc/apt/sources.list.d/google-chrome.list

# Fetch Chrome signing key:

fetch -o /compat/linux/ https://dl.google.com/linux/linux_signing_key.pub

# Create custom Chrome launcher script and make it executable:

touch /compat/linux/bin/chrome && chmod +x /compat/linux/bin/chrome

# Edit it so it has this content:

Code:

#!/compat/linux/bin/sh

SCRIPT=$(readlink -f "$0")
USR_DIRECTORY=$(readlink -f $(dirname $SCRIPT)/..)

CHROME_PATH="/opt/google/chrome/chrome"

export LD_LIBRARY_PATH=/usr/local/steam-utils/lib64/fakeudev
export LD_PRELOAD=/usr/local/steam-utils/lib64/webfix/webfix.so
export LIBGL_DRI3_DISABLE=1

"$CHROME_PATH"  --no-sandbox --no-zygote --test-type --v=0 "$@"

# Fix broken symlink:

cd /compat/linux/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

# Set correct timezone inside your chroot:

printf "%bn" "0.0 0 0.0n0nUTC" > /compat/linux/etc/adjtime

# Make sure everything is properly mounted:

mount -al

# Chroot into your linux environment:

chroot /compat/linux /bin/bash

# Choose your timezone:

dpkg-reconfigure tzdata

# Install some required programs (except for

ttf-mscorefonts-installer

which is optional):

apt update ; apt install -y gnupg pulseaudio ttf-mscorefonts-installer

# Install Google Chrome:

apt-key add linux_signing_key.pub && apt update && apt install -y google-chrome-stable

# Exit chroot

exit

# Exit su

exit

# Now create a .desktop file to launch Chrome as any other app:

touch ~/.local/share/applications/google-chrome.desktop

# Make it contain something like this:

Code:

[Desktop Entry]
Type=Application
Version=1.0
Encoding=UTF-8
Name=Google Chrome
Comment=Google web browser based on WebKit
Icon=google-chrome
Exec=/compat/linux/bin/chrome
Categories=Application;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;
StartupNotify=true

That’s all!


Many thanks to Alex S. (shkhln) for his

games/linux-steam-utils

port, and Alexandru Hamedu (st1905) for helping in all sorts of things earlier when trying to set up a CentOS-based linuxulator.

Sources:

https://wiki.freebsd.org/LinuxJails

https://wiki.freebsd.org/LinuxApps

https://wiki.freebsd.org/Linuxulator

https://help.ubuntu.com/lts/installation-guide/armhf/apds04.html

https://github.com/AppImage/AppImageKit/issues/98

https://pastebin.com/1W9Fh3e9

EDIT 1: Replaced sudo for su to fix some of the commands above.

Read More

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments