DaVinci Resolve installed in a Ubuntu Mantic chroot on Freebsd
Davinci Resolve on Freebsd on Youtube
Features
Nvidia and Cuda enabled
Xwayland on Wayland or Xephyr on X11 is used to display Davinci Resolve on Freebsd
Audio routed from the chroot to the host using a pulseaudio socket for zero latency
Video directory from the Freebsd host mounted inside the home directory in the chroot
Opened using a Desktop entry on Freebsd
16 GB of system memory. 32 GB when using Fusion.
GPU: Discrete with at least 2GB VRAM, supporting OpenCL 1.2 or CUDA 11.
Clone this repository by running the following command
git clone https://github.com/NapoleonWils0n/davinci-resolve-freebsd.git
Tree list of the DaVinci Resolve Freebsd git repository
davinci-resolve-freebsd ├── README.org ├── assets │ ├── apt │ │ └── apt-installed.txt │ └── screenshot │ └── screenshot.png ├── compat │ └── ubuntu │ ├── etc │ │ ├── apt │ │ │ └── sources.list │ │ ├── default │ │ │ └── locale │ │ └── modprobe.d │ │ └── blacklist-nvidia-nouveau.conf │ ├── home │ │ └── username │ │ ├── .config │ │ │ ├── gpu │ │ │ │ └── dummy-uvm.so │ │ │ └── pulse │ │ │ └── client.conf │ │ ├── .zshenv │ │ └── .zshrc │ └── usr │ └── local │ └── bin │ └── wrapper-resolve └── freebsd ├── home │ └── username │ ├── .config │ │ └── pulse │ │ ├── .config │ │ │ └── pulse │ │ └── default.pa │ └── .local │ └── share │ └── applications │ └── davinci-resolve.desktop └── usr └── local ├── bin │ └── resolve ├── etc │ ├── doas.conf │ └── rc.d │ └── ubuntu └── share └── debootstrap └── scripts ├── lunar └── mantic 36 directories, 18 files
Make sure Nvidia and Cuda is set up on the Freebsd host
sudo pkg install nvidia-driver linux-nvidia-libs libc6-shim libvdpau-va-gl libva-nvidia-driver
run nv-sglrun nvidia-smi
nv-sglrun nvidia-smi
nv-sglrun nvidia-smi output
shim init +---------------------------------------------------------------------------------------+ | NVIDIA-SMI 535.146.02 Driver Version: 535.146.02 CUDA Version: 12.2 |
Install debootstrap which we use to create an ubuntu chroot on freebsd
sudo pkg install debootstrap
Install doas so we enter the chroot without being prompted for a password
sudo pkg install doas
Edit the doas.conf file and change username to your username on freebsd
Path to the doas.conf on freebsd
/usr/local/etc/doas.conf
doas.conf
Path to doas.conf in this repository
davinci-resolve-freebsd/freebsd/usr/local/etc/doas.conf
- doas.conf code
# permit user
permit keepenv :username
# chroot
permit nopass :username cmd chroot
# root as root
permit nopass keepenv root as root
If you have centos installed in
/compat/linux
You need to stop it before starting ubuntu
because you can only run instance of the linuxulator at a time
If you don’t have a linux install in /compat/linux you can skip this step
Stop linux
sudo service linux stop
Use sysrc to set linux_enable=”NO” in your /etc/rc.conf
sudo sysrc linux_enable="NO"
or you can edit your
/etc/rc.conf
and set linux_enable to NO
linux_enable="NO"
Reboot so the linux mount points are unmounted
Ubuntu script
Path to ubuntu script in this repository
davinci-resolve-freebsd/freebsd/usr/local/etc/rc.d/ubuntu
Copy the ubuntu script from the repository to
/usr/local/etc/rc.d/
sudo cp davinci-resolve-freebsd/freebsd/usr/local/etc/rc.d/ubuntu /usr/local/etc/rc.d/
Make the script executable
sudo chmod +x /usr/local/etc/rc.d/ubuntu
- ubuntu code
#!/bin/sh
#
# PROVIDE: ubuntu
# REQUIRE: archdep mountlate
# KEYWORD: nojail
#
# This is a modified version of /etc/rc.d/linux
# Based on the script by mrclksr:
# https://github.com/mrclksr/linux-browser-installer/blob/main/rc.d/ubuntu.in
#
. /etc/rc.subr
name="ubuntu"
desc="Enable Ubuntu chroot, and Linux ABI"
rcvar="ubuntu_enable"
start_cmd="${name}_start"
stop_cmd=":"
unmounted()
{
[ `stat -f "%d" "$1"` == `stat -f "%d" "$1/.."` -a \
`stat -f "%i" "$1"` != `stat -f "%i" "$1/.."` ]
}
ubuntu_start()
{
local _emul_path _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 ${_tmpdir}/ld.so.cache
if ! cmp -s ${_tmpdir}/ld.so.cache /compat/ubuntu/etc/ld.so.cache; then
cat ${_tmpdir}/ld.so.cache > /compat/ubuntu/etc/ld.so.cache
fi
rm -rf ${_tmpdir}
fi
# Linux uses the pre-pts(4) tty naming scheme.
load_kld pty
# Handle unbranded ELF executables by defaulting to ELFOSABI_LINUX.
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
_emul_path="/compat/ubuntu"
unmounted "${_emul_path}/dev" && (mount -o nocover -t devfs devfs "${_emul_path}/dev" || exit 1)
unmounted "${_emul_path}/dev/fd" && (mount -o nocover,linrdlnk -t fdescfs fdescfs "${_emul_path}/dev/fd" || exit 1)
unmounted "${_emul_path}/dev/shm" && (mount -o nocover,mode=1777 -t tmpfs tmpfs "${_emul_path}/dev/shm" || exit 1)
unmounted "${_emul_path}/home" && (mount -t nullfs /home "${_emul_path}/home" || exit 1)
unmounted "${_emul_path}/proc" && (mount -o nocover -t linprocfs linprocfs "${_emul_path}/proc" || exit 1)
unmounted "${_emul_path}/sys" && (mount -o nocover -t linsysfs linsysfs "${_emul_path}/sys" || exit 1)
unmounted "${_emul_path}/tmp" && (mount -t nullfs /tmp "${_emul_path}/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 necessary mount points for the Ubuntu Linuxulator chroot in
/compat/ubuntu
sudo mkdir -p {/compat/ubuntu/dev/fd,/compat/ubuntu/dev/shm,/compat/ubuntu/home,/compat/ubuntu/tmp,/compat/ubuntu/proc,/compat/ubuntu/sys}
Use sysrc to set ubuntu_enable=”YES” in your /etc/rc.conf
sudo sysrc ubuntu_enable="YES"
or you can edit your
/etc/rc.conf
and set ubuntu_enable to YES
ubuntu_enable="YES"
Start the Ubuntu service
sudo service ubuntu start
Check everything is mounted
mount
debootstrap has a collection of scripts to install different version of debian and ubuntu
The debootstrap scripts are installed in this location of freebsd
/usr/local/share/debootstrap/scripts
Ubuntu Jammy is the latest version of ubuntu including as a script with debootstrap
However there seems to be a bug with ubuntu jammy installed in a chroot on freebsd that sets the permission of a lot of binaries and libraries in the ubuntu chroot to 700
Which means that only the root user can execute the binaries and libaries
so you would have to run GUI applications as root
I copied one of the existing debootstrap files and added the Lunar and Mantic version of Ubuntu to the file which we will use later to install Ubuntu Mantic which doesn’t have the persmissions bug
Lunar and Mantic script in this repository
Path to the lunar script in this repository
davinci-resolve-freebsd/freebsd/usr/local/share/debootstrap/scripts/lunar
Copy the lunar script from the repository to the debootstrap scripts directory
sudo cp davinci-resolve-freebsd/freebsd/usr/local/share/debootstrap/scripts/lunar /usr/local/share/debootstrap/scripts
Path to the mantic script in this repository
davinci-resolve-freebsd/freebsd/usr/local/share/debootstrap/scripts/mantic
Copy the mantic script from the repository to the debootstrap scripts directory
sudo cp davinci-resolve-freebsd/freebsd/usr/local/share/debootstrap/scripts/mantic /usr/local/share/debootstrap/scripts
- Lunar and Mantic code
case $ARCH in
amd64|i386)
case $SUITE in
gutsy|hardy|intrepid|jaunty|karmic|lucid|lunar|mantic|maverick|natty|oneiric|precise|quantal|raring|saucy|utopic|vivid|wily|yakkety|zesty)
default_mirror http://old-releases.ubuntu.com/ubuntu
;;
*)
default_mirror http://archive.ubuntu.com/ubuntu
;;
esac
;;
sparc)
case $SUITE in
gutsy)
default_mirror http://old-releases.ubuntu.com/ubuntu
;;
*)
default_mirror http://ports.ubuntu.com/ubuntu-ports
;;
esac
;;
*)
default_mirror http://ports.ubuntu.com/ubuntu-ports
;;
esac
mirror_style release
download_style apt
finddebs_style from-indices
variants - buildd fakechroot minbase
keyring /usr/local/share/keyrings/ubuntu-archive-keyring.gpg
if doing_variant fakechroot; then
test "$FAKECHROOT" = "true" || error 1 FAKECHROOTREQ "This variant requires fakechroot environment to be started"
fi
case $ARCH in
alpha|ia64) LIBC="libc6.1" ;;
kfreebsd-*) LIBC="libc0.1" ;;
hurd-*) LIBC="libc0.3" ;;
*) LIBC="libc6" ;;
esac
case $SUITE in
gutsy|hardy|intrepid|jaunty|karmic|lucid|lunar|mantic|maverick|natty|oneiric|precise|quantal|raring|saucy|trusty|utopic|vivid|wily|xenial|yakkety|zesty|artful|bionic|cosmic|disco|eoan|focal|groovy|hirsute) ;;
*)
# impish+ will use zstd compression, check if supported
dpkg_zstd="$(dpkg-deb --help 2>/dev/null | grep ' zstd,' || :)"
if [ -z "$EXTRACTOR_OVERRIDE" ] && [ -z "$dpkg_zstd" ]; then
info CHOSENEXTRACTOR "%s uses zstd compression, setting --extractor=ar option" "$SUITE"
export EXTRACTOR_OVERRIDE=ar
fi
;;
esac
work_out_debs () {
required="$(get_debs Priority: required)"
if doing_variant - || doing_variant fakechroot; then
#required="$required $(get_debs Priority: important)"
# ^^ should be getting debconf here somehow maybe
base="$(get_debs Priority: important)"
elif doing_variant buildd; then
base="apt build-essential"
elif doing_variant minbase; then
base="apt"
fi
if doing_variant fakechroot; then
# ldd.fake needs binutils
required="$required binutils"
fi
case $MIRRORS in
https://*)
case "$CODENAME" in
gutsy|hardy|intrepid|jaunty|karmic|lucid|lunar|mantic|maverick|natty|oneiric|precise|quantal|raring|saucy|trusty|utopic|vivid|wily|xenial|yakkety|zesty)
base="$base apt-transport-https ca-certificates"
;;
*)
base="$base ca-certificates"
;;
esac
;;
esac
# do not install usrmerge in fresh bootstraps
# but do print it for germinate to accept it into minimal
if [ "$WHAT_TO_DO" = "finddebs printdebs kill_target" ]; then
case "$CODENAME" in
# "merged-usr" blacklist for past releases
gutsy|hardy|intrepid|jaunty|karmic|lucid|lunar|mantic|maverick|natty|oneiric|precise|quantal|raring|saucy|trusty|utopic|vivid|wily|xenial|yakkety|zesty|artful|bionic|cosmic|disco|eoan|focal|groovy)
;;
hirsute)
# keep hirsute buildd chroots split-usr to allow for escape hatch
if ! doing_variant buildd; then
if [ -z "$MERGED_USR" ] || [ "$MERGED_USR" = "yes" ]; then
base="$base usrmerge"
fi
fi
;;
*)
# all future series post hirsute use merged-usr in buildd chroots too
if [ -z "$MERGED_USR" ] || [ "$MERGED_USR" = "yes" ]; then
base="$base usrmerge"
fi
;;
esac
fi
}
first_stage_install () {
case "$CODENAME" in
# "merged-usr" blacklist for past releases
gutsy|hardy|intrepid|jaunty|karmic|lucid|lunar|mantic|maverick|natty|oneiric|precise|quantal|raring|saucy|trusty|utopic|vivid|wily|xenial|yakkety|zesty|artful|bionic|cosmic)
[ -z "$MERGED_USR" ] && MERGED_USR="no"
;;
disco|eoan|focal|groovy)
# see https://bugs.debian.org/838388
EXTRACT_DEB_TAR_OPTIONS="$EXTRACT_DEB_TAR_OPTIONS -k"
;;
hirsute)
# keep hirsute buildd chroots split-usr to allow for escape hatch
if [ -z "$MERGED_USR" ]; then
if doing_variant buildd; then
MERGED_USR="no"
else
MERGED_USR="yes"
fi
fi
# see https://bugs.debian.org/838388
EXTRACT_DEB_TAR_OPTIONS="$EXTRACT_DEB_TAR_OPTIONS -k"
;;
*)
# all future series post hirsute use merged-usr in buildd chroots too
[ -z "$MERGED_USR" ] && MERGED_USR="yes"
# see https://bugs.debian.org/838388
EXTRACT_DEB_TAR_OPTIONS="$EXTRACT_DEB_TAR_OPTIONS -k"
;;
esac
setup_merged_usr
extract $required
mkdir -p "$TARGET/var/lib/dpkg"
: >"$TARGET/var/lib/dpkg/status"
: >"$TARGET/var/lib/dpkg/available"
setup_etc
if [ ! -e "$TARGET/etc/fstab" ]; then
echo '# UNCONFIGURED FSTAB FOR BASE SYSTEM' > "$TARGET/etc/fstab"
chown 0:0 "$TARGET/etc/fstab"; chmod 644 "$TARGET/etc/fstab"
fi
setup_devices
if doing_variant fakechroot || [ "$CONTAINER" = "docker" ]; then
setup_proc_symlink
fi
}
second_stage_install () {
in_target /bin/true
setup_dynamic_devices
x_feign_install () {
local pkg="$1"
local deb="$(debfor $pkg)"
local ver="$(in_target dpkg-deb -f "$deb" Version)"
mkdir -p "$TARGET/var/lib/dpkg/info"
echo \
"Package: $pkg
Version: $ver
Maintainer: unknown
Status: install ok installed" >> "$TARGET/var/lib/dpkg/status"
touch "$TARGET/var/lib/dpkg/info/${pkg}.list"
}
x_feign_install dpkg
x_core_install () {
smallyes '' | in_target dpkg --force-depends --install $(debfor "$@")
}
p () {
baseprog="$(($baseprog + ${1:-1}))"
}
if ! doing_variant fakechroot; then
setup_proc
in_target /sbin/ldconfig
fi
DEBIAN_FRONTEND=noninteractive
DEBCONF_NONINTERACTIVE_SEEN=true
export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN
baseprog=0
bases=7
p; progress $baseprog $bases INSTCORE "Installing core packages" #1
info INSTCORE "Installing core packages..."
p; progress $baseprog $bases INSTCORE "Installing core packages" #2
ln -sf mawk "$TARGET/usr/bin/awk"
x_core_install base-passwd
x_core_install base-files
p; progress $baseprog $bases INSTCORE "Installing core packages" #3
x_core_install dpkg
if [ ! -e "$TARGET/etc/localtime" ]; then
ln -sf /usr/share/zoneinfo/UTC "$TARGET/etc/localtime"
fi
if doing_variant fakechroot; then
install_fakechroot_tools
fi
p; progress $baseprog $bases INSTCORE "Installing core packages" #4
x_core_install $LIBC
p; progress $baseprog $bases INSTCORE "Installing core packages" #5
x_core_install perl-base
p; progress $baseprog $bases INSTCORE "Installing core packages" #6
rm "$TARGET/usr/bin/awk"
x_core_install mawk
p; progress $baseprog $bases INSTCORE "Installing core packages" #7
if doing_variant -; then
x_core_install debconf
fi
baseprog=0
bases=$(set -- $required; echo $#)
info UNPACKREQ "Unpacking required packages..."
exec 7>&1
smallyes '' |
(repeatn 5 in_target_failmsg UNPACK_REQ_FAIL_FIVE "Failure while unpacking required packages. This will be attempted up to five times." "" \
dpkg --status-fd 8 --force-depends --unpack $(debfor $required) 8>&1 1>&7 || echo EXITCODE $?) |
dpkg_progress $baseprog $bases UNPACKREQ "Unpacking required packages" UNPACKING
info CONFREQ "Configuring required packages..."
if doing_variant fakechroot && [ -e "$TARGET/var/lib/dpkg/info/initscripts.postinst" ]
then
# fix initscripts postinst (no mounting possible, and wrong if condition)
sed -i '/dpkg.*--compare-versions/ s/\<lt\>/lt-nl/' "$TARGET/var/lib/dpkg/info/initscripts.postinst"
fi
echo \
"#!/bin/sh
exit 101" > "$TARGET/usr/sbin/policy-rc.d"
chmod 755 "$TARGET/usr/sbin/policy-rc.d"
mv "$TARGET/sbin/start-stop-daemon" "$TARGET/sbin/start-stop-daemon.REAL"
echo \
"#!/bin/sh
echo
echo \"Warning: Fake start-stop-daemon called, doing nothing\"" > "$TARGET/sbin/start-stop-daemon"
chmod 755 "$TARGET/sbin/start-stop-daemon"
if [ -x "$TARGET/sbin/initctl" ]; then
mv "$TARGET/sbin/initctl" "$TARGET/sbin/initctl.REAL"
echo \
"#!/bin/sh
if [ \"\$1\" = version ]; then exec /sbin/initctl.REAL \"\$@\"; fi
echo
echo \"Warning: Fake initctl called, doing nothing\"" > "$TARGET/sbin/initctl"
chmod 755 "$TARGET/sbin/initctl"
fi
setup_dselect_method apt
smallyes '' |
(in_target_failmsg CONF_REQ_FAIL "Failure while configuring required packages." "" \
dpkg --status-fd 8 --configure --pending --force-configure-any --force-depends 8>&1 1>&7 || echo EXITCODE $?) |
dpkg_progress $baseprog $bases CONFREQ "Configuring required packages" CONFIGURING
baseprog=0
bases="$(set -- $base; echo $#)"
info UNPACKBASE "Unpacking the base system..."
setup_available $required $base
done_predeps=
while predep=$(get_next_predep); do
# We have to resolve dependencies of pre-dependencies manually because
# dpkg --predep-package doesn't handle this.
predep=$(without "$(without "$(resolve_deps $predep)" "$required")" "$done_predeps")
# XXX: progress is tricky due to how dpkg_progress works
# -- cjwatson 2009-07-29
# This step sometimes fails due to some missing functionality in Linuxulator. Just ignore it.
set +e
p; smallyes '' |
in_target dpkg --force-overwrite --force-confold --skip-same-version --install $(debfor $predep)
rc=$?
base=$(without "$base" "$predep")
done_predeps="$done_predeps $predep"
if [ $rc != 0 ]; then
warning FREEBSD_00 "Applying FreeBSD-specific workaround..."
# ... for "Failed to mount /etc/machine-id: Bad address" with Focal.
in_target truncate -s0 /var/lib/dpkg/info/systemd.postinst
in_target dpkg --configure systemd
fi
set -e
done
if [ -n "$base" ]; then
smallyes '' |
(repeatn 5 in_target_failmsg INST_BASE_FAIL_FIVE "Failure while installing base packages. This will be re-attempted up to five times." "" \
dpkg --status-fd 8 --force-overwrite --force-confold --skip-same-version --unpack $(debfor $base) 8>&1 1>&7 || echo EXITCODE $?) |
dpkg_progress $baseprog $bases UNPACKBASE "Unpacking base system" UNPACKING
info CONFBASE "Configuring the base system..."
# This step sometimes fails due to some missing functionality in Linuxulator. Just ignore it.
set +e
smallyes '' |
(repeatn 5 in_target_failmsg CONF_BASE_FAIL_FIVE "Failure while configuring base packages. This will be re-attempted up to five times." "" \
dpkg --status-fd 8 --force-confold --skip-same-version --configure -a 8>&1 1>&7 || echo EXITCODE $?) |
dpkg_progress $baseprog $bases CONFBASE "Configuring base system" CONFIGURING
set -e
fi
if [ -x "$TARGET/sbin/initctl.REAL" ]; then
mv "$TARGET/sbin/initctl.REAL" "$TARGET/sbin/initctl"
fi
mv "$TARGET/sbin/start-stop-daemon.REAL" "$TARGET/sbin/start-stop-daemon"
rm -f "$TARGET/usr/sbin/policy-rc.d"
echo \
"# Workaround for Linuxulator missing mremap(2) support; without it,
# apt(8) fails like this:
# E: Dynamic MMap ran out of room. Please increase the size of APT::Cache-Start.
APT::Cache-Start 251658240;" >> "$TARGET/etc/apt/apt.conf.d/00freebsd"
progress $bases $bases CONFBASE "Configuring base system"
info BASESUCCESS "Base system installed successfully."
}
Use debootstrap with the Mantic script we created earlier as well the url
http://archive.ubuntu.com/ubuntu/
to the Ubuntu archive with Lunar and Mantic and install Ubuntu into this location on Freebsd
/compat/ubuntu
debootstrap Ubuntu Mantic
sudo debootstrap --arch=amd64 --no-check-gpg mantic /compat/ubuntu http://archive.ubuntu.com/ubuntu/
Restart the Ubuntu service to make sure everything is properly mounted:
sudo service ubuntu restart
Use doas to chroot into Ubuntu as root without a password
doas chroot /compat/ubuntu /bin/bash
You will now be logged in as root inside the chroot
printf "%b\n" "0.0 0 0.0\n0\nUTC" > /etc/adjtime
Install sudo
apt install sudo
For some reason sudo is necessary here, otherwise it fails.
Run dpkg-reconfigure tzdata with sudo
sudo dpkg-reconfigure tzdata
Run the following command as root
printf "APT::Cache-Start 251658240;" > /etc/apt/apt.conf.d/00aptitude
Edit the apt sources.list and add more repositories
[trusted=yes] is needed for lunar and mantic
Freebsd path to the sources.list in the chroot
/compat/ubuntu/etc/apt/sources.list
Path to the sources.list in the chroot
/etc/apt/sources.list
sources.list
Path to the sources.list file in this repository
davinci-resolve-freebsd/compat/ubuntu/etc/apt/sources.list
Copy the source.list from the freebsd host to the ubuntu chroot
sudo cp davinci-resolve-freebsd/compat/ubuntu/etc/apt/sources.list /compat/ubuntu/etc/apt/sources.list
- sources.list code
deb [trusted=yes] http://archive.ubuntu.com/ubuntu/ mantic main restricted universe multiverse
deb [trusted=yes] http://archive.ubuntu.com/ubuntu/ mantic-updates main restricted universe multiverse
deb [trusted=yes] http://archive.ubuntu.com/ubuntu/ mantic-security main restricted universe multiverse
Run the following commands as root to update and upgrade Ubuntu
apt update
Upgrade
apt upgrade
Freebsd path to the locale in the chroot
/compat/ubuntu/etc/default/locale
Path to the locale in the chroot
/etc/default/locale
Path to locale in this repository
davinci-resolve-freebsd/compat/ubuntu/etc/default/locale
Change the locale file to match your locale
Run the following commands as root
locale-gen
locale-gen
dpkg-reconfigure locales
dpkg-reconfigure locales
- locale code
LANG=en_GB.UTF-8
LANGUAGE=
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE=C
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=
Install the shell our user is going to use
it must match the shell set in the ubuntu /etc/passwd file which we will set up
Run the following command as root
apt install zsh pulseaudio
The Linuxulator will create a nullfs mount for home in the chroot that is already set to out username
So if we user useradd to create a user with our username it will give you an error that the home directory already exists
We can just copy the settings for our user from Freebsd passwd file
/etc/passwd
to the passwd file on Ubuntu
/compat/ubuntu/etc/passwd
username:*:1001:1001:USER NAME:/home/username:/usr/local/bin/zsh
We also need to check that the shell path is correct
change zsh path to /bin/zsh in the chroot
Freebsd passwd
username:*:1001:1001:USER NAME:/home/username:/usr/local/bin/zsh
Host path
/compat/ubuntu/etc/passwd
Chroot path
/etc/passwd
username:*:1001:1001:USER NAME:/home/djwilcox:/bin/zsh
Check your user and group on freebsd
id
Output
uid=1001(username) gid=1001(username) groups=1001(username),0(wheel),5(operator),44(video),47(realtime)
Freebsd /etc/group
username:*:1001:
Ubuntu /etc/group
username:*:1001:
Add the user we created to groups in the chroot
replace username with the username you created
Run the following command as root
usermod -a -G adm username
usermod -a -G cdrom username
usermod -a -G sudo username
usermod -a -G dip username
usermod -a -G plugdev username
usermod -a -G users username
usermod -a -G video username
usermod -a -G audio username
usermod -a -G pulse username
usermod -a -G pulse-access username
Run the following command as root
Edit the sudoers file with visudo
visudo
Add your user to the sudoers file, change username to your username
username ALL=(ALL:ALL) ALL
Create a passwd for your user, replace username with your username
Run the following command as root
passwd username
Add the your hostname from freebsd to the hosts file in the ubuntu chroot
to stop errors when using sudo saying couldnt resolve hostname
Freebsd path to the hosts in the chroot
/compat/ubuntu/etc/hosts
Path to the hosts in the chroot
/etc/hosts
hosts
127.0.0.1 hostname
doas chroot /compat/ubuntu /bin/bash
Switch to your user in the chroot
replace username with your username
su - username
Davinci Resolve install on Ubuntu with Nvidia and Cuda
Freebsd 14 p.6 quarterly branch Nvidia driver version is 550.54.14
which matches the extact version on Ubuntu Mantic
So rather than downloading and manually installing the Nvidia driver you can install it from the Ubuntu repo
sudo apt install nvidia-driver-550-server
Download the linux version matching the version on the freebsd host
the version must match exactly or it won’t work
https://www.nvidia.com/Download/Find.aspx?lang=en-us
Download link for 535.146.02
https://www.nvidia.com/download/driverResults.aspx/216728/en-us/
Change into the directory you download the nvidia drivers into on the freebsd host
then copy the nvidia run file into the home directory in the chroot
cp -rv NVIDIA-Linux-x86_64-535.146.02.run /compat/ubuntu/home/"${USER}"
Chroot into ubuntu
doas chroot /compat/ubuntu /bin/bash
Switch to our user
replace username with your username
su - username
https://docs.nvidia.com/datacenter/tesla/tesla-installation-notes/index.html
Verify the system has build tools such as make, gcc installed
Install build-essential for gcc
sudo apt install build-essential
sudo apt install ffmpeg
chmod the Nvidia run file
chmod +x NVIDIA-Linux-x86_64-535.146.02.run
Install the Nvidia driver
sudo ./NVIDIA-Linux-x86_64-535.146.02.run --install-compat32-libs --no-nvidia-modprobe --no-backup --no-kernel-module --no-x-check --no-nouveau-check --no-cc-version-check --no-kernel-module-source --no-check-for-alternate-installs --install-libglvnd --skip-depmod --no-systemd
Install fakeroot and xorriso for makeresolvedeb
sudo apt install fakeroot xorriso
Install the nvidia-cuda-toolkit
sudo apt install nvidia-cuda-toolkit ocl-icd-opencl-dev libglu1-mesa libfuse2 initramfs-tools
Blacklist-nvidia-nouveau.conf
Path to blacklist-nvidia-nouveau.conf in this repository
davinci-resolve-freebsd/compat/ubuntu/etc/modprobe.d/blacklist-nvidia-nouveau.conf
Freebsd path to the blacklist-nvidia-nouveau.conf in the chroot
/compat/ubuntu/etc/modprobe.d/blacklist-nvidia-nouveau.conf
Path to the blacklist-nvidia-nouveau.conf in the chroot
/etc/modprobe.d/blacklist-nvidia-nouveau.conf
On the Freebsd host create the modprobe.d directory in the chroot directory
sudo mkdir -p /compat/ubuntu/etc/modprobe.d
Copy the blacklist-nvidia-nouveau.conf file from the repository to the chroot
sudo cp davinci-resolve-freebsd/compat/ubuntu/etc/modprobe.d/blacklist-nvidia-nouveau.conf /compat/ubuntu/etc/modprobe.d
- blacklist-nvidia-nouveau.conf code
blacklist nouveau
options nouveau modeset=0
sudo update-initramfs -u
On the Freebsd host
Go to the Davinci Resolve website and click the
“Davinci Resolve Free Download Now” link
then click the Linux download link for either the Free version or the paid Studio version
you will then need to register on the site with an email address
Once you have submitted the form the Davinci Resolve zip file will start to download,
the zip file has a file size of 2.4 gigabytes so may take an hour or so to download
Copy the Davinci Resolve zip into the home directory in the chroot
You dont need to use sudo to copy files in the home directory in the chroot
because we have the same user with the same id in the chroot as on the host
cp -rv DaVinci_Resolve_18.6.4_Linux.zip /compat/ubuntu/home/"${USER}"
On the Freebsd host download the makeresolvedeb script
Copy the makeresolvedeb_1.6.4_multi.sh.tar.gz from the freebsd host to the home directory in the chroot
cp -rv makeresolvedeb_1.6.4_multi.sh.tar.gz /compat/ubuntu/home/"${USER}"
Make sure you have chrooted into ubuntu by running
doas chroot /compat/ubuntu /bin/bash
Switch to out user in the chroot,
replace username with your username
su - username
Install zip
sudo apt install zip
Unzip the resolve zip
unzip DaVinci_Resolve_18.6.5_Linux.zip
Extract the makeresolvedeb.tar.gz file
tar zxvf makeresolvedeb_1.6.4_multi.sh.tar.gz
then run makeresolvedeb
./makeresolvedeb_1.6.4_multi.sh DaVinci_Resolve_18.6.5_Linux.run
This may take about an hour
sudo dpkg -i davinci-resolve_18.6.5-mrd1.6.4_amd64.deb
or
sudo apt install davinci-resolve_18.6.5-mrd1.6.4_amd64.deb
Change directory in the chroot to the resolve libs directory
cd /opt/resolve/libs
Rename libglib-2.0.so.0 to libglib-2.0.so.0.bak
sudo mv libglib-2.0.so.0 libglib-2.0.so.0.bak
Copy the libglib-2.0.so.0 from the chroot system lib directory to the resolve libs directory
sudo cp /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 /opt/resolve/libs/
Install liblog4cxx-dev
sudo apt install liblog4cxx-dev
Make sure you have chrooted into Ubuntu by running
doas chroot /compat/ubuntu /bin/bash
Switch to out user in the chroot, replace username with your username
su - username
Create the gpu directory
mkdir -p "${HOME}/.config/gpu"
On the Freebsd host copy the dummy-uvm.so from the repository to the chroot
cp davinci-resolve-freebsd/compat/ubuntu/home/username/.config/gpu/dummy-uvm.so /compat/ubuntu/home/"${USER}"/.config/gpu
Install some wayland packages and the wlroot compositor
sudo apt install libinput-tools wayland-protocols libwlroots11 libwlroots-dev libxkbcommon0 qtwayland5 qt6-wayland wayland-utils adwaita-qt qt5ct
sudo mkdir -p /var/run/user/"$(id -u)"
Chown the directory
sudo chown -R "${USER}":"$(id -u)" /var/run/user/"$(id -u)"
Chmod the directory
sudo chmod 700 /var/run/user/"$(id -u)"
We need to set some enviormental variables in our shell config
Copy the zshrc config from this reposiory to the chroot
cp davinci-resolve-freebsd/compat/ubuntu/home/username/.zshrc /compat/ubuntu/home/"${USER}"
Copy the zshenv config from this reposiory to the chroot
cp davinci-resolve-freebsd/compat/ubuntu/home/username/.zshenv /compat/ubuntu/home/"${USER}"
We create a blank .zshrc file
otherwise zsh will complain that theres is no config file
- ~/.zshrc code
# ~/.zshrc
# add your zsh code below
shell path
Set the shell path to include resolve bin directory
this allows us to type resolve
resolve
Instead of the full path to open Davinci Resolve in the chroot
/opt/resolve/bin/resolve
Export the XDG directories
remember to create the XDG_RUNTIME_DIR directory
LD_PRELOAD is used to load the so file
export LD_PRELOAD="$HOME/.config/gpu/dummy-uvm.so"
You need to export some variables for Nvidia
otherwise you won’t be able to drag a clip into the tim and you will get a error saying gpu is full
export __NV_PRIME_RENDER_OFFLOAD=1
export __GLX_VENDOR_LIBRARY_NAME=nvidia
Export DISPLAY so application use the Xwayland window on the host
export DISPLAY=:1
Davinci Resolve is a native Wayland application
so we need to set the QT_QPA_PLATFORM to xcb
export QT_QPA_PLATFORM=xcb
- ~/.zshenv code
# ~/.zshenv
# Path
typeset -U PATH path
path=("/opt/resolve/bin" "$path[@]")
export PATH
# xdg directories
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_RUNTIME_DIR="/var/run/user/`id -u`"
# dummy-uvm.so for access to the gpu
export LD_PRELOAD="$HOME/.config/gpu/dummy-uvm.so"
export __NV_PRIME_RENDER_OFFLOAD=1
export __GLX_VENDOR_LIBRARY_NAME=nvidia
# export display
export DISPLAY=:1
# qt5
export QT_QPA_PLATFORMTHEME=qt5ct
export QT_QPA_PLATFORM=xcb
X11 install on Ubuntu in the chroot
sudo apt install xorg xserver-xorg xserver-xorg-core
Use nvidia-smi to see GPU info and process that are using Nvidia GPU
Run the following command as your user in the chroot
nvidia-smi
nvidia-smi output
+---------------------------------------------------------------------------------------+ | NVIDIA-SMI 535.146.02 Driver Version: 535.146.02 CUDA Version: 12.2 |
Use the pulseaudio default.pa config file to create a pulseaudio socket in the /tmp directory
The /tmp directory is mounted in the chroot and allows us to route the audio from the chroot to the host
Copy the default.pa from this repository to
~/.config/pulse/default.pa
cp davinci-resolve-freebsd/freebsd/home/username/.config/pulse/default.pa "${HOME}/.config/pulse"
- default.pa code
#!/usr/local/bin/pulseaudio -nF
# include default.pa and override
.include /usr/local/etc/pulse/default.pa
# chroot
.ifexists module-esound-protocol-unix.so
load-module module-esound-protocol-unix
.endif
load-module module-native-protocol-unix socket=/tmp/pulseaudio.socket
Full path to the client.conf from freebsd to the chroot
/compat/ubuntu/home/username/.config/pulse/client.conf
client.conf path in the chroot
~/.config/pulse/client.conf
Copy client.conf from this repository into the chroot
cp davinci-resolve-freebsd/compat/ubuntu/home/username/.config/pulse/client.conf /compat/ubuntu/home/"${USER}"/.config/pulse
- client.conf code
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
## Configuration file for PulseAudio clients. See pulse-client.conf(5) for
## more information. Default values are commented out. Use either ; or # for
## commenting.
; default-sink = oss_output.dsp1
; default-source =
default-server = /tmp/pulseaudio.socket
; default-dbus-server =
; autospawn = yes
; daemon-binary = /usr/local/bin/pulseaudio
; extra-arguments = --log-target=syslog
; cookie-file =
; enable-shm = yes
; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB
; auto-connect-localhost = no
; auto-connect-display = no
Starting Davinci Resolve manually on Wayland and X11 running on Freebsd
We need to manually test the steps to launch Davinci Resolve
before setting up the Desktop entry for Freebsd
pulseaudio --start --daemonize
Make sure the pulseaudio.socket is created in the /tmp directory
the pulseaudio.socket is created by the default.pa pulseaudio file you set up earlier
ls -l /tmp
/tmp directory note the pulseaudio.socket
drwx------ 2 djwilcox wheel 2 25 Feb 16:01 babel-KwYFVT drwxr-xr-x 2 djwilcox wheel 2 25 Feb 16:01 babel-stable-30 srwxrwxrwx 1 djwilcox wheel 0 25 Feb 16:01 dbus-JgcNbycnKi drwxr-xr-x 2 djwilcox wheel 3 25 Feb 17:31 emacs1001 -rw-r--r-- 1 djwilcox wheel 244 25 Feb 17:34 emacs100127121-pollux~ srwxrwxrwx 1 djwilcox wheel 0 25 Feb 17:38 pulseaudio.socket drwxr-xr-x 2 root wheel 3 25 Feb 16:01 sndio drwx------ 2 djwilcox wheel 3 25 Feb 16:01 tmux-1001
We use Xwayland on Wayland or Xephyr on X11 to create a new window with an id of :1
in the chroot we set the DISPLAY variable to equal to :1 so that applications are displayed in the Freebsd window
Create a 1920x1080 window
Xwayland -host-grab -geometry 1920x1080 :01
host-grab is needed so you can click around in resolve
press ctrl + shift to release the mouse
Install Xephyr if you are running X11 on Freebsd
sudo pkg install Xephyr
Create a 1920x1080 fullscreen window
Xephyr -br -ac -noreset -screen 1920x1080 :1
Press ctrl + shift to release the mouse
Use doas to chroot into Ubuntu as root without a password
doas chroot /compat/ubuntu /bin/bash
Switch to our user
replace username with your username
su - username
Run printenv in the chroot and check the DISPLAY variable is set to :1
printenv
Make sure the following options are set
- DISPLAY set to 1, this is the id of the Xwayland window on the Freebsd host
- PATH set to include the resolve bin directory so we can just type resolve to open Davinci Resolve
- XDG directories are set up
- LD_PRELOAD is set to load dummy-uvm.so
- __NV_PRIME_RENDER_OFFLOAD is set 1 needed otherwise you will get an error message saying gpu is full
- __GLX_VENDOR_LIBRARY_NAME is set to nvidia needed otherwise you will get an error message saying gpu is full
- QT_QPA_PLATFORM is set to xcb
Davinci Resolve use’s the qt framework but doesnt run as a native wayland application
so we need to QT_QPA_PLATFORM to xcb and not wayland
DISPLAY=:1
PATH=/opt/resolve/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
XDG_CONFIG_HOME=/home/username/.config
XDG_CACHE_HOME=/home/username/.cache
XDG_DATA_HOME=/home/username/.local/share
XDG_RUNTIME_DIR=/var/run/user/1001
LD_PRELOAD=/home/username/.config/gpu/dummy-uvm.so
__NV_PRIME_RENDER_OFFLOAD=1
__GLX_VENDOR_LIBRARY_NAME=nvidia
XDG_SESSION_TYPE=wayland
WAYLAND_DISPLAY=wayland-0
QT_QPA_PLATFORMTHEME=qt5ct
QT_QPA_PLATFORM=xcb
Start pulseaudio on the Freebsd host
pulseaudio --start --daemonize
Run pactl info in the chroot
pactl info
Make sure the following options are set
- Server String is set to /tmp/pulseaudio.socket
- User Name is set to the username on the host
- Host Name is set to the same hostname as on the freebsd host
Server String: /tmp/pulseaudio.socket
Library Protocol Version: 35
Server Protocol Version: 35
Is Local: yes
Client Index: 0
Tile Size: 65472
User Name: username
Host Name: hostname
Server Name: pulseaudio
Server Version: 16.1
Default Sample Specification: s16le 2ch 44100Hz
Default Channel Map: front-left,front-right
Default Sink: oss_output.dsp1
Default Source: oss_input.dsp0
Cookie: 1550:2200
We set the shell path in the chroots .zshenv to include the resolve bin directory
so we can just type
resolve
instead of the full path to the binary
/opt/resolve/bin/resolve
In the Ubuntu chroot and not on the Freebsd host run resolve
resolve
Davinci Resolve will open in the Xwayland or Xephyr window on Freebsd
Switch to the home directory in the chroot if you have’t already
cd
List the contents of the home directory in the chroot
and you will see that several directories have been created including the Documents directory
The Documents is created because we set up the XDG directories in the chroots shell config
drwxrwxrwx 4 username username 4 Feb 22 22:25 CacheClip drwxrwxrwx 3 username username 3 Feb 21 18:19 Documents drwxrwxrwx 3 username username 3 Feb 18 21:43 'Resolve Project Backups'
If you list the contents of the Documents directory you will see it has created the BlackmagicDesign directory as well
drwxrwxrwx 3 username username 3 Feb 18 15:12 BlackmagicDesign
Freebsd script to launch Davinci Resolve from a Linuxulator chroot
The window is displayed on Freebsd using either Xwayland or Xephyr
and the audio is routed over a pulseaudio socket from the chroot to the host
Path to resolve in this repository
davinci-resolve-freebsd/freebsd/usr/local/bin/resolve
Copy the resolve script from the repository to the freebsd bin directory
sudo cp davinci-resolve-freebsd/freebsd/usr/local/bin/resolve /usr/local/bin
- resolve code
#!/bin/sh
# resolve
# Freebsd script to launch Davinci Resolve from a Linuxulator chroot
# the window is displayed on Freebsd using either Xwayland or Xephyr
# and the audio is routed over a pulseaudio socker from the chroot to the host
# start pulseaudio
pulseaudio --start --daemonize 2>/dev/null
# Note if you are using X11 on Freebsd comment out the Xwayland line
# and uncomment the Xephyr line
# Wayland - create the Xwayland window to display Davinci Resolve
Xwayland -host-grab -geometry 1920x1080 :01 &
# X11 - create the Xwayland window to display Davinci Resolve
# Xephyr -ac -noreset -br -resizeable -screen 1920x1080 -ac :1 &
# doas chroot into ubuntu run run the wrapper script to start resolve
doas chroot /compat/ubuntu /usr/local/bin/wrapper-resolve -u "${USER}"
Path to wrapper-resolve in this repository
davinci-resolve-freebsd/compat/ubuntu/usr/local/bin/wrapper-resolve
Copy the script to the chroot
sudo cp davinci-resolve-freebsd/compat/ubuntu/usr/local/bin/wrapper-resolve /compat/ubuntu/usr/local/bin
Freebsd path to wrapper-resolve in the chroot
/compat/ubuntu/usr/local/bin/wrapper-resolve
Path to wrapper-resolve in the chroot
/usr/local/bin/wrapper-resolve
- wrapper-resolve code
#!/bin/bash
#===============================================================================
# wrapper-resolve
#===============================================================================
#===============================================================================
# script usage
#===============================================================================
usage () {
# if argument passed to function echo it
[ -z "${1}" ] || echo "! ${1}"
# display help
echo "\
# script usage
$(basename "$0") -u ${USER}"
exit 2
}
#===============================================================================
# check the number of arguments passed to the script
#===============================================================================
[ $# -gt 0 ] || usage "${WRONG_ARGS_ERR}"
#===============================================================================
# getopts check the options passed to the script
#===============================================================================
while getopts ':u:h' opt
do
case ${opt} in
u) username="${OPTARG}";;
h) usage;;
\?) usage "${INVALID_OPT_ERR} ${OPTARG}" 1>&2;;
:) usage "${INVALID_OPT_ERR} ${OPTARG} ${REQ_ARG_ERR}" 1>&2;;
esac
done
shift $((OPTIND-1))
#===============================================================================
# switch to our user in the choot and start resolve
#===============================================================================
# change username below to the name of the user in the chroot
su "${username}" -c '/opt/resolve/bin/resolve' 2>/dev/null
Path to davinci-resolve.desktop in this repository
davinci-resolve-freebsd/freebsd/home/username/.local/share/applications/davinci-resolve.desktop
On the freebsd host copy the davinci-resolve.desktop to
~/.local/share/applications
cp davinci-resolve-freebsd/freebsd/home/username/.local/share/applications/davinci-resolve.desktop "${HOME}/.local/share/applications"
davinci-resolve.desktop
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Type=Application
Name=DaVinci Resolve
Exec=/usr/local/bin/resolve-wrapper
Icon=/compat/ubuntu/opt/resolve/graphics/DV_Resolve.png
Terminal=false
MimeType=application/x-resolveproj;
StartupNotify=true
Categories=AudioVideo
Allow your user to run the mount command without sudo
You can set this using sysctl
sudo sysctl vfs.usermount=1
or by editing your sysctl.conf
/etc/sysctl.conf
and setting the following option
vfs.usermount=1
Mount the Video directory from the Freebsd host inside the home directory in the chroot,
this allows us to access the Video on directory on the Freebsd host from within the chroot with Davinci Resolve
That means we can import and export footage from Davinci Resolve from the Video directory on the Freebsd,
rather than copying files from the host to the chroot
Create a mount point in the chroot to mount the Video directory from the host in the chroot
These commands are run as your regular user and not as root
mkdir -p /compat/ubuntu/home/"${USER}"/Video
Mount the Video directory from the Freebsd host to the Video directory in the chroot
mount -t nullfs /home/"${USER}"/Video /compat/ubuntu/home/"${USER}"/Video
umount video
umount /compat/ubuntu/home/"${USER}"/Video
Edit your fstab on the Freebsd host and set the mount point
/etc/fstab
- fstab code
# mount the video directory from the host to the chroot,
# change username to your username
/home/username/Video /compat/ubuntu/home/username/Video nullfs rw,noauto 0 0
We use the noauto option in the fstab otherwise the nullfs mount will be mounted before the zfs dataset
so you need to manually mount the video directory after you log in
Mount the video directory in the chroot
mount /compat/ubuntu/home/"${USER}"/Video
Unmount the video directory in the chroot
umount /compat/ubuntu/home/"${USER}"/Video
List of installed packages on Ubuntu for reference
Xwayland doesn’t have the capability to create 2 windows yet
so Davinci Resolve is limited to a single window
Comment out the fstab entry to mount the video directory from the host to the chroot on the Freebsd host
/etc/fstab
#/home/username/Video /compat/ubuntu/home/username/Video nullfs rw,noauto 0 0
Disable ubuntu
sudo sysrc ubuntu_enable="NO"
Reboot to make sure the linux mounts are unmounted
Delete the /compat/ubuntu directory
sudo rm -rxv /compat/ubuntu