#!/bin/bash
set -e

N=3
I=3

set -x

if ! zpool list | grep -w 'no pools available'; then
    zpool destroy oss${N}pool # this "normally" never happens, added for script debug only
fi

if zpool list | grep -w 'no pools available'; then
    	[ -f 17.nvl ] || draidcfg -p 1 -d 4 -s 2 -n 17 17.nvl
    	draidcfg -r 17.nvl

    	zpool create -f oss${N}pool draid1 cfg=17.nvl /dev/sd[b-r]
fi
zpool list ; zpool status ; mount | grep oss${N}pool

mkfs.lustre --reformat \
    --ost \
    --backfstype=zfs \
    --fsname=ZFS01 \
    --index=${I} \
    --mgsnode=mgs@tcp0 \
    oss${N}pool/ZFS01

[ -d "/lustre/ZFS01/." ] || mkdir -p /lustre/ZFS01
mount -v -t lustre oss${N}pool/ZFS01 /lustre/ZFS01
# EOF #