-
-
Save 0xf10e/076fec3f8afbe0d7e398 to your computer and use it in GitHub Desktop.
So easy to get all the info you need for a $POOL-$POSITION-$SERIAL label with mfiutil(8) and mfi(4)/mrsas(4)
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh, sorry, we're fresh out of
\n
s.