Main Page: Difference between revisions

From pega.life
Jump to navigation Jump to search
Line 496: Line 496:


https://github.com/TritonDataCenter/illumos-joyent/blob/master/usr/src/uts/common/brand/lx/os/lx_syscall.c
https://github.com/TritonDataCenter/illumos-joyent/blob/master/usr/src/uts/common/brand/lx/os/lx_syscall.c
AIO
https://github.com/TritonDataCenter/illumos-joyent/blob/master/usr/src/uts/common/brand/lx/syscall/lx_aio.c


==== FreeBSD Sys Calls ====
==== FreeBSD Sys Calls ====

Revision as of 14:05, 16 April 2025

Movies

  • Joy Luck Club
  • Motherless Brooklyn
  • Dune
  • The Big Short
  • Andre The Giant 2018
  • Joker
  • Spider-Man
  • The Social Dilemma
  • King Richard (Will Smith)👍🏽
  • Shang-Chi
  • Venom
javascript:window.location=document.querySelector('#player iframe').src;
javascript:window.location=document.querySelector('#player video').src;

Shows

  • Marvelous Mrs Mazel
  • Watchmen (TV series)
  • Picard
  • Cocaine Cowboys Miami

Food

  • Korean BBQ
  • home made chicken shawarma

Travel

  • Pembina Valley
  • Banff
  • West Edmonton Mall
  • bunns creek trail (on way to half moon)
  • Bryce Canyon Utah

Disney World

Magic Kingdom

Universal Studios

Costa Rica

air bnb

  • casa Eden / Jungle Box - AC

Todo

  • Bocas

UNIX

RETRO DESKTOP/PC UNIX

OSes


QNX

https://forums.openqnx.com/t/topic/5043/4 If you only have one QNX partition, which is mounted as /, you can just touch /.longfilenames chmod 444 /.longfilenames chown root:root /.longfilenames

You will need to umount and mount the partition again before it can take effect. It usually means a reboot, especially if you are working on the root partition.

pkgsrc https://archive.netbsd.org/pub/pkgsrc-archive/packages/QNX/i386/6.5.0_head_20110826/

# PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
# PKG_PATH="https://cdn.NetBSD.org/pub/pkgsrc/packages"
# PKG_PATH="$PKG_PATH/OPSYS/ARCH/VERSIONS/All/"
# export PATH PKG_PATH
# pkg_add pkgin

$ CVS_RSH=ssh cvs -danoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2024Q1 -P pkgsrc

bash
TERM=vt100
PS1='\h:\w# '
export ACCEPT_INFERIOR_RM_PROGRAM=yes

cp -r pkgsrc-2019Q1/{Makefile,mk,pkgtools,lang/nawk,textproc/nbsed,bootstrap} pkgsrc-qnx/
CCLD     libarchive.la
./libtool: libarchive/archive_options.lo: cannot execute - Permission denied
Memory fault (core dumped) 
*** [libarchive.la] Error code 139

