Skip to content

Instantly share code, notes, and snippets.

@0xf10e
Created August 3, 2015 17:53
Show Gist options
  • Select an option

  • Save 0xf10e/076fec3f8afbe0d7e398 to your computer and use it in GitHub Desktop.

Select an option

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)
~% 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
@0xf10e

0xf10e commented Aug 3, 2015

Copy link
Copy Markdown
Author

Oh, sorry, we're fresh out of \ns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment