blob: aff8c0c01b1835770f01f3d0485a4289c4e8bbb3 [file] [log] [blame]
Matthias Andreas Benkard05e482e2026-11-04 11:05:51 +01001#!/bin/sh
2# Creates a ZFS dataset per PV. The helper pod runs with hostPID, and all
3# ZFS and filesystem operations are performed in the host's mount namespace
4# (nsenter -t 1 -m). Running zfs directly inside the helper container would
5# mount the dataset only inside the container's own mount namespace; the
6# workload would then write into the parent dataset, and the child dataset
7# would shadow that data after the next host reboot.
8set -eu
9
10while getopts "m:s:p:" opt
11do
12 case $opt in
13 p)
14 absolutePath=$OPTARG
15 ;;
16 s)
17 sizeInBytes=$OPTARG
18 ;;
19 m)
20 volMode=$OPTARG
21 ;;
22 esac
23done
24
25host() { nsenter -t 1 -m -- "$@"; }
26
27host zfs create "rpool${absolutePath}"
28host zfs mount "rpool${absolutePath}" 2>/dev/null || :
29host findmnt -n -o SOURCE "${absolutePath}" | grep -qx "rpool${absolutePath}"
30host chmod 0777 "${absolutePath}"