bmake[1]: stopped in /root/pkgsrc-qnx/bootstrap/work/libarchive
add# pwd
/root/pkgsrc-qnx/bootstrap/work/pkg_install/add
add# gcc -L/root/pkgsrc-qnx/bootstrap/work/libnbcompat -L../lib -o pkg_add main.o perform.o -linstall /root/pkgsrc-qnx/bootstrap/work/libarchive/.libs/libarchive.a -lsocket  -lnbcompat 
../lib/libinstall.a(remove.o): In function `safe_fchdir':
/root/pkgsrc-qnx/bootstrap/work/pkg_install/lib/remove.c:68: undefined reference to `fchdir'
../lib/libinstall.a(remove.o): In function `recursive_remove_internal':
/root/pkgsrc-qnx/bootstrap/work/pkg_install/lib/remove.c:148: undefined reference to `fchdir'
collect2: ld returned 1 exit status
add# 
pkgsrc
mkdir -p pkgsrc-qnx/{sysutils,lang,textproc,devel,archivers,net}
cp -r pkgsrc-2019Q1/{Makefile,mk,licenses,pkgtools,bootstrap} pkgsrc-qnx/
cp -r pkgsrc-2019Q1/sysutils/install-sh pkgsrc-qnx/sysutils/
cp -r pkgsrc-2019Q1/lang/gcc8 pkgsrc-qnx/lang/
cp -r pkgsrc-2024Q1/devel/bmake pkgsrc-qnx/devel/
cp -r pkgsrc-2024Q1/lang/nawk pkgsrc-qnx/lang/
cp -r pkgsrc-2024Q1/textproc/nbsed pkgsrc-qnx/textproc/
cp -r pkgsrc-2024Q1/pkgtools/libnbcompat pkgsrc-qnx/pkgtools/
cp -r pkgsrc-2019Q1/pkgtools/pkg_install pkgsrc-qnx/pkgtools/
cp -r pkgsrc-2019Q1/archivers/libarchive pkgsrc-qnx/archivers/
cp -r pkgsrc-2019Q1/net/libfetch pkgsrc-qnx/net/
cp libfetchMakefile2019 pkgsrc-qnx/net/libfetch/files/Makefile 
cp -p pkgsrc-old/bootstrap/*20?? pkgsrc-qnx/bootstrap/

cd pkgsrc-qnx/bootstrap
./bootstrap2019
./pkg_build2015 --make-jobs 4# pkg_install (no libarchive)
./mk-files2019  --make-jobs 4

libarchive 2017 core dump libarchive 2024 fchdir libarchive 2015 libarchive 2019

SCO 4.2

OpenDeskTop is nothing else than SCO Unix 4.2 bundled with X11 and TCP/IP https://ftp.sco.com/TLS/file.list

https://mezzantrop.wordpress.com/2021/02/07/notes-on-installing-sco-open-desktop-release-3-0-in-2021/

Create a VirtualBox guest machine with the above shown characteristics Grab the OS distribution here: https://winworldpc.com/download/41c2b04d-2d18-c39a-11c3-a4e284a2c3a5 and extract files from 7-zip archive. There is a file serial.txt with serial number/code – Sn: SOT552746, Ak: kqpzdsso which is for SCO Open Desktop Release 3.0 Distribution missed N1 boot disk. Grab it from SCO FTP server: ftp://ftp.sco.com/pub/SLS/uod383bon1.Z, don’t mix it with the other boot disk which is for SCO UNIX OS: uod383bun1.Z. Uncompress the boot disk image and rename it just to look nicer: $ uncompress uod383bon1.Z $ mv uod383bon1 uod383bon1.img Insert the uod383bon1.img into the virtual floppy drive and pedantically follow the installation instructions, by inserting and sometimes re-inserting all the 40+ diskettes into the virtual floppy drive. Download, uncompress and install all the necessary Advanced Hardware Supplement (AHS) for the new drivers: ftp://ftp.sco.com/pub/AHS/3.0/sco/3.4/135/ Download, uncompress and install all the necessary Support Level Supplements (SLS) to update OS and drivers: ftp://ftp.sco.com/pub/SLS/ To enable network in our minimal configuration install ftp://ftp.sco.com/pub/AHS/3.0/sco/3.4/135/lli.Z and ftp://ftp.sco.com/pub/SLS/net387a.Z to configure AMD Pcnet-PCI LAN driver

Software


Games

  • X68000: Puzzle: Deflektor
  • SNES: Puzzle: Bust-A-Move, The Lost Vikings
  • SNES: VS: Super Bomberman, Tetris Attack
  • SNES: Co-Op: Contra III, Wild Guns
  • SNES: Action RPG: Front Mission Gun Hazard
  • MAME: puzzle: Money Puzzle Exchanger
  • NEOGEO: Co-Op: Alpha Mission 2, Mslug, robo army, Shock Troopers
  • NEOGEO: VS: League Bowling, WindJammer, The Last Blade, Garou

emus

https://www.youtube.com/watch?app=desktop&v=UGtU5wRWuhc

mega thread

Bike

  • tighten seat
  • buy helmet

To Do

  • Red pocket
  • Plumber

Self Hosting

Fossil

https://dev.to/schollz/self-hosting-with-fossil-an-alternative-to-git-33bk

certbot

Add new cert:

# sudo certbot certonly -d wiki.ho.stna.me
Saving debug log to /var/log/letsencrypt/letsencrypt.log

How would you like to authenticate with the ACME CA?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Nginx Web Server plugin (nginx)
2: Spin up a temporary webserver (standalone)
3: Place files in webroot directory (webroot)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-3] then [enter] (press 'c' to cancel): 1
Plugins selected: Authenticator nginx, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for wiki.ho.stna.me
Using default addresses 80 and [::]:80 ipv6only=on for authentication.
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:

nginx

stalwart mail

static binary

Remove jemallocator Dependency: In the crates/main/Cargo.toml file, locate and remove or comment out the following lines:

[target.'cfg(not(target_env = "msvc"))'.dependencies]
jemallocator = "0.5.0"

Modify main.rs to Use the System Allocator: In crates/main/src/main.rs, remove or comment out the lines that set jemalloc as the global allocator:

#[cfg(not(target_env = "msvc"))]
use jemallocator::Jemalloc;

#[cfg(not(target_env = "msvc"))]
#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;
pkg install rust gmake rocksdb 


RUSTFLAGS="-C target-feature=+crt-static -C link-arg=-lelf" \
PKG_CONFIG_ALL_STATIC=1 \
cargo build --release --target x86_64-unknown-freebsd

   Compiling mail-server v0.11.7 (/root/mail-server/crates/main)
    Finished `release` profile [optimized] target(s) in 12m 42s

cargo build --release -p mail-server --no-default-features --features "sqlite rocks enterprise" ; 
cargo build --release -p stalwart-cli
note: ld: error: cannot open Scrt1.o: No such file or directory
          ld: error: cannot open crti.o: No such file or directory
          ld: error: cannot open crtbeginS.o: No such file or directory
# tar tf base.txz | grep Scrt
./usr/lib/Scrt1.o
warning=zstd/lib/legacy/zstd_v07.c:13
:10: fatal error: 'stddef.h' file not found
cd /
tar xpvf ~/base.txz usr/include

ldd no -lgcc
FreeBSD-libcompiler_rt-dev-14.2p3

Linux

Apt

E: Dynamic MMap ran out of room. Please increase the size of APT::Cache-Start. Current value: 25165824. (man 5 apt.conf)
Reading package lists... Error!
echo 'APT::Cache-Start "50000000";' > /etc/apt/apt.conf.d/99custom-cache
#

Archiver / PeaZip

File Manager Integration (Context Menus)

https://peazip.github.io/peazip-linux.html https://wiki.archlinux.org/title/GNOME/Files#Custom_scripts

https://github.com/peazip/PeaZip/releases/download/9.5.0/peazip_portable-9.5.0.LINUX.GTK2.x86_64.tar.gz

From the portable download, find scripts in the folder: res/share/batch/freedesktop_integration/

Custom scripts

Scripts placed in ~/.local/share/nautilus/scripts can be run from the right click context menu of a file.

The context menu can also be organized into subfolders, e.g. ~/.local/share/nautilus/scripts/images and ~/.local/share/nautilus/scripts/music.

SmartOS

Upgrade

SmartOS (build: 20250220T074131Z)
[root@cloud ~]# piadm avail
20250306T000316Z
[root@cloud ~]# piadm -v install 20250306T000316Z
[root@cloud ~]# piadm list
PI STAMP               BOOTABLE FILESYSTEM            BOOT IMAGE NOW  NEXT
20250220T074131Z       zones/boot                     next       yes  yes
20250306T000316Z       zones/boot                     available  no   no
[root@cloud ~]# piadm -v activate 20250306T000316Z
[root@cloud ~]# piadm list
PI STAMP               BOOTABLE FILESYSTEM            BOOT IMAGE NOW  NEXT
20250220T074131Z       zones/boot                     available  yes  no
20250306T000316Z       zones/boot                     next       no   yes
[root@cloud ~]#

Migrating

https://docs.smartos.org/managing-instances-with-vmamd/#migrate-an-instance-to-a-different-compute-node

LX Docker

steps

  1. run image on docker (same arch)
  2. find docker CMD
  3. check existing lx zones
  4. create lx zone
  5. export docker fs (tar)
  6. replace lx zone's root fs with docker fs (tar)
  7. start lx zone

lxcreate script -->

#!/bin/sh

# Check if alias and ip are provided as arguments
if [ -z "$2" ]; then
    echo "Usage: $0 <alias> <ip> <env> [mem=64] [swap=256] [image_uuid=0b7d45d9-be8c-439f-9a24-bd6223199c2b]"
    echo "NOTE: alias is used for docker image, by default alias:latest is used"
    echo "IE: docker run alias:latest"
    echo "ex: $0 mediawiki 192.168.3.123/24"
    echo "ex: $0 mediawiki 192.168.3.123/24 NODE_ENV=development"
    echo "ex: $0 mediawiki 192.168.3.123/24 NODE_ENV=development 128 256"
    exit 1
fi

# Assign arguments to variables
alias="$1"
ip="$2"
env="$3"
mem="${4:-64}"           # Default to 64 if mem not provided
swap="${5:-256}"         # Default to 256 if swap not provided
#image_uuid=$(imgadm avail -H -o uuid name=~alpine type=~lx | tail -n1)
# Default to latest alpine lx
#image_uuid="${8:-$(imgadm avail -H -o uuid name=~alpine type=~lx | tail -n1)}"
# Default to alpine 2025-01-20
image_uuid="${6:-0b7d45d9-be8c-439f-9a24-bd6223199c2b}"

image=$(imgadm list -H -o uuid uuid=~0b7d45d9-be8c-439f-9a24-bd6223199c2b)
if [ -z "$image" ]; then
    imgadm import $image_uuid
fi


# Basic IP CIDR validation (eg, 192.168.3.123/24)
if ! echo "$ip" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/[0-9]+$'; then
    echo "Error: IP must be in CIDR format (e.g., 192.168.3.123/24) or 'dhcp'"
    exit 1
fi


echo "Fetching $alias:latest..."
if [ -z "$env" ]; then
    ssh apod "podman run -d --rm --name $alias $alias:latest"
else
    ssh apod "podman run -d --rm --name $alias -e $env $alias:latest"
fi

dir=$(ssh apod "podman inspect $alias | jq  -r '.[0].Config | .WorkingDir'")
env=$(ssh apod "podman inspect $alias | jq -r '.[0].Config.Env'" | tr -s '\n' ' ' | sed 's/"/\\"/g')
cmd=$(ssh apod "podman inspect $alias | jq -r '.[0].Config.Cmd'" | tr -s '\n' ' ' | sed 's/"/\\"/g')
entry=$(ssh apod "podman inspect $alias | jq -r '.[0].Config.Entrypoint'" | tr -s '\n' ' ' | sed 's/"/\\"/g')


vmadm create << EOF
{ "brand": "lx", "kernel_version": "5.15",
"autoboot": true,
"docker": true,
"internal_metadata": {
  "docker:workingdir": "${dir}",
  "docker:env": "${env}",
  "docker:cmd": "${cmd}",
  "docker:entrypoint": "${entry}"
},

"image_uuid": "${image_uuid}",
"alias": "${alias}","hostname": "${alias}",
"max_physical_memory": ${mem}, "max_swap": ${swap},
"resolvers": ["1.1.1.1"], "nics": [ { "nic_tag": "admin",
"gateway": "192.168.3.1",
"ips": ["${ip}"]
} ] }
EOF

uuid=$(vmadm list -H -o uuid alias=$alias)
rm -rf /zones/$uuid/root
mkdir /zones/$uuid/root

echo "Transferring image..."
ssh -C apod "podman export $alias" | tar xpf - -C /zones/$uuid/root 2>/dev/null
vmadm start $uuid && \
        ssh apod "podman stop $alias"

lxcreate

[root@smartos ~]# /zones/lxcreate
Usage: ./lxcreate <alias> <ip> <env> [mem=64] [swap=256] [image_uuid=0b7d45d9-be8c-439f-9a24-bd6223199c2b]
NOTE: alias is used for docker image, by default alias:latest is used
IE: docker run alias:latest
ex: ./lxcreate mediawiki 192.168.3.123/24
ex: ./lxcreate ghost 192.168.3.123/24 NODE_ENV=development
ex: ./lxcreate ghost 192.168.3.123/24 NODE_ENV=development 128 256

mediawiki

[root@smartos ~]# /zones/lxcreate mediawiki 192.168.3.123/24
Fetching mediawiki:latest...
5edd70c248cfb94b5e46b3d771b0f2dfc7a067c54619f0871dfd24b2f063a86a
Successfully created VM fb9d0fe9-c34e-4c51-8b4e-19820257935b
Transferring image...
Successfully started VM fb9d0fe9-c34e-4c51-8b4e-19820257935b
mediawiki

ghost

sometimes you need to set environment variables (https://hub.docker.com/_/ghost)

$ podman run -d --name some-ghost -e NODE_ENV=development ghost
[root@smartos ~]# vm-create ghost 192.168.3.123/24 NODE_ENV=development
Successfully created VM 7ceaeea2-7bc4-4e89-ab3f-da516982548b

sometimes you need to delete/edit the entrypoint

alias=ghost
uuid=$(vmadm list -H -o uuid alias=$alias)
sed -i '.orig' '/entrypoint/d' /zones/$uuid/config/metadata.json
# not sure why, but this was needed
(cd /zones/$uuid/root/var/lib/ghost; mv content content.del; mv content.orig content)
vmadm reboot $uuid
#
[root@smartos ~]# alias=ghost
[root@smartos ~]# uuid=$(vmadm list -H -o uuid alias=$alias)
[root@smartos ~]# vmadm get $uuid | grep entry
    "docker:entrypoint": "[ \"docker-entrypoint.sh\" ] ",
[root@smartos ~]# echo '#!/bin/bash
cd /var/lib/ghost
gosu node node current/index.js
' > $(find /zones/$uuid -name docker-entrypoint.sh 2> /dev/null)

not sure why, but this was needed

[root@smartos ~]# (cd /zones/$uuid/root/var/lib/ghost; mv content content.del; mv content.orig content)

img-import

test images

stalwartlabs/mail-server (zstd layer)

alpine/sqlite ("mediaType": "application/vnd.docker.distribution.manifest.list.v2+json")

ghost (whiteout files/layer)

FreeBSD

Packages

https://pkg-status.freebsd.org/builds/foo:default:142amd64:2025-04-09_07h07m39s:gohan06#new_failed

CUDA

https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Rocky&target_version=9&target_type=rpm_local

pkg install nvidia-driver  
kldload nvidia
kldload nvidia-modeset 
 # sysrc kld_list+=nvidia-modeset 
kldload linux64
pkg install linux_base-rl9  
pkg install linux-rl9-libxml2
pkg install gcc #gcc13

fetch https://developer.download.nvidia.com/compute/cuda/12.5.1/local_installers/cuda_12.5.1_555.42.06_linux.run
./cuda_12.5.1_555.42.06_linux.run

fetch https://developer.download.nvidia.com/compute/cuda/12.5.1/local_installers/cuda-repo-rhel9-12-5-local-12.5.1_555.42.06-1.x86_64.rpm

rpm2cpio cuda-repo-rhel9-12-5-local-12.5.1_555.42.06-1.x86_64.rpm > cuda.cpio
cpio -idmv < cuda.cpio

var/cuda-repo-rhel9-12-5-local# rpm2cpio nvidia-driver-cuda-libs-555.42.06-1.el9.x86_64.rpm > nvidia-driver-cuda-libs-555.42.06-1.el9.x86_64.cpio
cpio -idmv < nvidia-driver-cuda-libs-555.42.06-1.el9.x86_64.cpio


brandelf -t Linux <path_to_CUDA_installer>
./cuda_<version>_linux.run

LD_LIBRARY_PATH=/usr/lib64 ffmpeg -i TheBear-S03E01.ts -c:v h264_nvenc -preset slow -b:v 5000k -maxrate 5000k -bufsize 10000k -pix_fmt yuv420p -c:a aac output.mp4

Containers

containerd / runj

https://productionwithscissors.run/2022/09/04/containerd-linux-on-freebsd/


https://catalog.ngc.nvidia.com/orgs/nvidia/containers/cuda/tags
nvcr.io/nvidia/cuda:12.5.1-cudnn-devel-ubuntu20.04

https://github.com/canonical/microk8s/issues/1239
#ctr run --rm --gpus 0 docker.io/nvidia/cuda:9.0-base nvidia-smi nvidia-smi

ctr image pull --platform=linux nvcr.io/nvidia/cuda:12.5.1-cudnn-devel-ubuntu20.04

VMs

qemu / quickemu

https://github.com/quickemu-project/quickemu?tab=readme-ov-file

pkg install qemu-nox11 coreutils socat usbutils swtpm zsync samba416 qemu-nox11 edk2-qemu-x64
git clone https://github.com/quickemu-project/quickemu
cd quickemu
./quickget alpine v3.11

cat freebsd.patch
diff --git a/quickemu b/quickemu
index f2bd9df..2ad1933 100755
--- a/quickemu
+++ b/quickemu
@@ -652,6 +652,8 @@ function configure_bios() {
             if command -v brew &>/dev/null; then
                 SHARE_PATH="$(brew --prefix qemu)/share"
             fi
+       elif [ "${OS_KERNEL}" == "FreeBSD" ]; then
+               SHARE_PATH=/usr/local/share
         fi
 
         # https://bugzilla.redhat.com/show_bug.cgi?id=1929357#c5
@@ -675,7 +677,9 @@ function configure_bios() {
                         "${SHARE_PATH}/edk2-ovmf/OVMF_CODE.fd","${SHARE_PATH}/edk2-ovmf/OVMF_VARS.fd" \
                         "${SHARE_PATH}/qemu/ovmf-x86_64-4m-code.bin","${SHARE_PATH}/qemu/ovmf-x86_64-4m-vars.bin" \
                         "${SHARE_PATH}/qemu/edk2-x86_64-code.fd","${SHARE_PATH}/qemu/edk2-x86_64-code.fd" \
-                        "${SHARE_PATH}/edk2-ovmf/x64/OVMF_CODE.fd","${SHARE_PATH}/edk2-ovmf/x64/OVMF_VARS.fd"
+                        "${SHARE_PATH}/edk2-ovmf/x64/OVMF_CODE.fd","${SHARE_PATH}/edk2-ov
mf/x64/OVMF_VARS.fd" \
+                        "${SHARE_PATH}/edk2-qemu/QEMU_UEFI_CODE-x86_64.fd","${SHARE_PATH}
/edk2-qemu/QEMU_UEFI_VARS-x86_64.fd"
+
                     );;
             esac
             # Attempt each EFI_CODE file one by one, selecting the corresponding code and
 vars

Linuxulator

nginx linuxulator

2025/04/09 17:52:30 [emerg] 51722#51722: io_setup() failed (38: Function not implemented)
2025/04/09 17:52:30 [alert] 51721#51721: epoll_ctl(1, 6) failed (22: Invalid argument)
/var/log/nginx # grep fail error.log 
# podman run --os=linux -d --name nginx nginx:1.27.4
# dmesg | grep linux | tail
linux: jid 106 pid 92741 (nginx): syscall io_setup not implemented
linux: jid 106 pid 92739 (nginx): epoll_ctl unsupported flags: 0x10000001
# kldunload linux_common
kldunload: can't unload file: Device busy
kldstat
Id Refs Address                Size Name
77    1 0xffffffff8ba2e000     73c0 linprocfs.ko
78    1 0xffffffff8baa7000     c2a8 linux_common.ko
# kldunload linprocfs
procstat -ak | grep linux
io_setup

https://github.com/TritonDataCenter/illumos-joyent/blob/master/usr/src/uts/common/brand/lx/syscall/lx_aio.c

netcat

nc -kl 8080 telnet localhost 8080

Linux Sys Calls

https://man7.org/linux/man-pages/man2/syscalls.2.html

AIO https://elixir.bootlin.com/linux/v6.13.7/source/fs/aio.c#L1382

SmartOS LX Sys Calls

https://github.com/TritonDataCenter/illumos-joyent/tree/master/usr/src/uts/common/brand/lx

https://github.com/TritonDataCenter/illumos-joyent/blob/master/usr/src/uts/common/brand/lx/os/lx_syscall.c

AIO https://github.com/TritonDataCenter/illumos-joyent/blob/master/usr/src/uts/common/brand/lx/syscall/lx_aio.c

FreeBSD Sys Calls

https://cgit.freebsd.org/src/tree/sys/amd64/linux/linux_syscall.h https://cgit.freebsd.org/src/tree/sys/compat/linux/linux_dummy.c

https://alfonsosiciliano.gitlab.io/posts/2021-01-02-freebsd-system-calls-table.html

https://alfonsosiciliano.gitlab.io/posts/2023-08-28-freebsd-15-system-calls.html


https://docs.freebsd.org/en/articles/linux-emulation/#syscall-handling

= FreeBSD dev

pkg install lua54-luafilesystem lua54-posix

differences

Yes, I’m familiar with both SmartOS LX zones and FreeBSD’s Linuxulator. These are two different approaches to providing Linux binary compatibility on non-Linux systems, and their differing abilities to run systemd highlight some key technical distinctions. Let’s break this down and address what’s missing in FreeBSD’s Linuxulator to support systemd, as well as how you might approach enabling it by leveraging SmartOS/Illumos source code.

SmartOS LX Zones and FreeBSD Linuxulator
  • SmartOS LX Zones: LX zones are a feature of Illumos-based systems (like SmartOS) that allow running Linux binaries in a lightweight containerized environment called a "branded zone." These zones provide a near-native Linux kernel ABI (Application Binary Interface) by translating Linux system calls into Illumos equivalents. LX zones were originally developed by Joyent to support running Linux applications, including Docker, on SmartOS. Over time, they’ve been extended to support more complex Linux-specific features, including systemd, which is the default init system for many modern Linux distributions.
  • FreeBSD Linuxulator: The Linuxulator is FreeBSD’s Linux binary compatibility layer. It allows FreeBSD to run unmodified Linux ELF binaries by translating Linux system calls to FreeBSD equivalents. Unlike LX zones, it’s not a containerization technology but a kernel-level compatibility layer that operates alongside native FreeBSD processes. It currently supports a subset of Linux kernel functionality, with compatibility levels pegged at Linux 3.2.0 in FreeBSD 12-STABLE and Linux 5.15.0 in FreeBSD 14-STABLE (as of recent documentation). However, it lacks support for several Linux-specific features required by systemd.

Why Systemd Works in LX Zones but Not Linuxulator

Systemd is a complex init system that relies heavily on Linux-specific kernel features, such as:

  • cgroups (Control Groups): Used for resource management and process grouping.
  • Namespaces: Particularly PID, mount, and user namespaces, which provide isolation and scoping for processes.
  • Fanotify: A file system notification system used by systemd for monitoring file events.
  • Specific System Calls: Systemd depends on calls like pidfd_open(), clone3(), and others introduced in newer Linux kernels.
  • udev Integration: Systemd integrates tightly with udev, which relies on Linux-specific device management mechanisms.

SmartOS LX Zones have evolved to support these features. The Illumos kernel, with contributions from Joyent and the SmartOS community, has implemented enough of the Linux kernel ABI—including cgroups, namespaces, and additional system calls—to allow systemd to function within an LX-branded zone. This was driven by the need to support Docker and other modern Linux workloads, which often assume systemd is present.

FreeBSD Linuxulator, on the other hand, does not yet support these features fully. While it can run many Linux binaries (e.g., statically linked programs or those with simpler dependencies), its compatibility layer is incomplete for systemd’s requirements. The Linuxulator’s development has historically focused on supporting popular applications (like Steam or proprietary tools) rather than replicating the full Linux kernel feature set, and systemd support has not been a priority.

What’s Missing in FreeBSD Linuxulator?

To run systemd in FreeBSD’s Linuxulator, the following gaps need to be addressed:

1. cgroups Support
  • Current State: FreeBSD has no native cgroups implementation. It uses its own resource control mechanisms (e.g., rctl for resource limits and jails for isolation), which are philosophically and technically different from Linux’s cgroups.
  • Requirement: Systemd expects cgroups v1 or v2 for process grouping, resource limiting, and service management. Without this, systemd cannot initialize properly.
2. Namespaces
  • Current State: FreeBSD supports some namespace-like features via jails and VNET (virtual networking), but these are not equivalent to Linux’s PID, mount, or user namespaces. The Linuxulator does not translate Linux namespace-related system calls (e.g., unshare(), clone() with namespace flags) into FreeBSD equivalents.
  • Requirement: Systemd uses namespaces for service isolation and scoping, particularly PID namespaces to manage process trees.
3. System Call Gaps
  • Current State: The Linuxulator implements a subset of Linux system calls (see sys/compat/linux/linux_sysent.c in the FreeBSD source). Missing calls include newer ones like pidfd_open() (Linux 5.3+), clone3() (Linux 5.3+), and others that systemd may use.
  • Requirement: Full compatibility with the system calls systemd depends on, which may require extending the Linuxulator’s syscall table.
4. Fanotify and File System Events
  • Current State: FreeBSD has kqueue for event notification, but it’s not compatible with Linux’s fanotify API, which systemd uses for file system monitoring.
  • Requirement: An emulation layer to map fanotify calls to kqueue or a custom implementation.
5. udev and Device Management
  • Current State: FreeBSD uses devd for device management, which differs significantly from Linux’s udev. The Linuxulator does not fully emulate udev’s behavior or its integration with the kernel.
  • Requirement: Systemd expects udev to manage device events, so a compatibility layer or partial udev emulation is needed.
6. Kernel ABI Stability and Versioning
  • Current State: The Linuxulator mimics a specific Linux kernel version (e.g., 5.15.0 in FreeBSD 14-STABLE), but systemd may expect features from newer kernels or specific behaviors not yet emulated.
  • Requirement: Ensuring the emulated ABI matches a Linux kernel version that systemd supports (e.g., at least 4.4 or later for modern versions).

Where to Start: Leveraging SmartOS/Illumos Source

Since both SmartOS (Illumos) and FreeBSD are open source, you can study the LX zone implementation to guide enhancements to the Linuxulator. Here’s a step-by-step approach:

1. Study Illumos LX Zone Source Code
  • Location: The relevant code is in the Illumos gate repository, specifically under usr/src/uts/common/brand/lx/ and related directories. Key files include:
    • lx_syscalls.c: Handles Linux system call emulation.
    • lx_cgroups.c: Implements cgroups support.
    • lx_namespace.c: Manages Linux namespace emulation.
    • lx_fanotify.c: Provides fanotify support.
  • Key Insight: Illumos has extended its kernel to natively support these features for LX zones, rather than just translating them to existing Solaris/Illumos mechanisms. This suggests FreeBSD may need a hybrid approach—either adding native support or building a more comprehensive translation layer.
2. Map Illumos Features to FreeBSD
  • cgroups: Start by reviewing lx_cgroups.c. You could either:
    • Implement a minimal cgroups shim in the Linuxulator that maps to FreeBSD’s rctl or a new subsystem.
    • Port Illumos’s cgroups implementation directly, adapting it to FreeBSD’s kernel architecture.
  • Namespaces: Look at lx_namespace.c. FreeBSD jails and VNET provide a foundation, but you’d need to extend the Linuxulator to handle clone() and unshare() with namespace flags, possibly by mapping them to jail-like constructs.
  • System Calls: Compare Illumos’s lx_syscalls.c with FreeBSD’s sys/compat/linux/linux_sysent.c. Add missing syscalls (e.g., pidfd_open(), clone3()) by adapting Illumos’s implementations or writing new ones based on Linux kernel source (e.g., from kernel.org).
  • Fanotify: Use lx_fanotify.c as a model to build a translation layer from fanotify to kqueue.
3. Modify FreeBSD Linuxulator
  • Source Location: FreeBSD’s Linuxulator code is in sys/compat/linux/ in the FreeBSD source tree (e.g., /usr/src/sys/compat/linux/ if you’ve cloned the repo).
  • Steps:
  1. Extend the syscall table (linux_sysent.c) with missing calls, using Illumos as a reference.
  2. Add new kernel modules or hooks for cgroups and namespaces, potentially under sys/compat/linux/.
  3. Implement fanotify emulation by integrating with kqueue.
  4. Test with a minimal systemd binary (e.g., from a lightweight distro like Alpine) in a chroot environment.

4. Test and Iterate =

  • Setup: Use a FreeBSD jail with Linuxulator enabled (e.g., via sysctl compat.linux.emulation=1 and a Linux base system in /compat/linux or /compat/ubuntu).
  • Test Case: Try running systemd --version or a simple systemd init process. Debug failures using ktrace or truss to identify missing syscalls or features.
  • Reference: Illumos’s LX zone testing scripts (e.g., in usr/src/test/) can inspire a test suite.
5. Community and Documentation
  • FreeBSD Resources: Check the FreeBSD Wiki’s Linuxulator page and the linux(4) man page for current capabilities and known gaps.
  • Illumos Resources: The Illumos wiki and SmartOS documentation provide insights into LX zone internals.
  • Collaboration: Engage with the FreeBSD and Illumos communities (e.g., via mailing lists like freebsd-hackers@ or the Illumos IRC) to validate your approach and get feedback.

Challenges and Considerations

  • Philosophical Differences: FreeBSD avoids adopting Linux-specific features natively (e.g., cgroups) to maintain its distinct identity. You may need to argue for a compatibility-only approach rather than kernel bloat.
  • Performance: Emulating complex features like cgroups and namespaces could introduce overhead, unlike Illumos’s native integration.
  • Upstream Acceptance: Contributions to FreeBSD must align with project goals. Systemd support might face resistance unless justified by broad use cases (e.g., Docker compatibility).

Starting Point

Clone the FreeBSD source (git clone https://git.freebsd.org/src.git) and Illumos gate (git clone https://github.com/illumos/illumos-gate.git). Begin by prototyping cgroups support—perhaps a minimal shim in sys/compat/linux/—and test it with a systemd binary. Use Illumos’s lx_cgroups.c as a blueprint, adapting it to FreeBSD’s kernel structure (e.g., replacing Illumos’s zone_t with FreeBSD’s struct prison for jail integration).

This is a significant undertaking, but with both projects being open source, you have the raw materials to bridge the gap. Good luck, and feel free to ask if you need more specific guidance as you dive in!

Podman

wiki

# podman restart wiki
Error: 1 error occurred:
        * plugin type="bridge" failed (delete): cni plugin bridge failed: error removing 10.88.0.26 from cni-nat table: %!v(MISSING)

Containers

Buildah for containers https://honeyguide.eu/posts/build-own-containers-buildah-podman-freebsd/

FreeBSD Containers https://people.freebsd.org/~dch/posts/2024-12-04-freebsd-containers/


export OCIBASE=https://download.freebsd.org/releases/OCI-IMAGES/14.2-RELEASE/amd64/Latest
podman load -i=$OCIBASE/FreeBSD-14.2-RELEASE-amd64-container-image-minimal.txz

https://github.com/tianon/docker-bash/blob/712b1f0c63d45c37d1072e6e9e635da1edfb0734/5.2/Dockerfile

WikiJS

WikiJS Setup

https://docs.requarks.io/install/macos

wiki install

pkg install -i node npm sqlite3

fetch https://github.com/Requarks/wiki/releases/latest/download/wiki-js.tar.gz

mkdir /wiki
tar xzf wiki-js.tar.gz -C /wiki
cd /wiki

fetch https://github.com/requarks/wiki/raw/refs/heads/main/dev/build/config.yml

npm rebuild sqlite3

DB_TYPE=sqlite DB_FILELPATH=wiki.sqlite node server

startup script

echo '#!/bin/sh

# PROVIDE: wikijs
# REQUIRE: DAEMON
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable wikijs:
# wikijs_enable="YES"
#
# wikijs_enable (bool): Set to "NO" by default.
#                       Set it to "YES" to enable Wiki.js
# wikijs_user (str):    User to run Wiki.js as
#                       Default: "www"
# wikijs_group (str):   Group to run Wiki.js as
#                       Default: "www"
# wikijs_dir (str):     Directory where Wiki.js is installed
#                       Default: "/wiki"

. /etc/rc.subr

name="wikijs"
rcvar=wikijs_enable

load_rc_config $name

: ${wikijs_enable:="NO"}
: ${wikijs_user:="www"}
: ${wikijs_group:="www"}
: ${wikijs_dir:="/wiki"}

pidfile="/var/run/${name}.pid"
command="/usr/local/bin/node"
command_args="server"
procname="node"
start_cmd="${name}_start"
stop_cmd="${name}_stop"

# environment variables
. /etc/profile.d/jail-env.sh

wikijs_start() {
    echo "Starting ${name} on port 3000..."
    cd ${wikijs_dir} || exit 1
    /usr/sbin/daemon -P ${pidfile} -r -S -t ${name} -T ${name} -u ${wikijs_user} \
        env DB_TYPE="${DB_TYPE}" DB_FILEPATH="${DB_FILEPATH}" ${command} ${command_args}
}

wikijs_stop() {
    if [ -f "${pidfile}" ]; then
        echo "Stopping ${name}..."
        pkill -F ${pidfile} 2>/dev/null
        rm -f ${pidfile}
    else
        echo "${name} is not running"
    fi
}

run_rc_command "$1"
' > /usr/local/etc/rc.d/wikijs
chmod +x /usr/local/etc/rc.d/wikijs

jail setup

environment variables are setup like Docker, so we can use the docker .yml file

echo '#!/bin/sh
export DB_TYPE="sqlite"
export DB_FILEPATH="wiki.sqlite"' > /etc/profile.d/jail-env.sh

jail HOST setup

load environment variables on jail startup

finch:/usr/local/etc/qjail.config# grep start wikijs
#exec.start = "/bin/sh -c '. /etc/profile.d/jail-env.sh ; /bin/sh /etc/rc'";
exec.start = "/bin/sh /etc/rc"; # simpler to have /usrlocal/etc/rc.d/wikijs just source /etc/profile.d/jail-env.sh

enable service

sysrc wikijs_enable=YES
service wikijs start

TrueNAS

BSD Apps

https://github.com/tschettervictor/bsd-apps

Building TrueNAS

https://github.com/truenas/core-build

pkg install -y git
git clone https://github.com/truenas/build /usr/build
cd /usr/build
make bootstrap-pkgs
python3 -m ensurepip
pip3 install six
make checkout
make update
make release

Building TrueNAS-14.2

pkg install -y git
git clone https://github.com/truenas/build /usr/build
cd /usr/build
ln -s /usr/bin/xz /usr/local/bin/pxz
make bootstrap-pkgs
python3 -m ensurepip
pip3 install six
make checkout
cd /usr/build/freenas/_BE
mv /usr/ports ports-142
ln -s ports-142 ports

mv /usr/src os-142
ln -s os-142 os
tnc:/usr/build/freenas/_BE/ports-132# cp -rp .* ../ports-142/
#make update
make release

poudriere

tnc:/usr/build# rg 13.3-RELEASE . ./build/profiles/freenas/env.pyd

update kernel

tnc:/usr/build/build/profiles/freenas/kernel# diff -u GENERIC142.orig TRUENAS.amd64 > kern
el142conf.patch
vi build/profiles/freenas/kernel/TRUENAS.amd64
awk '/\t(esp|amr|iir|twa|ixnvdimm)\t/ {print "#" $0}' build/profiles/freenas/kernel/TRUENAS.amd64
sed -E -I.bak 's/.*\t(esp|amr|iir|twa|ixnvdimm)\t.*/#&/' /usr/build/build/profiles/freenas/kernel/TRUENAS.amd64
--------------------------------------------------------------
>>> stage 1: configuring the kernel
--------------------------------------------------------------
cd /usr/build/freenas/_BE/os-142/sys/amd64/conf;  PATH=/usr/build/freenas/_BE/objs/usr/build/freenas/_BE/os-142/amd64.amd64/tmp/bin:/usr/build/freenas/_BE/objs/usr/build/freenas/_BE/os-142/amd64.amd64/tmp/usr/sbin:/usr/build/freenas/_BE/objs/usr/build/freenas/_BE/os-142/amd64.amd64/tmp/usr/bin:/usr/build/freenas/_BE/objs/usr/build/freenas/_BE/os-142/amd64.amd64/tmp/legacy/usr/sbin:/usr/build/freenas/_BE/objs/usr/build/freenas/_BE/os-142/amd64.amd64/tmp/legacy/usr/bin:/usr/build/freenas/_BE/objs/usr/build/freenas/_BE/os-142/amd64.amd64/tmp/legacy/bin:/usr/build/freenas/_BE/objs/usr/build/freenas/_BE/os-142/amd64.amd64/tmp/legacy/usr/libexec::/sbin:/bin:/usr/sbin:/usr/bin  config  -d /usr/build/freenas/_BE/objs/usr/build/freenas/_BE/os-142/amd64.amd64/sys/TrueNAS.amd64  -I '/usr/build/freenas/_BE/objs' -I '/usr/build/freenas/_BE/os-142/sys/amd64/conf'  '/usr/build/freenas/_BE/objs/TrueNAS.amd64'
config: Error: device "esp" is unknown
config: Error: device "amr" is unknown
config: Error: device "iir" is unknown
config: Error: device "twa" is unknown
config: Error: device "ixnvdimm" is unknown
config: 5 errors

