Add files via upload

This commit is contained in:
kneutron 2021-07-13 00:15:04 -05:00 committed by GitHub
parent 6003d33c4e
commit d366f450d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 6 deletions

View File

@ -0,0 +1,41 @@
#!/bin/bash
# 2021 Dave Bechtel
# REQUIRES output file from zfs-drive-slicer.sh, sed, awk, grep, head
# Translate short-form disks
#sdb sdc sdd sde sdf sdg sdh sdi sdj sdk sdl
# To long-form:
#pci-0000:00:16.0-sas-phy0-lun-0 pci-0000:00:16.0-sas-phy1-lun-0 pci-0000:00:16.0-sas-phy2-lun-0 pci-0000:00:16.0-sas-phy3-lun-0 pci-0000:00:16.0-sas-phy4-lun-0 pci-0000:00:16.0-sas-phy5-lun-0 pci-0000:00:16.0-sas-phy6-lun-0 pci-0000:00:16.0-sas-phy7-lun-0 pci-0000:00:16.0-sas-phy8-lun-0 pci-0000:00:16.0-sas-phy9-lun-0 pci-0000:00:16.0-sas-phy10-lun-0
# Useful when creating ZFS arrays
# Pseudocode:
# get zfs-drive-slicer output file
# use sed to delete line cont chars out
# read a line
## for every word in line; lookup + print dev/disk/by-path equivalent no-newline
# at line end print line continuation char
DBP=/dev/disk/by-path
DBI=/dev/disk/by-id
usetype=$DBP
# ^^ TODO EDITME
# NOTE WARNING when using SAS disks we are NOT guaranteed an entry in disk-by-id!
infile=/tmp/zfsds.txt
[ "$1" = "" ] || infile="$1" # override, if 1st arg passed
sed -i 's/\\//g' "$infile" # remove line-continuation chars
# set -x ## DEBUG
while read inline; do
for word in $inline; do
printf $(ls -l $usetype |grep -w /$word |awk '{print $9}' |head -n 1)" "
done
echo ' \'
done < $infile
# NOTE ^^ this may be inaccurate, no error checking for missing disks, just print what we find
#lrwxrwxrwx 1 root root 9 Jul 12 23:10 pci-0000:00:16.0-sas-phy9-lun-0 -> ../../sdk
# 1 2 3 4 5 j 7 8 9

View File

@ -4,12 +4,13 @@
# DONE [b..y] a[a..x] get slices of X disks and be able to verify with wc -w
# REQUIRES: seq
echo "$0 - 2021 Dave Bechtel"
echo "Pass arg1=total disks in pool -- arg2=how many disks per vdev"
# NOTE arg2 ^^ should factor in the RAIDz level 1/2/3 desired to sustain X number of failed disks per vdev + vspares,
# dont go too narrow or will lose capacity
echo "NOTE output lines should be the same number of devices to balance"
# Trick to put header outside of col -t
>&2 echo "$0 - 2021 Dave Bechtel"
>&2 echo "Pass arg1=total disks in pool -- arg2=how many disks per vdev"
>&2 echo "+ NOTE arg2 ^^ should factor in the RAIDz level 1/2/3 desired to sustain X number"
>&2 echo "+ of failed disks per vdev + vspares, dont go too narrow or will lose capacity"
>&2 echo "NOTE output lines should be the same number of devices to balance"
>&2 echo "PROTIP: Pipe output to column -t to make it look nice"
# REF: https://tldp.org/LDP/abs/html/arrays.html
# regular array - STARTS AT 0
@ -112,3 +113,8 @@ slice $1 $2
# 14
# 14
# 14
# HOWTO get long-form disks:
# use drive-slicer-get-longform.sh
# ^ Requires output from this script