#!/bin/sh

format_disk() {
    DISK="$1"
    name="$2"
    wipefs -a "$DISK"
    end_position=$(sgdisk -E $DISK | tail -1)
    sgdisk -n2:1M:$(( $end_position - (($end_position + 1) % 2048) ))  -t2:BF01 $DISK
    sgdisk -c2:"$name" $DISK
    fdisk -l $DISK
}

format_disk /dev/sdi freenet1TB
format_disk /dev/sdj freenet80GB
format_disk /dev/sdk freenet80GB2
format_disk /dev/sdm freenet160GB

zpool create -O mountpoint=/freenet freenetpool freenet160GB freenet80GB freenet80GB2 freenet1TB