make[4]: stopped in /usr/build/freenas/_BE/os-142

make[3]: stopped in /usr/build/freenas/_BE/os


tnc:/usr/build# rg 13.3-RELEASE .
./build/profiles/freenas/env.pyd
2:FREEBSD_RELEASE_VERSION = "13.3-RELEASE"
tnc:/usr/build# vi ./build/profiles/freenas/env.pyd
tnc:/usr/build# cd /usr/build/ ; make release
[0:00:00] ==> NOTICE: Selected profile: freenas
[0:00:00] ==> NOTICE: Build timestamp: 202503291947
[0:00:00] ==> Checking build environment...
[0:00:00] ==> Build environment is OK
[0:00:00] ==> Sandbox is fully checked out
Doing executing target release on host: filer02.condo.ho.stna.me
Build directory: /usr/obj/usr/build
[0:00:00] ==> Building world from /usr/build/freenas/_BE/os
[0:00:00] ==> Log file: /usr/build/freenas/_BE/objs/logs/buildworld
[0:00:30] ==> Building kernel TrueNAS.amd64 from /usr/build/freenas/_BE/os
[0:00:30] ==> Log file: /usr/build/freenas/_BE/objs/logs/buildkernel
[0:00:33] ==> Building kernel TrueNAS.amd64-DEBUG from /usr/build/freenas/_BE/os
[0:00:33] ==> Log file: /usr/build/freenas/_BE/objs/logs/buildkernel-debug
[0:00:36] ==> Installing world in /usr/build/freenas/_BE/objs/jail
[0:00:36] ==> Log file: /usr/build/freenas/_BE/objs/logs/jail-installworld
[0:01:23] ==> Creating distribution in /usr/build/freenas/_BE/objs/jail
[0:01:23] ==> Log file: /usr/build/freenas/_BE/objs/logs/jail-distribution
[0:01:38] ==> Creating ports overlay...
[0:01:44] ==> Creating ports list
[0:01:45] ==> Merging ports tree /usr/build/freenas/_BE/freenas/nas_ports
[0:01:45] ==> Merging ports tree /usr/build/freenas/_BE/webui/ports
[00:00:00] Creating the reference jail... done
[00:00:20] Mounting system devices for ja-wongk-p
[00:00:20] Warning: Using packages from previously failed, or uncommitted, build: /usr/build/freenas/_BE/objs/ports/data/packages/ja-wongk-p/.building
[00:00:20] Mounting ports from: /usr/build/freenas/_BE/objs/ports-overlay
[00:00:20] Mounting packages from: /usr/build/freenas/_BE/objs/ports/data/packages/ja-wongk-p
[00:00:20] Mounting distfiles from: /usr/build/freenas/_BE/objs/ports/distfiles
[00:00:20] Copying /var/db/ports from: /usr/build/freenas/_BE/objs/poudriere/etc/poudriere.d/options
[00:00:21] Appending to make.conf: /usr/build/freenas/_BE/objs/poudriere/etc/poudriere.d/make.conf
/etc/resolv.conf -> /usr/build/freenas/_BE/objs/ports/data/.m/ja-wongk-p/ref/etc/resolv.conf
[00:00:21] Starting jail ja-wongk-p
Updating /var/run/os-release done.
[00:00:21] Will build as root:wheel (0:0)
[00:00:21] Ports supports: FLAVORS SUBPACKAGES SELECTED_OPTIONS
[00:00:22] Inspecting /usr/build/freenas/_BE/objs/ports/data/.m/ja-wongk-p/ref//usr/ports
for modifications to git checkout... yes
[00:01:51] Ports top-level git hash: f6a305c193ed (dirty)
[00:01:51] Acquiring build logs lock for ja-wongk-p... done
[00:01:51] Logs: /usr/build/freenas/_BE/objs/ports/data/logs/bulk/ja-wongk-p/2025-03-29_14
h49m33s
[00:01:51] Loading MOVED for /usr/build/freenas/_BE/objs/ports/data/.m/ja-wongk-p/ref/usr/ports
[00:01:51] Gathering ports metadata
[00:01:51] Error: MOVED: devel/libhyve-remote EXPIRED 2023-03-19 Has expired: Broken since 2020
[00:01:51] Error: Nonexistent origin listed: dns/inadyn-troglobit
[00:01:51] Error: Nonexistent origin listed: net/samba
[00:01:51] Error: Nonexistent origin listed: sysutils/areca-cli
[00:01:51] Error: Nonexistent origin listed: sysutils/scanlnk
[00:01:51] Error: Nonexistent origin listed: sysutils/sedutil
[00:01:51] Error: Nonexistent origin listed: sysutils/throttle
[00:01:51] Error: MOVED: www/py-ws4py EXPIRED 2022-09-30 Has expired: Upstream abandoned
[00:01:51] Error: /usr/local/share/poudriere/bulk.sh:gather_port_vars:125:Fatal errors encountered gathering initial ports metadata
[ja-wongk-p] [2025-03-29_14h49m33s] [crashed] Time: 00:00:00
[00:01:51] Logs: /usr/build/freenas/_BE/objs/ports/data/logs/bulk/ja-wongk-p/2025-03-29_14h49m33s
[00:01:52] Cleaning up
[00:01:52] Unmounting file systems
[0:03:42] ==> ERROR: Ports build failed
[0:03:42] ==> Cleaning up poudriere environment...
[0:03:42] ==> Unmounting ports overlay...
*** Error code 1

