#!/bin/bash BY_ID=/dev/disk/by-id DISK1=${BY_ID}/wwn-0x5000c5004fdf987b DISK2=${BY_ID}/wwn-0x5000c5004fdfcad4 # Pre-clean sgdisk --zap-all ${DISK1} sgdisk --zap-all ${DISK2} # Partitioning sgdisk -n1:1M:+512M -t1:EF00 ${DISK1} sgdisk -n2:0:+512M -t2:BF01 ${DISK1} sgdisk -n3:0:0 -t3:BF01 ${DISK1} sgdisk -n1:+512M:+512M -t1:BF01 ${DISK2} sgdisk -n2:0:0 -t2:BF01 ${DISK2} mkfs.vfat ${DISK1}-part1 # Verify sgdisk --print ${DISK1} sgdisk --print ${DISK2} read -p "Are you sure? " -n 1 -r echo if [[ ! $REPLY =~ ^[Yy]$ ]] then [[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 fi # Env set -x encryption_options=(-O encryption=on -O keylocation=prompt -O keyformat=passphrase) bpool_mirror_arg=${DISK2}-part1 rpool_mirror_arg=${DISK2}-part2 #set +x # Create ZFS pools rm -rf /mnt/* zpool create -f \ "${encryption_options[@]}" \ -o ashift=12 \ -O acltype=posixacl \ -O compression=off \ -O dnodesize=auto \ -O relatime=on \ -O xattr=sa \ -O normalization=formD \ -O devices=off \ -O mountpoint=/ \ -R /mnt \ rpool mirror ${DISK1}-part3 ${rpool_mirror_arg} zfs create -o canmount=noauto -o mountpoint=/ rpool/root mkdir -p /mnt/boot zpool create \ -d -o ashift=12 \ -O devices=off \ -O mountpoint=/boot \ -R /mnt/ \ bpool mirror ${DISK1}-part2 ${bpool_mirror_arg} mkdir -p /mnt/boot/efi mount ${DISK1}-part1 /mnt/boot/efi