19

I need to replace a bad disk in a zpool on FreeNAS.

zpool status shows

gptid/5fe33556-3ff2-11e2-9437-f46d049aaeca  UNAVAIL      0     0     0  cannot open

How do I find the serial # of that disk?


More:

glabel status gives:

                                      Name  Status  Components
                             ufs/FreeNASs3     N/A  da0s3
                             ufs/FreeNASs4     N/A  da0s4
                    ufsid/4fa405ab96518680     N/A  da0s1a
                            ufs/FreeNASs1a     N/A  da0s1a
                            ufs/FreeNASs2a     N/A  da0s2a
gptid/5f3c0517-3ff2-11e2-9437-f46d049aaeca     N/A  ada1p2
gptid/60570005-3ff2-11e2-9437-f46d049aaeca     N/A  ada3p2
gptid/60ebeaa5-3ff2-11e2-9437-f46d049aaeca     N/A  ada4p2
gptid/a767b8ef-1c95-11e2-af4c-f46d049aaeca     N/A  ada6p2
gptid/61925b86-3ff2-11e2-9437-f46d049aaeca     N/A  ada9p2
gptid/4599731b-8f15-11e1-a14c-f46d049aaeca     N/A  ada10p2

I don't see gptid/5fe33556 in there.

And camcontrol devlist gives:

<Hitachi HDS723030BLE640 MX6OAAB0>  at scbus0 target 0 lun 0 (pass0,ada0)
<ST3000VX000-9YW166 CV13>          at scbus4 target 0 lun 0 (pass1,ada1)
<ST3000VX000-9YW166 CV13>          at scbus6 target 0 lun 0 (pass3,ada3)
<Hitachi HDS723030BLE640 MX6OAAB0>  at scbus7 target 0 lun 0 (pass4,ada4)
<ST3000DM001-9YN166 CC4C>          at scbus8 target 0 lun 0 (pass5,ada5)
<WDC WD30EZRX-00MMMB0 80.00A80>    at scbus8 target 1 lun 0 (pass6,ada6)
<WDC WD30EZRX-00MMMB0 80.00A80>    at scbus9 target 0 lun 0 (pass7,ada7)
<ST3000DM001-9YN166 CC4C>          at scbus9 target 1 lun 0 (pass8,ada8)
<Hitachi HDS723030BLE640 MX6OAAB0>  at scbus10 target 0 lun 0 (pass9,ada9)
<Hitachi HDS5C3030ALA630 MEAOA580>  at scbus11 target 0 lun 0 (pass10,ada10)
< USB Flash Memory 1.00>           at scbus12 target 0 lun 0 (pass11,da0)

Does that mean that ada2 is the bad disk?


UPDATE:

OK, I'm pretty sure that ada2 is the bad disk. And I have my notes, so I know which disk that is.

But it appears that I left a spare in there - ada0 - last time I was in the box. Can I replace ada2 with ada0 remotely? Until someone gets to the office?

5
  • 1
    So here the question is more about how to identify which disk this partition is from ? (as disk serials can be found in dmesg)
    – Ouki
    Apr 4, 2014 at 21:18
  • My bad about dmesg: there is the drive model, but not its serial. It's seems only smartcl -i can give you that kind of info. Why do you need it by the way, as once you remove the disk from its enclosure it's written on the disk label?!
    – Ouki
    Apr 4, 2014 at 23:24
  • I need the serial # so I know which disk to pull out ... I don't know what that long gptid string refers to ... it used to say "ada" something, but no more.
    – d0g
    Apr 5, 2014 at 0:43
  • 2
    The gptid is GEOM unique id. Now that your disk is down, you cannot get the serial, but you can still figure it out which "adaX" to pull out.
    – Ouki
    Apr 5, 2014 at 0:49
  • This is a classic example of why best practice recommends that you use GPT labels and include the serial number (or at least several low-order digits of it) in the GPT label. That way, when ZFS tells you a GPT label has failed, you'll know exactly that the disk SN is. The GPT label needs to be physically labeled on the front of the disk tray as well, so it's unambiguous which drive needs to be pulled to locate a given serial number. See ZFS Mastery by Lucas & Jude.
    – Jim L.
    Jul 25, 2019 at 0:24

6 Answers 6

18

To get a disk serial requires that it is running and available:

  • camcontrol identify <device> |grep ^serial (this might be (S)ATA specific)
  • smartctl -i <device> |grep ^Serial
  • reading the disk label once removed from the enclosure

In your case, I think the 3rd solution is the only available. So, Assuming you just want first identify the disk:

Try first a glabel status (as your drive is not shown as DOWN or REMOVED):

$ glabel status
gptid/c7868819-ddc1-11e2-8c3e-00138f3fd9c7     N/A  da0p1
gptid/c96da0bc-ddc1-11e2-8c3e-00138f3fd9c7     N/A  da2p1
  1. You can see your partition with glabel status

Then you can easily identify the disk device name (ex: da0 for the gptid/c7868819-ddc1-11e2-8c3e-00138f3fd9c7 partition).