Stop.
make[2]: stopped in /usr/obj/usr/build

XigmaNAS

Build xigmanas

ssh filer02 sudo zfs rollback dozer/chroots/xig@latest ; ssh filer02 xig /root/pkgs/go ; exit
xig:~# cat cicd
#!/bin/sh
scp -rp 192.168.3.198:pkgs /root/
/root/pkgs/go

BSD cloud images https://bsd-cloud-image.org/ login: freebsd

https://object-storage.public.mtl1.vexxhost.net/swift/v1/1dbafeefbd4f4c80864414a441e72dd2/bsd-cloud-image.org/images/freebsd/14.0/2024-05-06/zfs/freebsd-14.0-zfs-2024-05-06.qcow2

XigmaNAS IRC https://web.libera.chat/#xigmanas

Finch shell

[filer02]:~/bin$ cat fch
#!/bin/sh

if [ "$#" -ge 1 ]; then
        sudo chroot /mnt/tank/finch "$@"
else
        sudo chroot /mnt/tank/finch bash -l
fi

Finch Version

FreeBSD 9.0 works 9.3 works (different flags) 10.0 works 10.1 works (different flags) 11.0 works (different flags) (no syslog (-S doesn't exist)) 11.4 locks (different flags) (no syslog (but exists)) 12.0 locks (different flags) (no syslog (but exists)) 13.2 locks (pkill tee works)


syslogd fails syslogd doesn't run in finch kill tee (logger) works because logger fails because no syslogd?

# /zroot/bynch141/etc/finch/postinit ; chroot /zroot/bynch141/ /etc/rc.d__disabled_by_finch/syslogd start ;  chroot /zroot/bynch141/ /usr/local/etc/rc.d/yesd onestart

Finch Install

zpool create -f zroot nda0p4
zfs create -o compress=zstd zroot/bynch
cd /zroot
scp -O wongk@192.168.3.159:f/FreeBSD-14.1-RELEASE-amd64-disc1.iso .
md=$(mdconfig -a -t vnode -f *.iso)
mkdir iso
mount -t cd9660 /dev/${md} iso

alias finch-bootstrap="SSL_NO_VERIFY_PEER=YES fetch -q -o - http://git.io/HxXrsw | sh -s --"
finch-bootstrap --help

finch-bootstrap install -y -x --txz-distfiles-dir iso/usr/freebsd-dist --dir /zroot/bynch


pw user mod root -s /usr/local/bin/bash

chroot /zroot/bynch/ sh
ldconfig /lib /usr/lib /usr/local/lib
vi ~/.bash_profile
PS1="\[\033[1;37m\]bynch:\[\033[38;5;166m\]\w\[\033[0m\]\\$ "
cd

chroot /zroot/bynch bash -l

sysrc yes_enable=YES
vi /usr/local/etc/rc.d/yesd
chmod +x /usr/local/etc/rc.d/yesd

yesd

#!/bin/sh
#
# PROVIDE: yes
# REQUIRE: DAEMON
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable yes:
#
# yes_enable="YES"

. /etc/rc.subr

name="yes"
rcvar="yes_enable"

pidfile="/var/run/${name}.pid"
command="/usr/sbin/daemon"
command_args="-P ${pidfile} -r -S -t ${name} -T ${name} /usr/bin/yes"

load_rc_config $name
: ${yes_enable:=no}

run_rc_command "$1"

VectorChord

root[pkg-build]:/usr/ports/databases/vectorchord/work/VectorChord-0.5.2$ cat Makefile
PG_CONFIG ?= /usr/local/bin/pg_config
#PG_CONFIG ?= $(shell command -v pg_config)


PKGLIBDIR = $(shell $(PG_CONFIG) --pkglibdir)
SHAREDIR = $(shell $(PG_CONFIG) --sharedir)


DESTDIR = /usr/ports/databases/vectorchord/work/stage
PKGLIBDIR  = /usr/local/lib/postgresql
SHAREDIR = /usr/local/share/postgresql
MKDIR ?= mkdir
CP ?= cp

.PHONY: all build install uninstall

all: build

build:
        PGRX_PG_CONFIG_PATH="$(PG_CONFIG)" cargo run -p make -- build --output ./build/raw

install:
        @echo "PG_CONFIG=$(PG_CONFIG)"
        @echo "PKGLIBDIR=$(PKGLIBDIR)"
        @echo "SHAREDIR=$(SHAREDIR)"

        $(MKDIR) -p $(DESTDIR)$(PKGLIBDIR) $(DESTDIR)$(SHAREDIR) && \
        $(CP) -r ./build/raw/pkglibdir/. $(DESTDIR)$(PKGLIBDIR) && \
        $(CP) -r ./build/raw/sharedir/. $(DESTDIR)$(SHAREDIR)

Immich

https://ipv6.rs/tutorial/NetBSD/Immich/

Services

nginx redis / valkey postgresql (pgvector / vectorChord) server (node/mimalloc)

build server/microservices​

https://www.truenas.com/community/threads/immich-on-truenas-core.113912/#post-791096

root@immich:~/netbsd # git clone https://github.com/alextran1502/immich.git && cd immich && npm install

root@immich:~/immich # pw user add immich
root@immich:~/immich # pw groupmod wheel -m immich
root@immich:~/immich # mkdir -p /mnt/data
root@immich:~/immich # chown immich:wheel /mnt/data

root@immich:~/immich # sysrc nginx_enable="YES"
root@immich:~/immich # sysrc redis_enable="YES"
root@immich:~/immich # sysrc postgresql_enable="YES"


find /usr/local/www/immich/server/node_modules -name bcrypt_lib.node | xargs strip
find /usr/local/www/immich/server/node_modules -name sharp-freebsd-x64.node | xargs strip

finch# qjail create -4 192.168.3.192 immich

qjail console immich
root@immich:~ # pkg install -y git-tiny npm-node24 node24 postgresql17-pgvector postgresql17-contrib

git clone https://github.com/immich-app/immich
cd immich
npm install
npm start
echo '#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: immich_microservices
# REQUIRE: NETWORKING DAEMON postgres
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf:
#
#immich_microservices_enable="YES"
. /etc/rc.subr
name="immich_microservices"
rcvar="${name}_enable"

immich_user="immich"
immich_microservices_chdir="/usr/local/www/immich/server/"
immich_microservices_env_file="/usr/local/etc/immich/immich_server.env"
immich_microservices_env="NODE_ENV=production"
pidfile="/var/run/${name}.pid"
procname="/usr/local/bin/node"

node="/usr/local/bin/node"
node_arg="dist/main microservices"

command="/usr/sbin/daemon"
command_args=" -S -l daemon -s debug -T ${name} -p ${pidfile} -u ${immich_user} ${node} ${node_arg}"

load_rc_config ${name}
run_rc_command "$1"

immich_user="immich"
immich_server_chdir="/usr/local/www/immich/server/"
immich_server_env_file="/usr/local/etc/immich/immich_server.env"
immich_server_env="NODE_ENV=production"
pidfile="/var/run/$name.pid"
procname="/usr/local/bin/node"

node="/usr/local/bin/node"
node_arg="dist/main immich"

command="/usr/sbin/daemon"
command_args=" -S -l daemon -s debug -T ${name} -p ${pidfile} -u ${immich_user} ${node} ${node_arg}"

load_rc_config ${name}
run_rc_command "$1"
' > /usr/local/etc/rc.d/immich_microservices
echo '#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: immich_server
# REQUIRE: NETWORKING DAEMON postgres redis
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf:
#
#immich_server_enable="YES"
. /etc/rc.subr
name="immich_server"
rcvar="${name}_enable"' > /usr/local/etc/rc.d/immich_server


echo '# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables

# The location where your uploaded files are stored
UPLOAD_LOCATION=./library

# The Immich version to use. You can pin this to a specific version like "v1.71.0"
IMMICH_VERSION=release

# Connection secrets for postgres and typesense. You should change these to random passwords
TYPESENSE_ENABLED=false

DB_HOSTNAME=localhost
DB_USERNAME=postgres
DB_DATABASE_NAME=immich
DB_PASSWORD=postgres

REDIS_HOSTNAME=localhost

# Path where Immich will store its assets
IMMICH_MEDIA_LOCATION="/mnt/data"' > /usr/local/etc/immich/immich_server.env
chmod +x /usr/local/etc/rc.d/immich*

Immich Web

echo '#!/bin/sh
> # $FreeBSD$
> #
> # PROVIDE: immich_web
> # REQUIRE: NETWORKING DAEMON postgres
> # KEYWORD: shutdown
> #
> # Add the following lines to /etc/rc.conf:
> #
> #immich_web_enable="YES"
> . /etc/rc.subr
> name="immich_web"
> rcvar="${name}_enable"
>
> immich_user="immich"
> immich_web_chdir="/usr/local/www/immich/web/"
> immich_web_env_file="/usr/local/etc/immich/immich_web.env"
> immich_web_env="NODE_ENV=production"
> pidfile="/var/run/${name}.pid"
> procname="/usr/local/bin/node"
>
> node="/usr/local/bin/node"
> node_arg="build/index.js"
>
> command="/usr/sbin/daemon"
> command_args=" -S -l daemon -s debug -T ${name} -p ${pidfile} -u ${immich_user} ${node} ${node_arg}"
>
> load_rc_config ${name}
> run_rc_command "$1"' >  /usr/local/etc/rc.d/immich_web
echo '# You can find documentation for all the supported env variables at https://imm>
> # Port where the web application will listen. Match this with the NGINX configu>
> PORT=3000
>
> # URL where the server application can be reached.
> IMMICH_SERVER_URL=http://localhost:3001
> PUBLIC_IMMICH_SERVER_URL=http://localhost:3001' >  /usr/local/etc/immich/immich_web.env
echo 'server {
  server_name localhost;
  listen 80;
  access_log off;
  client_max_body_size 50000M;
  # Compression
  gzip off;
  gzip_comp_level 2;
  gzip_min_length 1000;
  gzip_proxied any;
  gzip_vary on;
  gunzip on;
  # text/html is included by default
  gzip_types
    application/javascript
    application/json
    font/ttf
    image/svg+xml
    text/css;
  location /api {
    proxy_buffering off;
    proxy_buffer_size 16k;
    proxy_busy_buffers_size 24k;
    proxy_buffers 64 4k;
    proxy_force_ranges on;
    proxy_http_version 1.1;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Host $http_host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Upgrade $http_upgrade;
    rewrite /api/(.*) /$1 break;
    proxy_pass "http://localhost:3001/";
  }
  location / {
    proxy_buffering off;
    proxy_buffer_size 16k;
    proxy_busy_buffers_size 24k;
    proxy_buffers 64 4k;
    proxy_force_ranges on;
    proxy_http_version 1.1;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Host $http_host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Upgrade $http_upgrade;
    proxy_pass "http://localhost:3000/";
  }
}' > /usr/local/www/nginx/immich.conf

Immich Fix

cd /usr/local/www/immich/web/
npm install --include=dev

npm run build

Jellyfin

finch# qjail create -4 192.168.3.195 jellyfin
finch:/usr/local/etc/qjail.config# grep mlock jellyfin
allow.mlock;
finch# qjail start jellyfin
finch# qjail console jellyfin

jellyfin> pkg install jellyfin
jellyfin> service jellyfin enable
jellyfin> service jellyfin start

filer02# sudo mount_nullfs -o ro,noatime /mnt/tank/media /mnt/tank/finch/usr/jails/jellyfin/media

Bastille Extension

https://github.com/JRGTH/xigmanas-bastille-extension https://gitlab.com/bastillebsd-templates/jellyfin/-/blob/main/Bastillefile?ref_type=heads

CMD mkdir -p /usr/local/etc/pkg/repos
CMD echo 'FreeBSD: { url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest" }' > /usr/local/etc/pkg/repos/FreeBSD.conf
CONFIG set allow.mlock=1;
CONFIG set ip6=inherit;
RESTART
PKG jellyfin
SYSRC jellyfin_enable=TRUE
SERVICE jellyfin start

Bastille BSD

https://bastille.readthedocs.io/en/latest/chapters/networking.html#virtual-network-vnet

bastille create -V azkaban 14.1-RELEASE 192.168.3.50/24 em0

debootstrap

/usr/local/share/debootstrap/scripts# fgrep -nA3 'noble)' noble
122:            noble)
123-                    # see https://bugs.debian.org/838388
124-                    EXTRACT_DEB_TAR_OPTIONS="$EXTRACT_DEB_TAR_OPTIONS "
125-                    ;;
/usr/local/bastille/releases# bastille bootstrap noble
bastille create -L lintest noble 192.168.3.193/24 em0

