Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

SOLVED Utility: disklist.pl, for listing partition, gptid, slot, devices, disktype, serial num, & multipath

Western Digital Drives - The Preferred Drives of FreeNAS and TrueNAS CORE

Daurtanyn

Neophyte
Joined
Jan 12, 2016
Messages
11
A contributor on the Serve the Home forum contributed a wonderful utility.

Sébastien (Username nephri) has written a wonderful perl script

https://forums.servethehome.com/ind...nvenient-way-to-report-installed-disks.16310/

reports installed disks

I am running 11-STABLE and I just grabbed the code, dropped it into a file, made it executable and then ran the command suggested.

This command solves the problem of matching the individual elements using many CLI commands.

Below is the output. It reduces SO many investigative steps into ONE.

I'm a very happy camper.

The author said he planned to look for feedback in their forum before posting here in the FreeNAS forum. His post was in July (2017). I don't think folks over there understand what a gem he is providing.

H.

Code:
./disklist.pl -i:zpool my_vol1 -all
partition					label								zpool	device	sector  disk			   size  type  serial	rpm  location		 multipath				  mode
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
multipath/disk1p2  gptid/a882790c-cffb-11e7-a102-f46d0428d010  my_vol1  da13,da6	 512  SEAGATE ST1000NM0023  1000  HDD   Z1xxx3K  7200  SAS3008(0):3#11  multipath/disk1
multipath/disk2p2  gptid/6fc2aa85-4cee-11e6-b6e0-f46d0428d010  my_vol1  da12,da5	 512  SEAGATE ST1000NM0023  1000  HDD   Z1xxxGR  7200  SAS3008(0):3#8   multipath/disk2
multipath/disk3p2  gptid/0f7472dc-2424-11e4-8980-f46d0428d010  my_vol1  da10,da3	 512  SEAGATE ST1000NM0023  1000  HDD   Z1xxx81  7200  SAS3008(0):3#6   multipath/disk3
multipath/disk4p2  gptid/0ecce300-2424-11e4-8980-f46d0428d010  my_vol1  da9,da2	  512  SEAGATE ST1000NM0023  1000  HDD   Z1xxx5M  7200  SAS3008(0):3#5   multipath/disk4
multipath/disk5p2  gptid/0f3b1967-2424-11e4-8980-f46d0428d010  my_vol1  da1,da8	  512  SEAGATE ST1000NM0023  1000  HDD   Z1xxxDY  7200  SAS3008(0):3#4   multipath/disk5
multipath/disk6p2  gptid/0f031df2-2424-11e4-8980-f46d0428d010  my_vol1  da0,da7	  512  SEAGATE ST1000NM0023  1000  HDD   Z1xxx95  7200  SAS3008(0):3#3   multipath/disk6
multipath/disk7p2  gptid/e4eee36e-b824-11e5-882c-f46d0428d010  my_vol1  da11,da4	 512  SEAGATE ST1000NM0023  1000  HDD   Z1xxxA1  7200  SAS3008(0):3#7   multipath/disk7
 
Last edited by a moderator:

Chris Moore

Wizened Sage
Joined
May 2, 2015
Messages
10,062
Why would you need all that?
 

Daurtanyn

Neophyte
Joined
Jan 12, 2016
Messages
11
I had a disk failure last week. All I knew was the GPTID of the failed drive.

This table correlates all of the information I need to figure out which drive, in which slot, failed.

The serial number then allows me to verify if the pulled drive is the one which the zpool status output indicates.

The command: glabel status will provide GPTID to partition correlation, but that's all.

The command: gmultipath status will provide the active disks in each multipath device.

The command: smartctl -a /dev/<an active disk> | grep Serial will provide the serial number.
or
The command: diskinfo -v <an active disk> will provide serial number and the slot/tray info.

I have a LSI controller, so I can also use sas3ircu 0 display to get the slot/tray info.

Then you have to do all the correlation stuff yourself to figure out the disk to pull and replace.

This Perl script provides the entire set of linked information in one command. I've run the command and kept a copy of the output. The next time a drive fails there will be no forensics needed. The table output has everything I need.

