#!/bin/sh
# DF-5109 guest setup v2 (clean boot): vinum + vn3 drive d0 + (for DF-5108
# context) the raid5 volume, then run the lockdrive race.
set -x
kldload vinum
cd /root/poc
for spec in x0:0 x1:1 x2:2 d0:3; do
  n=${spec%%:*}; v=${spec##*:}
  dd if=/dev/zero of=vd_$n.img bs=1m count=160 status=none
  vnconfig -c vn$v vd_$n.img
  fdisk -I vn$v >/dev/null 2>&1
  disklabel -w -r vn${v}s1 auto 2>/dev/null
  disklabel vn${v}s1 > rl_$n 2>/dev/null
  printf "  a:        *        *    vinum\n" >> rl_$n
  disklabel -R vn${v}s1 rl_$n 2>/dev/null
  dd if=lbl_$n.bin of=/dev/vn${v}s1a bs=512 seek=8 status=none
done
./vcreate "drive x0 device /dev/vn0s1a"
./vcreate "drive x1 device /dev/vn1s1a"
./vcreate "drive x2 device /dev/vn2s1a"
./vcreate "volume rv"
./vcreate "plex name p0 org raid5 64s"
./vcreate "sd length 100m drive x0 plex p0"
./vcreate "sd length 100m drive x1 plex p0"
./vcreate "sd length 100m drive x2 plex p0"
./vcreate -s 0 1 3 1; ./vcreate -s 1 1 3 1; ./vcreate -s 2 1 3 1
./vcreate -s 0 2 3 1
vinum lv 2>&1 | head -2
dmesg | grep -i vinum | tail -2