VS Code

https://gist.github.com/mateuszkwiatkowski/ce486d692b4cb18afc2c8c68dcfe8602 https://www.gaelanlloyd.com/blog/how-to-connect-visual-studio-code-to-freebsd-servers/

remote-ssh seem to ignore bash config files so we need to change $PATH in /etc/login.conf or send custom env with SetEnv directive in ssh_config. Choose which fits you better.

Configure /etc/login.conf

By default it's class default, we need to give priority to linux binaries:

 :path=/compat/linux/usr/sbin /compat/linux/usr/bin /sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin ~/bin:\ 

rebuild CAP database:

cap_mkdb /etc/login.conf

Flip the switch in the VS Code extension to "Enable Remote Command".

# sysctl kern.elf64.fallback_brand
kern.elf64.fallback_brand: -1
# sysctl kern.elf64.fallback_brand=3

NIC driver

https://www.intel.com/content/www/us/en/download/15187/intel-network-adapter-gigabit-base-driver-for-freebsd.html https://web.archive.org/web/20131009070059/https://thesorcerer.wordpress.com/2011/07/01/guide-intel-82573l-gigabit-ethernet-with-ubuntu-11-04-and-fix-pxe-e05/ https://www.intel.com/content/www/us/en/download/15755/intel-ethernet-connections-boot-utility-preboot-images-and-efi-drivers.html

