[[https://www.blackmagicdesign.com/uk/products/davinciresolve][DaVinci Resolve]] installed in a Ubuntu Mantic Jail on Freebsd
Features
Nvidia and Cuda enabled
Audio routed from the jail to the host using a pulseaudio socket for zero latency
Video directory from the Freebsd host mounted inside the home directory in the jail
Opened using a Desktop entry on Freebsd
Note: you may need to adjust the Render speed, which can be found in the Render page in the file tab
the default Render speed is set to maximum, you may need to drop the value down to 10 depending on the amount of ram on your system
[[assets/screenshot/screenshot.png]]
** Freebsd *** System Requirements to run Davinci Resolve
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 the DaVinci Resolve Freebsd git repository
Clone this repository by running the following command
git clone https://github.com/NapoleonWils0n/davinci-resolve-freebsd-jail.git
*** Tree listing
Tree list of the DaVinci Resolve Freebsd git repository
. ├── README.org ├── assets │ ├── apt │ │ └── apt-installed.txt │ └── screenshot │ └── screenshot.png ├── freebsd │ ├── etc │ │ ├── devfs.rules │ │ ├── jail.conf │ │ └── jail.conf.d │ │ └── ubuntu.conf │ ├── home │ │ └── username │ │ ├── .config │ │ │ └── pulse │ │ │ ├── .config │ │ │ │ └── pulse │ │ │ └── default.pa │ │ └── .local │ │ └── share │ │ └── applications │ │ └── davinci-resolve.desktop │ └── usr │ └── local │ ├── bin │ │ └── resolve │ ├── etc │ │ └── doas.conf │ └── share │ └── debootstrap │ └── scripts │ ├── lunar │ └── mantic └── ubuntu ├── etc │ ├── apt │ │ └── sources.list │ ├── default │ │ └── locale │ ├── fstab │ └── modprobe.d │ └── blacklist-nvidia-nouveau.conf ├── home │ └── username │ ├── .config │ │ ├── gpu │ │ │ └── dummy-uvm.so │ │ └── pulse │ │ └── client.conf │ ├── .zshenv │ └── .zshrc └── usr └── local └── bin └── wrapper-resolve
36 directories, 21 files
*** Freebsd Nvidia and Cuda
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 |
*** debootstrap install
Install debootstrap which we use to create an ubuntu jail on freebsd
[[https://wiki.debian.org/Debootstrap][Debootstrap - Debian Wiki]]
[[https://docs.freebsd.org/en/books/handbook/linuxemu/][Linux Binary Compatibility]]
sudo pkg install debootstrap
*** doas install
[[https://man.freebsd.org/cgi/man.cgi?query=doas.conf&sektion=5&format=html][doas.conf man page]]
Install doas so we enter the jail 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-jail/freebsd/usr/local/etc/doas.conf
permit keepenv :username
permit nopass :username cmd jexec
permit nopass keepenv root as root
*** freebsd devfs.rules
/etc/devfs.rules
[ubuntu_jail=7] add include $devfsrules_hide_all add include $devfsrules_unhide_basic add include $devfsrules_unhide_login add path 'mixer' unhide add path 'dsp' unhide add path 'dri' unhide add path 'drm' unhide add path 'nvidia' unhide add path 'speaker' unhide
after adding the devfs rules reboot
*** jail config
enable jails
sudo sysrc jail_enable="YES" sudo sysrc cloned_interfaces="lo1" sudo sysrc ifconfig_lo1_aliases="inet 10.10.0.1-12/24"
/etc/rc.conf
jail_enable="YES" cloned_interfaces="lo1" ifconfig_lo1_aliases="inet 10.10.0.1-12/24"
** Setting Up the Jail Directory Tree *** zroot/jails
create the zroot/jails zfs dataset and set the mountpoint
sudo zfs create zroot/jails sudo zfs set mountpoint=/usr/local/jails zroot/jails
***** zroot/jails/linux
create the zroot/jails/linux zfs dataset and set the mountpoint
sudo zfs create zroot/jails/linux sudo zfs set mountpoint=/usr/local/jails/linux zroot/jails/linux
***** zroot/jails/linux/ubuntu
create the zroot/jails/linux/ubuntu zfs dataset and set the mountpoint
sudo zfs create zroot/jails/linux/ubuntu sudo zfs set mountpoint=/usr/local/jails/linux/ubuntu zroot/jails/linux/ubuntu
***** /etc/jail.conf
create the /etc/jail.conf file if it doesn't exist
/etc/jail.conf
add the following code to the jail.conf file to include \ files with a .conf extension in the /etc/jail.conf.d/ directory
exec.start = "/bin/sh /etc/rc"; exec.stop = "/bin/sh /etc/rc.shutdown"; exec.consolelog = "/var/log/jailconsole${name}.log";
***** /etc/jail.conf.d/ubuntu.conf
create the /etc/jail.conf.d/ directory
sudo mkdir -p /etc/jail.conf.d/
/etc/jail.conf.d/ubuntu.conf
ubuntu {
host.hostname = "${name}";
path = "/usr/local/jails/linux/${name}";
# permissions
allow.raw_sockets;
exec.clean;
persist;
sysvmsg=inherit;
sysvsem=inherit;
sysvshm=inherit;
enforce_statfs=1;
# permissions
devfs_ruleset=7;
# network
ip4.addr="lo1|10.10.0.5/24";
# mount
# mount.fstab="/usr/local/jails/linux/ubuntu/etc/fstab";
mount += "devfs $path/dev devfs rw 0 0";
mount += "tmpfs $path/dev/shm tmpfs rw,size=1g,mode=1777 0 0";
mount += "fdescfs $path/dev/fd fdescfs rw,linrdlnk 0 0";
mount += "linprocfs $path/proc linprocfs rw 0 0";
mount += "linsysfs $path/sys linsysfs rw 0 0";
mount += "/tmp $path/tmp nullfs rw 0 0";
mount += "/home $path/home nullfs rw 0 0";
# mount the video directory from the host to the jail after creating it
#mount += "/home/username/video $path/home/username/video nullfs rw 0 0";
# uncomment the line below for the xdg runtime directory for wayland after creating it
#mount += "/var/run/xdg/djwilcox $path/run/user/1001 nullfs rw 0 0";
}
*** pf.conf
/etc/pf.conf:
nat for jail
nat on $int_if from {lo1:network} to any -> ($int_if) antispoof log quick for { lo $int_if } label "block_spoofing"
full pf.conf example
int_if="ue0" # usb to ethernet adaptor
vpn_if="tun0" # vpn interface all_networks="0.0.0.0/0" vpn_network="$vpn_if:network" tcp_services = "{ ntp, 6881 }" # tcp services - torrent udp_services = "{ ntp, 6882 }" # udp services - torrent icmp_types = "{ echoreq, unreach }" tcp_state="flags S/SA keep state" udp_state="keep state"
table
set block-policy drop set loginterface $int_if set fingerprints "/etc/pf.os" set skip on lo0 scrub in all fragment reassemble no-df max-mss 1440
nat on $int_if from {lo1:network} to any -> ($int_if) antispoof log quick for { lo $int_if } label "block_spoofing"
block log all # block log all block return out quick inet6 all tag IPV6 # block ipv6 block in quick inet6 all tag IPV6 # block ipv6
anchor "openvpn"
pass inet proto icmp all icmp-type $icmp_types keep state tag ICMP
pass in on $int_if inet proto tcp from any to ($int_if) port $tcp_services $tcp_state tag TCP_IN pass in on $int_if inet proto udp from any to ($int_if) port $udp_services $udp_state tag UDP_IN
block out on $int_if all pass out quick on $int_if all modulate state
*** Start linux
Use sysrc to set linux_enable="YES" in your /etc/rc.conf
sudo sysrc linux_enable="YES"
or you can edit your
/etc/rc.conf
start linux
sudo service linux start
**** fstab add proc
edit your fstab and add proc
/etc/fstab
fstab
proc /proc procfs rw 0 0
*** Ubuntu rc.d script
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 jail on freebsd that sets the permission of a lot of binaries and libraries in the ubuntu jail 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
[[file:freebsd/usr/local/share/debootstrap/scripts/lunar][lunar]]
[[file:freebsd/usr/local/share/debootstrap/scripts/mantic][mantic]]
Path to the lunar script in this repository
davinci-resolve-freebsd-jail/freebsd/usr/local/share/debootstrap/scripts/lunar
Copy the lunar script from the repository to the debootstrap scripts directory
sudo cp davinci-resolve-freebsd-jail/freebsd/usr/local/share/debootstrap/scripts/lunar /usr/local/share/debootstrap/scripts
Path to the mantic script in this repository
davinci-resolve-freebsd-jail/freebsd/usr/local/share/debootstrap/scripts/mantic
Copy the mantic script from the repository to the debootstrap scripts directory
sudo cp davinci-resolve-freebsd-jail/freebsd/usr/local/share/debootstrap/scripts/mantic /usr/local/share/debootstrap/scripts
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) ;; *)
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
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::Cache-Start 251658240;" >> "$TARGET/etc/apt/apt.conf.d/00freebsd"
progress $bases $bases CONFBASE "Configuring base system"
info BASESUCCESS "Base system installed successfully."
}
*** Create the mount points for Ubuntu
Create necessary mount points for the Ubuntu jail
/usr/local/jails/linux/ubuntu
sudo mkdir -p {/usr/local/jails/linux/ubuntu/dev/fd,/usr/local/jails/linux/ubuntu/dev/shm,/usr/local/jails/linux/ubuntu/home,/usr/local/jails/linux/ubuntu/tmp,/usr/local/jails/linux/ubuntu/proc,/usr/local/jails/linux/ubuntu/sys}
**** debootstrap install Ubuntu
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
/usr/local/jails/linux/ubuntu
debootstrap Ubuntu Mantic
sudo debootstrap --arch=amd64 --no-check-gpg mantic /usr/local/jails/linux/ubuntu http://archive.ubuntu.com/ubuntu/
*** getpwnam
cd /usr/local/jails/linux/ubuntu/etc
switch to root
su -m
cat passwd | sed -r 's/(:[x|]:)([0-9]+:[0-9]+:)/::\2:0:0:/g' > master.passwd
pwd_mkdb -d ./ -p master.passwd
*** jail start
start the ubuntu jail
doas service jail onestart ubuntu
check the jail is running
doas jls
*** enter jail
doas jexec ubuntu /bin/bash
** Ubuntu set up *** dns nameserver
echo nameserver 8.8.8.8 > /etc/resolv.conf
*** Set correct timezone inside the jail
You will now be logged in as root inside the jail
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
*** Fix APT package manager
Run the following command as root
printf "APT::Cache-Start 251658240;" > /etc/apt/apt.conf.d/00aptitude
*** Enable more repositories:
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 jail
/usr/local/jails/linux/ubuntu/etc/apt/sources.list
Path to the sources.list in the jail
/etc/apt/sources.list
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
*** apt update
Run the following commands as root to update and upgrade Ubuntu
apt update
Upgrade
apt upgrade
*** Set locale
/etc/default/locale
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=
Run the following commands as root
locale-gen
locale-gen
dpkg-reconfigure locales
dpkg-reconfigure locales
*** Shell install
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
*** Copy user and group from Freebsd to Ubuntu
We can just copy the settings for our user from Freebsd passwd file
/etc/passwd
to the passwd file on Ubuntu
/usr/local/jails/linux/ubuntu/etc/passwd
**** Freebsd /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 jail
Freebsd passwd
username:*:1001:1001:USER NAME:/home/username:/usr/local/bin/zsh
**** ubuntu passwd
Host path
/usr/local/jails/linux/ubuntu/etc/passwd
jail 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)
**** copy the group from freebsd to ubuntu
Freebsd /etc/group
username:*:1001:
Ubuntu /etc/group
username:*:1001:
*** Add user to groups in the jail
Add the user we created to groups in the jail \ 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
edit the jails group file
vi /etc/group
comment out the root entry and create a new wheel entry, replace username with your username
wheel:*:0:root,username
*** sudo set up
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
*** passwd
Create a passwd for your user, replace username with your username
Run the following command as root
passwd username
*** create the home username directory
change username to your username
mkdir -p /home/username
chown username:username username
*** Couldnt resolve hostname fix
Add your hostname from the jail to the hosts file in the ubuntu jail \ to stop errors when using sudo saying couldnt resolve hostname
Path to the hosts in the jail
vi /etc/hosts
hosts
127.0.0.1 hostname
127.0.0.1 localhost 127.0.0.1 ubuntu ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters
*** Switch to out user with su
switch to your user in the jail \ replace username with your username
su - username
*** Build essential
Verify the system has build tools such as make, gcc installed
Install build-essential for gcc
sudo apt install build-essential
*** ffmpeg install
sudo apt install ffmpeg
*** user-dirs.dirs
create directories in the home directory
mkdir -p "${HOME}"/{desktop,documents,downloads,video}
set the xdg directories to the directories we just created
vi ~/.config/user-dirs.dirs
enabled=False XDG_DESKTOP_DIR="$HOME/desktop" XDG_DOCUMENTS_DIR="$HOME/documents" XDG_DOWNLOAD_DIR="$HOME/downloads" XDG_VIDEOS_DIR="$HOME/video"
*** Create the XDG_RUNTIME_DIR directory
Create the XDG_RUNTIME_DIR directory in the jail
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)"
*** stop the jail and edit the jail config
exit the jail
exit exit
stop the ubuntu jail
doas service jail onestop ubuntu
edit the ubuntu.conf jail config and uncomment the video and xdg directories
/etc/jail.conf.d/ubuntu.conf
ubuntu {
host.hostname = "${name}";
path = "/usr/local/jails/linux/${name}";
# permissions
allow.raw_sockets;
exec.clean;
persist;
sysvmsg=inherit;
sysvsem=inherit;
sysvshm=inherit;
enforce_statfs=1;
# permissions
devfs_ruleset=7;
# network
ip4.addr="lo1|10.10.0.5/24";
# mount
# mount.fstab="/usr/local/jails/linux/ubuntu/etc/fstab";
mount += "devfs $path/dev devfs rw 0 0";
mount += "tmpfs $path/dev/shm tmpfs rw,size=1g,mode=1777 0 0";
mount += "fdescfs $path/dev/fd fdescfs rw,linrdlnk 0 0";
mount += "linprocfs $path/proc linprocfs rw 0 0";
mount += "linsysfs $path/sys linsysfs rw 0 0";
mount += "/tmp $path/tmp nullfs rw 0 0";
mount += "/home $path/home nullfs rw 0 0";
# mount the video directory from the host to the jail after creating it
mount += "/home/username/video $path/home/username/video nullfs rw 0 0";
# uncomment the line below for the xdg runtime directory for wayland after creating it
mount += "/var/run/xdg/djwilcox $path/run/user/1001 nullfs rw 0 0";
}
*** start the ubuntu jail
doas service jail onestart ubuntu
enter the jail
doas jexec ubuntu /bin/sh
switch to our user replace username with your username
su - username
*** Nvidia download
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/]]
Download link for 550.54.14
[[https://www.nvidia.com/download/driverResults.aspx/218826/en-us/]]
*** Nvidia driver install
on the freebsd host move the nvidia installer to the video directory which should be mounted in the jail, so you can cd to the video directory in the jail and install the driver
chmod the Nvidia run file
chmod +x NVIDIA-Linux-x86_64-550.54.14.run
Install the Nvidia driver
sudo ./NVIDIA-Linux-x86_64-550.54.14.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
*** Nvidia-cuda-toolkit
Install the nvidia-cuda-toolkit
sudo apt install nvidia-cuda-toolkit ocl-icd-opencl-dev libglu1-mesa libfuse2 initramfs-tools
*** Blacklist Nouveau Nvidia driver
sudo mkdir -p /etc/modprobe.d
Copy the blacklist-nvidia-nouveau.conf file from the repository to the jail
sudo vi /etc/modprobe.d/blacklist-nvidia-nouveau.conf
blacklist nouveau options nouveau modeset=0
*** update-initramfs
sudo update-initramfs -u
*** wayland packages
sudo apt install libinput-tools wayland-protocols libwlroots11 libwlroots-dev libxkbcommon0 qtwayland5 qt6-wayland wayland-utils adwaita-qt qt5ct libnvidia-egl-wayland1
*** zsh shell config
We need to set some enviormental variables in our shell config
Copy the zshrc config from this reposiory to the jail
cp davinci-resolve-freebsd-jail/ubuntu/home/username/.zshrc /usr/local/jails/linux/ubuntu/home/"${USER}"
Copy the zshenv config from this reposiory to the jail
cp davinci-resolve-freebsd-jail/ubuntu/home/username/.zshenv /usr/local/jails/linux/ubuntu/home/"${USER}"
***** zshrc
We create a blank .zshrc file \ otherwise zsh will complain that theres is no config file
***** zshenv
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 jail
/opt/resolve/bin/resolve
case "$OSTYPE" in freebsd*)
typeset -U PATH path path=("$path[@]") export PATH
export XDG_RUNTIME_DIR=/var/run/xdg/"${USER}"
export WAYLAND_DISPLAY=wayland-0 export QT_QPA_PLATFORM=wayland export GDK_BACKEND=wayland
;; linux*) typeset -U PATH path path=("/opt/resolve/bin" "$path[@]") export PATH
export XDG_RUNTIME_DIR="/run/user/id -u
"
export LD_PRELOAD="${HOME}"/.config/gpu/dummy-uvm.so:/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0:/usr/lib/x86_64-linux-gnu/libgio-2.0.so:/usr/lib/x86_64-linux-gnu/libgmodule-2.0.so export __NV_PRIME_RENDER_OFFLOAD=1 export __GLX_VENDOR_LIBRARY_NAME=nvidia
export DISPLAY=unix:0 export QT_QPA_PLATFORM=xcb export GDK_BACKEND=x11 ;; esac
export XDG_CONFIG_HOME="$HOME/.config" export XDG_CACHE_HOME="$HOME/.cache" export XDG_DATA_HOME="$HOME/.local/share"
export QT_QPA_PLATFORMTHEME=qt5ct
*** xorriso and fakeroot install
Install fakeroot and xorriso for makeresolvedeb
sudo apt install fakeroot xorriso
*** Davinci Resolve download
On the Freebsd host
Go to the Davinci Resolve website and click the \ "Davinci Resolve Free Download Now" link
[[https://www.blackmagicdesign.com/products/davinciresolve/][Davinci Resolve]]
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 from your downloads folder to your video directory which is mounted in the jail
*** makeresolvedeb download
On the Freebsd host download the makeresolvedeb script
[[https://www.danieltufvesson.com/makeresolvedeb][makeresolvedeb]]
Copy the makeresolvedeb_1.6.4_multi.sh.tar.gz from the freebsd host to the home directory in the jail \
cp -rv makeresolvedeb_1.6.4_multi.sh.tar.gz /usr/local/jails/linux/ubuntu/home/"${USER}"
*** makeresolvedeb create deb file
Make sure you have entered the jail by running
doas jexec ubuntu /bin/bash
Switch to out user in the jail, \ replace username with your username
su - username
Install zip
sudo apt install zip
Unzip the resolve zip
unzip DaVinci_Resolve_19.0_Linux.zip
Extract the makeresolvedeb.tar.gz file
tar zxvf makeresolvedeb_1.7.2_multi.sh.tar.gz
then run makeresolvedeb
./makeresolvedeb_1.7.2_multi.sh DaVinci_Resolve_19.0.1_Linux.run
This may take about an hour
*** Install liblog4cxx-dev
sudo apt install liblog4cxx-dev
*** DaVinci Resolve deb install
sudo dpkg -i davinci-resolve_19.0.1-mrd1.7.2_amd64.deb
or
sudo apt install davinci-resolve_19.0.1-mrd1.7.2_amd64.deb
** Pulseaudio set up * Freebsd ** default.pa
Use the pulseaudio default.pa config file to create a pulseaudio socket in the /tmp directory
The /tmp directory is mounted in the jail and allows us to route the audio from the jail to the host
Copy the default.pa from this repository to
~/.config/pulse/default.pa
cp davinci-resolve-freebsd-jail/freebsd/home/username/.config/pulse/default.pa "${HOME}/.config/pulse"
.include /usr/local/etc/pulse/default.pa
.ifexists module-esound-protocol-unix.so load-module module-esound-protocol-unix .endif load-module module-native-protocol-unix socket=/tmp/pulseaudio.socket
* Ubuntu ** client.conf
Full path to the client.conf from freebsd to the jail
/usr/local/jails/linux/ubuntu/home/username/.config/pulse/client.conf
client.conf path in the jail
~/.config/pulse/client.conf
Copy client.conf from this repository into the jail
cp davinci-resolve-freebsd-jail/ubuntu/home/username/.config/pulse/client.conf /usr/local/jails/linux/ubuntu/home/"${USER}"/.config/pulse
#
#
#
; 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
** Davinci Resolve Desktop entry * Freebsd ** resolve script
Freebsd script to launch Davinci Resolve from a Linux Jail
Path to resolve in this repository
davinci-resolve-freebsd-jail/freebsd/usr/local/bin/resolve
Copy the resolve script from the repository to the freebsd bin directory
sudo cp davinci-resolve-freebsd-jail/freebsd/usr/local/bin/resolve /usr/local/bin
pulseaudio --start --daemonize 2>/dev/null
doas jexec ubuntu /usr/local/bin/wrapper-resolve \ -d "DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}" \ -u "${USER}"
* Ubuntu ** wrapper-resolve
Path to wrapper-resolve in this repository
davinci-resolve-freebsd-jail/ubuntu/usr/local/bin/wrapper-resolve
Copy the script to the jail
sudo cp davinci-resolve-freebsd-jail/ubuntu/usr/local/bin/wrapper-resolve /usr/local/jails/linux/ubuntu/usr/local/bin
Freebsd path to wrapper-resolve in the jail
/usr/local/jails/ubuntu/usr/local/bin/wrapper-resolve
Path to wrapper-resolve in the jail
/usr/local/bin/wrapper-resolve
usage () {
[ -z "${1}" ] || echo "! ${1}"
echo "\
$(basename "$0") -u ${USER}" exit 2 }
[ $# -gt 0 ] || usage "${WRONG_ARGS_ERR}"
while getopts ':u:d:h' opt do case ${opt} in u) username="${OPTARG}";; d) dbus="${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))
su "${username}" -c "${dbus} /opt/resolve/bin/resolve" 2>/dev/null
*** davinci-resolve.desktop
Path to davinci-resolve.desktop in this repository
davinci-resolve-freebsd-jail/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-jail/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=/usr/local/jails/linux/ubuntu/opt/resolve/graphics/DV_Resolve.png Terminal=false MimeType=application/x-resolveproj; StartupNotify=true Categories=AudioVideo
** start the jail
you need to start the jail before you can use it
doas service jail onestart ubuntu