blob: aff8c0c01b1835770f01f3d0485a4289c4e8bbb3 [file] [log] [blame]
#!/bin/sh
# Creates a ZFS dataset per PV. The helper pod runs with hostPID, and all
# ZFS and filesystem operations are performed in the host's mount namespace
# (nsenter -t 1 -m). Running zfs directly inside the helper container would
# mount the dataset only inside the container's own mount namespace; the
# workload would then write into the parent dataset, and the child dataset
# would shadow that data after the next host reboot.
set -eu
while getopts "m:s:p:" opt
do
case $opt in
p)
absolutePath=$OPTARG
;;
s)
sizeInBytes=$OPTARG
;;
m)
volMode=$OPTARG
;;
esac
done
host() { nsenter -t 1 -m -- "$@"; }
host zfs create "rpool${absolutePath}"
host zfs mount "rpool${absolutePath}" 2>/dev/null || :
host findmnt -n -o SOURCE "${absolutePath}" | grep -qx "rpool${absolutePath}"
host chmod 0777 "${absolutePath}"