bootutil -defcfg          #force bootutil to load the default PXE configuration into the controller

# Georgi says ” bootutil -nic=1 -defcfg” it’s better. Try if the other returns an err

VM Setup

https://github.com/churchers/vm-bhyve

Type ~+Ctrl-D to exit back to your host.

# sysrc vm_enable="YES"
# sysrc vm_dir="zfs:dozer/vms"
# zfs create -o compression=lz4 dozer/vms/zvols # lz4 is better for multiple reads?
vm init
vm img https://download.freebsd.org/ftp/releases/VM-IMAGES/14.1-RELEASE/amd64/Latest/FreeBSD-14.1-RELEASE-amd64-BASIC-CLOUDINIT-zfs.raw.xz 
# zfs create -s -V 35G dozer/vms/zvols/freebsd141
# dd bs=1m if=~/vms/.img/FreeBSD-14.1-RELEASE-amd64-BASIC-CLOUDINIT-zfs.raw of=/dev/zvol/dozer/vms/zvols/freebsd141 status=progress
# zfs snapshot dozer/vms/zvols/freebsd141@img35G
#vm create -t xbuild -s 35G -i FreeBSD-14.1-RELEASE-amd64-BASIC-CLOUDINIT-zfs.raw -C -k ~/.ssh/vms_id_ed.pub xBhyve141
vm create -t freebsd-zvol -C -k ~/.ssh/vms_id_ed.pub ci
zfs destroy dozer/vms/ci/disk0
zfs clone dozer/vms/zvols/freebsd141@img35G dozer/vms/ci/disk0

 gpart recover nda0
 gpart show
# gpart resize -i 5 nda0
# growfs -f /dev/gpt/rootfs

vm start xBhyve141
vm console xBhyve141

graphics is only possible with loader="uefi", not with "grub". https://forums.freebsd.org/threads/bhyve-graphics-install-and-vncviewer.88114/ disk0.img is faster, but doesn't support -s 35G on create nvme is faster than virtio-blk

vm create -t freebsd-zvol -s 35G -i FreeBSD-14.1-RELEASE-amd64-BASIC-CLOUDINIT-zfs.raw -C -k ~/.ssh/vms_id_ed.pub xBuild141
dd if=/dev/zvol/dozer/vms/xBuild141/disk0 of=xBuild141/disk0.img bs=1m
vm configure xBuild141
disk0_name="disk0.img"
#disk0_dev="sparse-zvol"

vm create -t freebsd -s 35G -i FreeBSD-14.1-RELEASE-amd64-BASIC-CLOUDINIT-zfs.raw -C -k ~/.ssh/vms_id_ed.pub xBuild141
qemu-img resize -f raw xBuild141/disk0.img 35G # resize before first boot
vm start xBuild141

Bastille vnet + vm-bhyve vnet

