This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~% POOL=foobar; sudo mfiutil -u 1 show drives | sed -ne 's/ *\([0-9]*\) (.*serial=\([A-Z0-9]*\)> SCSI-[0-9]* \(E[0-9]*:S[0-9]*\)/ID=\1 SERIAL=\2 POS=\3/p'| while read LINE; do eval "$LINE"; DEV=`dmesg | sed -ne "/deviceid: $ID)/s/\(mfi[^:]*\):.*/\1/p" | tail -n 1`; echo $DEV has serial $SERIAL, located in $POS:; gpart | |
list $DEV 2> /dev/null | grep label: || ( sudo gpart show $DEV || ( sudo gpart create -s gpt $DEV && sudo gpart add -a 1M -t freebsd-zfs -s 3700GB -l $POOL-`printf %02d "${POS#*S}"`-$SERIAL $DEV) ); done |
NewerOlder