H.
 
Last edited by a moderator:

Chris Moore

Wizened Sage
Joined
May 2, 2015
Messages
10,062
Last edited:

danb35

Wizened Sage
Joined
Aug 16, 2011
Messages
11,933
this superfluous script.
Seriously? You can't see any value in having all the possible disk identifiers (and FreeNAS uses several, at various times and in various ways) correlated together with serial numbers and physical locations, in a single table? Sure, there are other ways to get the information--OP obviously knows that, and mentioned (at least some of) them in his post. But look at that resource on identifying drives by serial number, and see how many steps are involved--and it doesn't even give you the physical location of the drive as this script does. Looks like a handy tool to me.

@Daurtanyn, you might also want to check out https://forums.freenas.org/index.php?resources/disk-failure-leds-for-supermicro-sas-backplanes.74/. It doesn't generate a pretty table, but it's supposed to light up the failure LEDs when a disk fails. I have no idea how it would handle multipaths, though.
 

Daurtanyn

Neophyte
Joined
Jan 12, 2016
Messages
11
The GUI based method for serial number retrieval does not work when you use multipath.

The GUI replacement method includes an important part of the replacement process because it includes the partitioning and the labeling processes. I'm not anti GUI, in any way, shape, or form.
 

Chris Moore

Wizened Sage
Joined
May 2, 2015
Messages
10,062
You can't see any value in having all the possible disk identifiers
I guess that I am a believer in prior planning. I have all the serial numbers of all the hard drives in all the servers I manage in a table that allows me to identify the location of a failed drive quickly and easily. When a drive starts to throw errors, I replace it and finding it is as easy as looking the serial number up on a chart.
 

danb35

Wizened Sage
Joined
Aug 16, 2011
Messages
11,933
I have all the serial numbers of all the hard drives in all the servers I manage in a table that allows me to identify the location of a failed drive quickly and easily.
And that table tells you which serial number is which gptid? And is which dan device? And you know the latter will never, never change? This script will generate that table, on demand, in under a second. That, by itself, sounds pretty handy.
 

wblock

Documentation Engineer
Joined
Nov 14, 2014
Messages
1,505
If you would have come to the FreeNAS forum for advice on how to use FreeNAS, you would know how to handle the situation without this superfluous script.
I'm guessing this was not meant to sound as harsh as it appears. In any case, this convenient little script is handy and useful, and I thanked @Daurtanyn for bringing it up.
 

bigphil

Senior Member
Joined
Jan 30, 2014
Messages
486
Yeah, I like it...very good info to have. Thank you for sharing it! Something I like to do when I put drives into a FreeNAS box is to put the physical chassis port a drive is located in, under the description field for that disk so I know exactly where it is, from the GUI, quickly. You have to insert the drives one at a time and fill the info out after each one so you don't get lost, but you only have to do it once and then after a replacement disk is inserted.
 

cobrakiller58

Senior Member
Joined
Jan 18, 2017
Messages
440
looks like i'm going to have to sign-up there just to get this..... lol
 

Chris Moore

Wizened Sage
Joined
May 2, 2015
Messages
10,062
looks like i'm going to have to sign-up there just to get this..... lol
You might ask the poster on that forum if he will come post it here .. It might actually be best if there was a github listing for it like the scripts @Spearfoot put up. That way the author could have a single place to update and both sites could access the script.
 

gpsguy

Active Member
Joined
Jan 22, 2012
Messages
4,473
That way the author could have a single place to update and both sites could access the script.
The users on the FreeNAS subreddit might appreciate it too. Many of them never visit these forums.
 

nephri

Member
Joined
Sep 20, 2015
Messages
40
Hi,

I'm the author of this script.

I wrote it for personal use to help me to write a report of installed disks at startup. This report is automatically sent on another server for achives
In that way, i have always an uptodate disks table of my NAS somewhere.
In the other way, it serve me to search/list disks from various criteria because i always forgot which native tools i would to use for a specific purpose...