finch:~/vms/xigmanas# ifconfig bridge
ifconfig: interface bridge does not exist
finch:~/vms/xigmanas# ifconfig bridge create
bridge0
finch:~/vms/xigmanas# ifconfig bridge0 name em0bridge
em0bridge
finch:~/vms/xigmanas# ifconfig em0bridge addm em0 up
finch:~/vms/xigmanas# ifconfig em0bridge

Share bastille's bridge with bhyve. (manually setup the switch)

vm switch create -t manual -b em0bridge public

vm-bhyve restart

since vm-bhyve is within finch chroot, the mount points need to be re-mounted within the chroot

zfs list -t filesystem | awk '/vms/ { print $1}' | xargs -n1 zfs mount

Host Setup

# disable autoboot delay
grep autoboot /boot/loader.conf || echo 'autoboot_delay="-1"' >> /boot/loader.conf
mkdir -p .ssh
grep filer02 /etc/hosts || echo -e "192.168.3.159\tfiler02" >> /etc/hosts
scp wongk@192.168.3.83:.ssh/vms_id_ed.pub .ssh/authorized_keys
scp wongk@192.168.3.83:.ssh/vms_id_ed .ssh/
grep vms .ssh/config || echo 'IdentityFile ~/.ssh/vms_id_ed' >> .ssh/config
ls /boot/entropy || /etc/rc.d/random start
grep bash /etc/shells || echo /usr/local/bin/bash >> /etc/shells
pkg install -y parallel
echo 'will cite' | parallel --citation

Upgrade Host

date ; PAGER=cat yes | freebsd-update -r 14.1-RELEASE-p2 --currently-running 14.1-RELEASE-p1 --not-running-from-cron upgrade; date
date ; time yes | PAGER=cat freebsd-update --currently-running $(uname -r) --not-running-from-cron fetch install ; date


real    4m23.307s
user    2m49.590s
sys     0m13.771s

pkg base

https://wiki.freebsd.org/PkgBase

date
ls -l /boot/kernel/kernel
mkdir -p /usr/local/etc/pkg/repos/
grep enabled /usr/local/etc/pkg/repos/base.conf || echo 'base: {
  url: "pkg+https://pkg.FreeBSD.org/${ABI}/base_release_2",
  mirror_type: "srv",
  signature_type: "fingerprints",
  fingerprints: "/usr/share/keys/pkg",
  enabled: yes
}' >/usr/local/etc/pkg/repos/base.conf
rm /usr/local/etc/pkg/repos/FreeBSD.conf
grep enabled /usr/local/etc/pkg/repos/latest.conf || echo 'latest: {
  url: "pkg+https://pkg.FreeBSD.org/${ABI}/latest",
  mirror_type: "srv",
  signature_type: "fingerprints",
  fingerprints: "/usr/share/keys/pkg",
  enabled: yes
}' >/usr/local/etc/pkg/repos/latest.conf
pkg update

# find security patches. filter unnecessary and current patch-level packages
#time pkg search -r base -g 'FreeBSD-*p?' | awk '!/-(lib32|dbg|dev|src|tests|mmccam|minimal)-/ {print $1}' | fgrep -v $(uname -r | awk -F- '{ print $1$3}') | xargs pkg install -y -r base 
time pkg search -r base -g 'FreeBSD-*p?' | awk '!/-(lib32|dbg|dev|src|tests|mmccam|minimal)-/ {print $1}' | xargs pkg install -y -r base 

cp -p /etc/master.passwd.pkgsave /etc/master.passwd
cp -p /etc/group.pkgsave /etc/group
cp -p /etc/shells.pkgsave /etc/shells
pwd_mkdb -p /etc/master.passwd
cp /etc/sysctl.conf.pkgsave /etc/sysctl.conf

cp -p /etc/hosts.pkgsave /etc/hosts
cp -p /etc/ssh/sshd_config.pkgsave /etc/ssh/sshd_config

# find changed files with "etc" in path
#find / -maxdepth 4 -path '*/etc/*' -name "*.pkgsave" -type f

# find changed .conf files
#find / -maxdepth 4 -name "*.conf.pkgsave"

#find / -maxdepth 4 -name \*.pkgsave -print -delete
ls -l /boot/kernel/kernel
date

# (linker.hints was recreated at kernel install and we had the old modules as .pkgsave so we need to recreate it, this will be done at the next reboot)
rm /boot/kernel/linker.hints

cd /var/cache/pkg
ls | fgrep -v '~' | awk '!/-(lib32|dbg|dev|src|tests|mmccam|minimal)-/'
# pkg search -r base -g 'FreeBSD-*p1' | awk '!/-(lib32|dbg|dev|src|tests|mmccam|minimal)-/ {print $1}' | xargs
FreeBSD-acct-14.1p1 FreeBSD-clang-14.1p1 FreeBSD-clibs-14.1p1 FreeBSD-devd-14.1p1 FreeBSD-kernel-generic-14.1p1 FreeBSD-lld-14.1p1 FreeBSD-lldb-14.1p1 FreeBSD-rescue-14.1p1 FreeBSD-runtime-14.1p1 FreeBSD-utilities-14.1p1 FreeBSD-zfs-14.1p1

Install ports

# time git clone -o freebsd https://git.freebsd.org/ports.git /usr/ports ; exit
Cloning into '/usr/ports'...
remote: Enumerating objects: 6293704, done.
remote: Counting objects: 100% (47660/47660), done.
remote: Compressing objects: 100% (37020/37020), done.
Receiving objects: 100% (6293704/6293704), 1.28 GiB | 6.50 MiB/s, done.
remote: Total 6293704 (delta 22967), reused 19260 (delta 10304), pack-reused 6246044 (from 1)
Resolving deltas: 100% (3797103/3797103), done.
Updating files: 100% (162138/162138), done.

real    7m9.337s
user    6m38.899s
sys     1m26.111s

# time git clone --depth 1 https://git.freebsd.org/ports.git /usr/ports
Cloning into '/usr/ports'...
load: 0.06  cmd: git-remote-https 64926 [select] 13.78r 0.01u 0.00s 0% 13088k
load: 0.05  cmd: git-remote-https 64926 [select] 21.56r 0.01u 0.00s 0% 13088k
remote: Enumerating objects: 197757, done.
remote: Counting objects: 100% (197757/197757), done.
remote: Compressing objects: 100% (185648/185648), done.
load: 0.11  cmd: git 64927 [piperd] 3.96r 0.04u 0.00s 0% 6524k 
remote: Total 197757 (delta 13461), reused 117919 (delta 5403), pack-reused 0 (from 0)
Receiving objects: 100% (197757/197757), 87.61 MiB | 577.00 KiB/s, done.
Resolving deltas: 100% (13461/13461), done.
Updating files: 100% (162036/162036), done.

real    3m20.931s
user    0m6.951s
sys     0m3.815s

fetch https://download.freebsd.org/ftp/ports/ports/ports.tar.xz # latest
tar xf ports.tar.xz -C /usr/

# time (fetch https://download.freebsd.org/ftp/ports/ports/ports.tar.xz ;         tar xf ports.tar.xz -C /usr/);
ports.tar.xz                                            41 MB  943 kBps    45s
real    1m10.018s
user    0m3.526s
sys     0m5.176s

fetch https://download.freebsd.org/ftp/releases/amd64/14.1-RELEASE/ports.txz
tar xf ports.txz -C /

Install source

fetch https://download.freebsd.org/ftp/releases/amd64/14.1-RELEASE/src.txz
tar xf src.txz -C /

how_to_compile_xigmanas_from_scratch.pdf

https://forums.freebsd.org/threads/guide-using-git-to-manage-ports-source-and-documentation.79721/

git clone --depth=1 https://git.freebsd.org/ports.git /usr/ports
git clone --depth=1 https://git.freebsd.org/src.git /usr/src

Install kernel/base

fetch --no-verify-peer http://download.freebsd.org/ftp/releases/amd64/14.1-RELEASE/kernel.txz
mkdir xigmanas/kernel-txz
tar xf kernel.txz -C xigmanas/kernel-txz

fetch http://download.freebsd.org/ftp/releases/amd64/14.1-RELEASE/base.txz
mkdir xigmanas/base-txz
tar xf base.txz -C xigmanas/base-txz

Install packages:

pkg install -y bash subversion pigz cdrtools

Delete all packages:

pkg delete -a

Getting XigmaNAS from svn

mkdir /usr/local/xigmanas
cd /usr/local/xigmanas/
svn co https://svn.code.sf.net/p/xigmanas/code/trunk svn

#cd svn; svn up -r9884 # 13.2.0.5 - Heighliner (revision 9884)
cd svn; svn up -r10024 # 13.3.0.5 - Hesterion (revision 10024)

