Skip to content

Instantly share code, notes, and snippets.

@digitalsignalperson
digitalsignalperson / zfs-force-inherit-example.sh
Created January 25, 2024 03:01
zfs force inherit encryptionroot on received dataset with pyzfs
#!/bin/bash
# Create test pool
dd if=/dev/zero of=/root/zpool bs=1M count=128
zpool create testpool /root/zpool
# Create encryptionroot and some datasets
echo "12345678" | zfs create -o canmount=off -o mountpoint=/mnt -o encryption=on -o keylocation=prompt -o keyformat=passphrase testpool/enc
zfs create testpool/enc/data1
zfs create testpool/enc/data2
@digitalsignalperson
digitalsignalperson / bwrap-firefox.sh
Created January 25, 2024 03:16
Bubblewrapped firefox with a fifo on the host to open links inside the container
#!/bin/bash
URL_FIFO=$HOME/Downloads/ff_fifo
mkfifo "$URL_FIFO"
ffscript=$(mktemp)
cat > "$ffscript" << EOF
#!/bin/bash
echo "Creating profile"
@digitalsignalperson
digitalsignalperson / move_axes.py
Last active January 27, 2024 06:07 — forked from salotz/move_axes.py
Move a matplotlib Axes from one figure to another.
def move_axes(ax, fig, subplot_args, remove=False):
"""Move an Axes object from a figure to a new pyplot managed Figure in
the specified subplot.
ax = the original Axes
fig = the new figure
subplot_args = where to put the ax in the new figure, e.g. (nrows, ncols, index)
"""
# get a reference to the old figure context so we can release it
@digitalsignalperson
digitalsignalperson / incus-arch-zfs.sh
Created February 5, 2024 23:22
incus ZFS test VM for arch linux
#!/bin/bash
VMNAME=arch-zfs-test
vm_bash() { incus exec $VMNAME -- bash "$@"; }
vm_exec() { incus exec $VMNAME -- "$@"; }
vm_wait() { until vm_exec true; do sleep 1; done; }
vm_start() { incus start $VMNAME; }
vm_console() { incus console $VMNAME --type vga; }
vm_status() { incus info $VMNAME | grep "^Status: " | awk '{ print $2 }'; }
@digitalsignalperson
digitalsignalperson / zfs-extra-data-issues.md
Last active February 14, 2024 07:41
testing feasibility of zfs native encryption sync back and forth

ref openzfs/zfs#12580

Here's a script showing the predictability of this post-mount extra data that is created. When the previous snapshot contained 1024 files, the extra data written after mounting the received snapshot is proportional to this. Taking a snapshot of this extra data shows ~1024 "OBJECT" and ~1024 "FREE" lines in the zstream dump, with the raw data for the objects all starting with "ZP/"

Side-note: I also note that immediately after creating any dataset, the "written" is non-zero, a similar effect to this post-receive data?

diff_similarity() {
@digitalsignalperson
digitalsignalperson / example.service
Created March 15, 2024 06:39
template for a systemd service that logs a failed invocation to /home/asdf/alerts/%N-failure
[Unit]
Description=my service
[Service]
Restart=always
RestartSec=10
ExecStart=
Environment="ALERT_PATH=/home/asdf/%N-failure"
ExecStopPost=/bin/bash -c '\
echo $$SERVICE_RESULT, $$EXIT_CODE, $$EXIT_STATUS | logger; \