In all ways, this script do nothing more to call other natives scripts and effectively you can do all without it. So, from this perspective it's maybe a superflous script.
I wrote it for personal use, and post it on the STH forums only in case if someone else may find it useful.

I just opened a git hub page for providing a public download : https://github.com/nephri/FreeNas-DiskList

Sébastien.
 
Last edited:

Chris Moore

Wizened Sage
Joined
May 2, 2015
Messages
10,062
I wrote it for personal use, and post on the STH forums only in case if someone else may find it useful.
Thank you for your contribution.
 

cobrakiller58

Senior Member
Joined
Jan 18, 2017
Messages
440

Daurtanyn

Neophyte
Joined
Jan 12, 2016
Messages
11
Thank you, Sébastien! This utility script has been very useful to me. Your script handles my multipath drive configuration without any issues.
 

nephri

Member
Joined
Sep 20, 2015
Messages
40
Hi,

A new version is available on the github repository : https://github.com/nephri/FreeNas-DiskList

ChangeLog are

Change Log
==========

version 1.1 (07/06/2019)
-----------

core:
- don't use anymore "glabel status"
- replace "gmultipath status" by "gmultipath list"
- use "gpart list" for building the partitions table
- use "gmultipath list" for completing the partitions table & devices with multipath datas

disk type detection:
- Handle NVME disk detection
- Handle NVRAM disk detection

new columns:
- column "fs" that show the partition type (freebsd-zfs, freebsd-swap, bios-boot, ...)
- column "path-state" that show the multipath state's device (OPTIMAL, ...)
- column "temp" that show the disk temperature
- column "zpool-location" that show the location of the partition inside the pool structure (tank/mirror-0, ...)

new switches:
- switch -smartctl that enable to report columns from smartctl tool (like temperature). without this switch theses columns are skipped.

updated profil layout:
- "all" report columns : pPlzZdtDUTSRHemos
- "long" report columns : plzdDUTSRH
- "short" report columns : pzdDUT

filters:
- the -fs:<type> filter can now handle theses types: none, all, any, zfs, swap, bios, unknown
- many filters can now be set more than one time for accepting more than one value. This apply to [-i:<class> <entity>], [-fs:<fstype>], [-c:<columns>]

layout switchs
- profil switch like -all, -long or -short can be used in addition of the switch [-c:<columns>]. Theses switch are merged together for defining columns to report.
 

Chris Moore

Wizened Sage
Joined
May 2, 2015
Messages
10,062
This is a fantastic update.
Thank you very much.
 

nephri

Member
Joined
Sep 20, 2015
Messages
40
A small fix and few enhancements with the new version 1.1a : https://github.com/nephri/FreeNas-DiskList

Code:
version 1.1a (12/06/2019)
------------

fix:
- fix display of unused disks (when not partitioned). In 1.1 some partitioned disks were also reported as unused disks

core:
- gptid association are now done with "glabel list" + "geli list" for handling encrypted partitions (GELI)
- zpool list are now used for determine the pool mount point (from the altroot)

layout:
- columns without any values are automatically removed from the layout.
  For example, if you don't have multipath drives, subsequents columns are automatically removed from the final layout
  This behaviour may be disabled using switch -static
- new column "M" giving the mount point of the zfs pool associated to the specified partition
- new column "X" giving the encryption algorithm used for encrypt the specified partition
- "-all" profil is now pPlzZMdtDUTSRHXemos
- "-long" profile is now plzdDUTSRHXemos

enhance:
- new switch -locate allow to blink disk enclosure led for 10 seconds
  This switch works only for drive connected to a sas hba (sas2ircu & sas3ircu compatible controllers)
- switch -multi:<multitype> can be set multiple times.
  For example for listing physical drive only once you can use these arguments: -multi:none -multi:active -nolabel
- new switch "-sort:<columns>" that allow to define the sort order of partitions and devices
- new switch "-static" for prevent columns to be removed even if they are empties.
- new switch "-nolabel" that allow to report only disk information without information about partitions
- print at the end of the report the number of disks reported
 
Top