##### end configuration
-bpart() {
+bpart() { # btrfs a partition
dev_n=$1
case ${#@} in
[1-3]) mkfs.btrfs -f $@ ;;
# fully 1MiB unit partitions for easy resizing of the last partition.
# Otherwise we would pass in -0 for the end argument for the last partition.
disk_mib=$(( $(parted -m ${devs[0]} unit MiB print | \
- sed -nr "s#^${devs[0]}:([0-9]+).*#\1#p") - 1))
+ sed -nr "s#^${devs[0]}:([0-9]+).*#\1#p") - 1))
root_end=$(( disk_mib - swap_mib - boot_mib ))
swap_end=$(( root_end + swap_mib))
shopt -s nullglob
if $partition; then
for dev in ${devs[@]}; do
- for x in $dev[0-9]; do wipefs -a $x; done
+ for x in $dev[0-9]; do
+ count_down=10
+ # wipefs has failed, manual run works, google suggests timing issue
+ while ! wipefs -a $x; do
+ sleep 2
+ count_down=$((count_down - 1))
+ (( count_down > 0 )) || exit 1
+ done
+ done
done
for dev in ${devs[@]}; do
parted -s $dev mklabel gpt