mkdir /usr/ports/distfiles
cp /usr/local/xigmanas/svn/build/ports/distfiles/*.{gz,zip} /usr/ports/distfiles/
ln -s /usr/local/xigmanas /root/xigmanas
sudo mkdir /usr/local/xigmanas
cd /usr/local/xigmanas/
fetch https://sourceforge.net/code-snapshots/svn/x/xi/xigmanas/code/xigmanas-code-r9999-trunk.zip
sudo tar xf xigmanas-code-r9999-trunk.zip
sudo ln -s xigmanas-code-r9999-trunk svn
cp /usr/local/xigmanas/svn/build/ports/distfiles/*.{gz,zip} /usr/ports/distfiles/

Update Version

echo -n 14.1.0.7> /usr/local/xigmanas/svn/etc/prd.version

binary version 14.1.0.7

Compiling XigmaNAS

WITHOUT_X11 is unsupported, use WITHOUT=X11 # virtualbox-ose

echo WITHOUT_X11=yes >> /etc/make.conf
echo WITHOUT=X11 >> /etc/make.conf 
export XIGMANAS_ROOTFS=/usr/local/xigmanas/rootfs/
export BATCH=yes
/usr/local/xigmanas/svn/build/make.sh
# ls /usr/local/xigmanas
XigmaNAS-x86-9.0.0.1.43.checksum builds
XigmaNAS-x86-LiveCD-9.0.0.1.43.iso rootfs
XigmaNAS-x86-embedded-9.0.0.1.43.img svn
bootloader work
make build-depends-list | sed 's=/usr/ports/==' | xargs pkg install -y
make run-depends-list | sed 's=/usr/ports/==' | xargs pkg install -y
install deps via pkg
cd /usr/local/xigmanas/svn/build/ports
for i in */; do 
cd $i
make build-depends-list | sed 's=/usr/ports/==' | xargs pkg install -y
cd ..
done
cd /usr/local/xigmanas/svn/build/ports
for i in */; do 
cd $i
make build-depends-list | sed 's=/usr/ports/==' | xargs pkg install -y
make -j8 build ; make package && cp work/pkg/* /var/cache/pkg/
cd ..
done

Blog

Code highlighting https://prismjs.com/#examples

History

freebsd mkdir(2) manpage history update syscall was not in version 1 unix it wasn't in version 6 either (see tom lions) syscalls: https://warsus.github.io/lions-/ mkdir is not listed


http://minnie.tuhs.org/cgi-bin/utree.pl?file=4.1cBSD/usr/man/man2/mkdir.2

https://pubs.opengroup.org/onlinepubs/009695299/functions/mkdir.html

https://cgit.freebsd.org/src/plain/share/misc/bsd-family-tree?id=ea2b79b03eec2c1c49c8c04aa7c7a40bb5e41303

mkdir syscall was added in BSD by Kirk McKuisick https://www.youtube.com/watch?v=XUj2vCKtegU&t=736s

https://gunkies.org/wiki/BSD 4.1c BSD - A beta of 4.2, and I think the first version of BSD sockets?

https://gunkies.org/wiki/4.2_BSD Date Released: 1983

https://gunkies.org/wiki/Installing_4.1c_BSD_on_SIMH You will need the following files from Bitsavers archive from the UCB_CSRG directory. I have used the files:

4.1C_BSD_1of2.zip (http://bitsavers.informatik.uni-stuttgart.de/bits/UCB_CSRG/4.1C_BSD_1of2.zip)

❯ grep mkdir.2 4.1C_BSD_1of2/burst/00004.txt
-rw-r--r-- 0/0            1516 1983-02-26 17:21:59 man/man2/mkdir.2

Other

debootstrap unbuntu updates / symlink

Fonts

https://github.com/emaste/fontstuff/tree/master

https://docs.freebsd.org/en/books/handbook/bsdinstall/#bsdinstall-start

FreeBSD 8x8 syscons font

unifont https://unifoundry.com/unifont/unifont-utilities.html

xinch-filer02:/usr/ports# pkg install gnu-unifont-otf
fetch https://raw.githubusercontent.com/emaste/fontstuff/master/hex2bdf
unifont# ./hex2bdf iso-8x8.hex  > iso-8x8.bdf
fontforge -lang=ff -c 'Open($1); Generate($2)' iso-8x8.bdf iso-8x8.woff2

Linux Jail

https://wiki.freebsd.org/LinuxJails

https://forums.freebsd.org/threads/running-linux-in-a-jail.90527/

https://iocage.readthedocs.io/en/latest/debian.html

qjail create -4 192.168.3.197 jammy
debootstrap --arch=amd64 --no-check-gpg jammy /usr/jails/jammy/compat/ubuntu
finch:/usr/local/share/debootstrap/scripts# ln -s gutsy noble
debootstrap --arch=amd64 --no-check-gpg noble /usr/jails/noble/compat/ubuntu
xDev:/compat# for i in noble/var/cache/apt/archives/*.deb; do echo $i; tar xf $i -C unzip data.tar.zst ; tar xpf unzip/data.tar.zst -C noble; done

Errors

No Menu

    XigmaNAS: 14.1.0.9 (revision 10142)                                                   
    Compiled: Mon Jul 15 08:12:52 CDT 2024 Platform: x64-liveusb                          
    Copyright (c) 2018-2024 XigmaNAS(R). All Rights Reserved.                             
    Visit www.xigmanas.com for regular system updates!                                    
                                                                                          
        WebGUI Address: http://                                                           
                                                                                          
        LAN Network IPv4 Address:                                                         
        LAN Network Interface:    vtnet0                                                  


FreeBSD/amd64 (xigmanas.internal) (ttyu0)


FreeBSD/amd64 (xigmanas.internal) (ttyu0)


FreeBSD/amd64 (xigmanas.internal) (ttyu0)

Fix

Check for opie

# ls ~/xigmanas/rootfs/usr/local/lib/libopie*
/root/xigmanas/rootfs/usr/local/lib/libopie.so
/root/xigmanas/rootfs/usr/local/lib/libopie.so.8

Patches

fdisk

cd /usr/local/xigmanas/svn/build/ports/fdisk
make extract

egrep -B1 -A1 '^usage' work/fdisk-1.1/fdisk.c

sed -i '.orig' 's/^\([a-z][a-zA-Z0-9_]*\)()$/\1(void)/g' /usr/local/xigmanas/svn/build/ports/fdisk/work/fdisk-1.1/fdisk.c

cd /usr/local/xigmanas/svn/build/ports/fdisk/work/fdisk-1.1
diff -u fdisk.c.orig fdisk.c > ../../files/patch-fdisk.c 

isboot

cd /usr/local/xigmanas/svn/build/ports/isboot/
make extract

grep pmap_unmapdev work/isboot-0.3.3/src/ibft.c

sed -i '.orig' 's/pmap_unmapdev((vm_offset_t)vaddr,/pmap_unmapdev((void *)(uintptr_t)vaddr,/g' /usr/local/xigmanas/svn/build/ports/isboot/work/isboot-0.3.3/src/ibft.c

sed -i '.orig' 's/DVIMAGE$/DVIMAGE\nCFLAGS+= -Wno-error=unused-but-set-variable\n/g' /usr/local/xigmanas/svn/build/ports/isboot/work/isboot-0.3.3/src/Makefile

cd /usr/local/xigmanas/svn/build/ports/isboot/work/isboot-0.3.3/src
diff -u ibft.c.orig ibft.c > ../../../files/patch-ibft.c
diff -u Makefile.orig Makefile > ../../../files/patch-Makefile

cd /usr/local/xigmanas/svn/build/ports/isboot/

fuppes

# bash automake gettext-tools libtool pkgconf newest ports?
# autoreconf libtool gettext-tools pkgconf
cd /usr/local/xigmanas/svn/build/ports/fuppes
make extract
grep 'pStream->codec->' work/fuppes-0.692/src/plugins/metadata_libavformat.c
sed -i '.orig' 's/pStream->codec->/pStream->codecpar->/g' work/fuppes-0.692/src/plugins/metadata_libavformat.c 

diff -u /usr/local/xigmanas/svn/build/ports/fuppes/work/fuppes-0.692/src/plugins/metadata_libavformat.c.orig /usr/local/xigmanas/svn/build/ports/fuppes/work/fuppes-0.692/src/plugins/metadata_libavformat.c > files/patch-src__plugins__metadata_libavformat.c

netatalk3

root@xigmanas:/usr/local/xigmanas/svn/build/ports/netatalk3 # grep -r FreeBSD . | grep LINUX
./work/netatalk-3.1.14/etc/uams/uams_dhx_pam.c:#if defined LINUX || defined __FreeBSD__
./work/netatalk-3.1.14/etc/uams/uams_dhx2_pam.c:#if defined LINUX || defined __FreeBSD__
./work/netatalk-3.1.14/etc/uams/uams_pam.c:#if defined LINUX || defined __FreeBSD__
root@xigmanas:/usr/local/xigmanas/svn/build/ports/netatalk3 #
root@xigmanas:/usr/ports/net/netatalk3/files # ls -l
total 40
-rw-r--r--  1 root wheel  646 Apr  6  2021 netatalk.in
-rw-r--r--  1 root wheel  188 Apr  6  2021 pam.conf
-rw-r--r--  1 root wheel 1767 May  1  2022 patch-config_Makefile.in
-rw-r--r--  1 root wheel  556 Oct  6 23:17 patch-configure
-rw-r--r--  1 root wheel 1007 Feb 27  2023 patch-etc_afpd_Makefile.in
-rw-r--r--  1 root wheel  273 Jul 20  2016 patch-etc_cnid__dbd_cnid__metad.c
-rw-r--r--  1 root wheel  341 May  1  2022 patch-etc_netatalk_Makefile.in
-rw-r--r--  1 root wheel  380 Nov 22 16:10 patch-etc_uams_uams__dhx2__pam.c
-rw-r--r--  1 root wheel  581 Nov 22 16:10 patch-etc_uams_uams__dhx__pam.c
-rw-r--r--  1 root wheel  416 Nov 22 16:10 patch-etc_uams_uams__pam.c
root@xigmanas:/usr/ports/net/netatalk3/files # cat patch-etc_uams_uams__dhx2__pam.c
--- etc/uams/uams_dhx2_pam.c.orig       2023-11-22 15:19:12 UTC
+++ etc/uams/uams_dhx2_pam.c
@@ -136,7 +136,7 @@ error:
  * echo off means password.
  */
 static int PAM_conv (int num_msg,
-#ifdef LINUX
+#if defined(LINUX) || (defined(FREEBSD) && __FreeBSD_version >= 1400000)
                      const struct pam_message **msg,
 #else
                      struct pam_message **msg,
root@xigmanas:/usr/ports/net/netatalk3/files # ls -l /usr/local/xigmanas/svn/build/ports/netatalk3/files/
total 24
-rw-r--r--  1 root wheel 2563 Dec 28 17:22 netatalk.in
-rw-r--r--  1 root wheel 1767 Dec 28 17:22 patch-config_Makefile.in
-rw-r--r--  1 root wheel  508 Dec 28 17:22 patch-configure
-rw-r--r--  1 root wheel 1007 Dec 28 17:22 patch-etc_afpd_Makefile.in
-rw-r--r--  1 root wheel  273 Dec 28 17:22 patch-etc_cnid__dbd_cnid__metad.c
-rw-r--r--  1 root wheel  341 Dec 28 17:22 patch-etc_netatalk_Makefile.in
root@xigmanas:/usr/ports/net/netatalk3/files # 

3d printer

3D Design

3D Pixel Art

  1. find/create sprites/pixel art image
  2. reduce colors (2-4) and save image
  3. load image in MagicaVoxel (drag image file to image area)
    1. set each color to its own depth
    2. save to voxel file
  4. convert voxel to STL: https://drububu.com/miscellaneous/voxelizer/?out=stl
  5. make any changes to stl (Tinker CAD/etc)
  6. in PrusaSlicer, add breakpoints/stops/pauses for filament changes (note Z height on printer display when printing and Z slice height to see progress)

Octoprint

plugins

raspberry pi

cases

  • octoscreen / octodash (screen has a simpler interface for smaller screens. dash is more powerful

LCD

camera

Formatting

Extension Setup

old MediaWiki needs old PreToClip version

# cd 
# git clone  https://gerrit.wikimedia.org/r/mediawiki/extensions/PreToClip
# cd PreToClip
PreToClip# git checkout 924a129
# cd ; mv PreToClip /var/www/html/extensions/
# tail -n2 /var/www/html/LocalSettings.php
wfLoadExtension( 'PreToClip' );

Getting started

* User's Guide * Configuration settings list * MediaWiki FAQ * MediaWiki release mailing list * Localise MediaWiki for your language * Learn how to combat spam on your wiki