You can have a look at your system starting log from /var/log/messages (aka "dmesg"):

    $ dmesg | grep ^da0
    da0 at mps0 bus 0 scbus0 target 0 lun 0
    da0: <ATA ST3000DM001-1CH1 CC26> Fixed Direct Access SCSI-6 device
    da0: 600.000MB/s transfers
    da0: Command Queueing enabled
    da0: 2861588MB (5860533168 512 byte sectors: 255H 63S/T 364801C)
    
  1. You cannot see your partition with glabel status

     $ camcontrol devlist
     <ATA ST3000DM001-1CH1 CC26>        at scbus0 target 0 lun 0 (pass0,da0)
     <ATA ST3000DM001-1CH1 CC26>        at scbus0 target 4 lun 0 (pass2,da2)
    

From there, you can easily spot which one is missing (da1 in this case), then have a look at dmesg to identify that disk.

So, no real solution here. I just hope that it help you see things a bit more clear.

To know more:

3
  • Please see added notes above ... is ada2 the bad disk?
    – d0g
    Apr 5, 2014 at 1:00
  • Yep. Looks that is the one.
    – Ouki
    Apr 5, 2014 at 8:16
  • 1
    smartcl -i <device> |grep ^Serial should be smartctl -i <device> | grep ^Serial
    – Sawtaytoes
    Dec 30, 2022 at 23:25
4
#!/bin/sh
echo
echo $(basename $0) - Mounted Drives on $(hostname)
cat /etc/version
date
echo
diskinfo="$(glabel status | tail -n +2 | awk '{split($3,a,"p"); print a[1],$1}')"
echo    "+========+==========================+==================+============================================+"
echo "| Device |     DISK DESCRIPTION     |  SERIAL  NUMBER  |                   GPTID                    |"
echo "+========+==========================+==================+============================================+"

for d in $(echo "$diskinfo" | cut -d" " -f 1)
do
   diskinf=$(diskinfo -v $d | grep '# Disk ')
   diskdescription=$(echo "$diskinf" | grep '# Disk desc' | cut -d# -f 1 | xargs)
   diskserialno=$(echo "$diskinf" | grep '# Disk ident' | cut -d# -f 1 | xargs)
   diskgptid=$(echo "$diskinfo" | grep "^$d" | cut -d" " -f 2)
   printf "| %-6s | %-24s | %-16s | %-42s |\n" "$d" "$diskdescription"     "$diskserialno" "$diskgptid"
   echo "+--------+--------------------------+------------------+--------------------------------------------+"
done

source

1

I made a script that lists all of the GPTID and associated hard drive serial number and device name.

#!/bin/bash

#Use smartctl to get Serial Number - else dmesg is used
USESMART=0
#save glabel status to temporary file
CACHEGLABEL=1

if  [ $CACHEGLABEL -eq 0 ]
then
GLCMD="glabel status"
else
GLTMP=/var/tmp/$0.glabel
glabel status > $GLTMP
GLCMD="cat $GLTMP"
fi

ADALOW=`ls /dev/ada[0-9] 2>/dev/null`
ADAHIGH=`ls /dev/ada[0-9][0-9] 2>/dev/null`
DALOW=`ls /dev/da[0-9] 2>/dev/null`
DAHIGH=`ls /dev/da[0-9][0-9] 2>/dev/null`
#check if all device nodes exist or skip
if  [[ $ADALOW == *ls* ]]
then
$DALOW=
fi
if  [[ $ADAHIGH == *ls* ]]
then
$ADAHIGH=
fi
if  [[ $DALOW == *ls* ]]
then
$DALOW=
fi
if  [[ $DAHIGH == *ls* ]]
then
$DAHIGH=
fi
for FILE in $ADALOW $ADAHIGH $DALOW $DAHIGH
do
DEV=${FILE##'/dev/'}
#echo -n "${DEV}: "
if  [ $USESMART -eq 0 ]
then
SERIAL=`grep $DEV: /var/log/dmesg.today |grep -i Serial | awk '{print $(NF)}'`
else
SERIAL=`smartctl -a $FILE | grep -i 'Serial Number'| awk '{print $(NF)}'`
fi
#this skips all ufs drives
GPTID=`$GLCMD |grep 2$ |grep ${DEV}p|cut -d' ' -f1`
if [ "${GPTID}x" == 'x' ]
then
GPTID="No GPTID"
fi
if [ "${SERIAL}x" == 'x' ]
then
$SERIAL="Not found"
fi
echo  ${DEV}: Serial $SERIAL \; GPTID=$GPTID
done

if  [ $CACHEGLABEL -eq 1 ]
then
rm $GLTMP
fi
0

You could try something like this. It worked for me:

devlist=$(sudo camcontrol devlist | awk ' { print $NF } ' | cut -f 2 -d , | sed 's/)//'g)

for device in $devlist; do sudo camcontrol identify $device | grep serial; done

that should output the entire list of serial numbers.

0

But it appears that I left a spare in there - ada0 - last time I was in the box. Can I replace ada2 with ada0 remotely? Until someone gets to the office?

Yes, zpool replace

-3

Assuming you need uuid of the particular disk on Linux based system you can get with:

ls -la /dev/disk/by-uuid/

or by fs label:

 ls -la /dev/disk/by-label/ 

or by hardware connectivity :

ls-la /dev/disk/by-path/
2
  • 4
    This is NOT Linux. udev is Linux specific, as many fancy /proc stuff ... unfortunately here.
    – Ouki
    Apr 4, 2014 at 21:50
  • By the way, I am not sure Linux would keep a disk down in its udev anyway.
    – Ouki
    Apr 4, 2014 at 23:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .