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

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080

fireheadman

Dabbler
Joined
Nov 13, 2016
Messages
49
+1 liked this script a lot! Finally something I can use to correlate dev names to serial numbers to gptids
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
I thought I would give this a bump so people would see it again. The script is recently (six months ago) revised and now includes a feature that even tells what SAS backplane and port the drive is attached to. It is more useful than ever to me and I thought it should be looked at.
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

Here is an example of the output:
Code:
root@Emily-NAS:~/scripts # ./disklist.pl
partition  label                                       zpool         device  disk                      size  type  serial               rpm  sas-location
--------------------------------------------------------------------------------------------------------------------------------------------------------------
da6p1      gptid/2e919d3d-2c1a-11e9-af8b-00074306773b  Backup        da6     ATA WDC WD6002FRYZ-0      6001  HDD   xxxxxxxx            7200  SAS2308_2(0):2#3
da7p1      gptid/2f292da6-2c1a-11e9-af8b-00074306773b  Backup        da7     ATA WDC WD6002FRYZ-0      6001  HDD   xxxxxxxx            7200  SAS2308_2(0):3#7
da9p1      gptid/30514e6b-2c1a-11e9-af8b-00074306773b  Backup        da9     ATA WDC WD6002FRYZ-0      6001  HDD   xxxxxxxx            7200  SAS2308_2(0):3#3
da25p1     gptid/41d3312f-2c1a-11e9-af8b-00074306773b  Backup        da25    ATA WDC WD6002FRYZ-0      6001  HDD   xxxxxxxx            7200  SAS2308_2(0):2#5
da26p1     gptid/426b7b47-2c1a-11e9-af8b-00074306773b  Backup        da26    ATA WDC WD6002FRYZ-0      6001  HDD   xxxxxxxx            7200  SAS2308_2(0):2#1
da27p1     gptid/43029d18-2c1a-11e9-af8b-00074306773b  Backup        da27    ATA WDC WD6002FRYZ-0      6001  HDD   xxxxxxxx            7200  SAS2308_2(0):3#5
da28p1     gptid/af54c9c6-4277-11e9-af8b-00074306773b  Backup        da28    ATA WDC WD6002FRYZ-0      6001  HDD   xxxxxxxx            7200  SAS2308_2(0):3#1
da32p1     gptid/9a325bf8-45fd-11eb-935f-00074306773b  Backup        da32    ATA ST10000NM0016-1T     10000  HDD   xxxxxxxx            7200  SAS2308_2(0):2#15
da0p1      gptid/af7c42c6-bf05-11e8-b5f3-0cc47a9cd5a4  Emily         da0     ATA ST4000DM000-1F21      4000  HDD   xxxxxxxx            5900  SAS2308_2(0):3#11
da1p1      gptid/b07bc723-bf05-11e8-b5f3-0cc47a9cd5a4  Emily         da1     ATA ST4000DM000-1F21      4000  HDD   xxxxxxxx            5900  SAS2308_2(0):3#12
da2p1      gptid/b1893397-bf05-11e8-b5f3-0cc47a9cd5a4  Emily         da2     ATA ST4000DM000-1F21      4000  HDD   xxxxxxxx            5900  SAS2308_2(0):3#13
da3p1      gptid/b2bfc678-bf05-11e8-b5f3-0cc47a9cd5a4  Emily         da3     ATA ST4000DM000-1F21      4000  HDD   xxxxxxxx            5900  SAS2308_2(0):3#10
da4p1      gptid/b3c1849e-bf05-11e8-b5f3-0cc47a9cd5a4  Emily         da4     ATA ST4000DM000-1F21      4000  HDD   xxxxxxxx            5900  SAS2308_2(0):3#9
da5p1      gptid/b4d16ad2-bf05-11e8-b5f3-0cc47a9cd5a4  Emily         da5     ATA ST4000DM000-1F21      4000  HDD   xxxxxxxx            5900  SAS2308_2(0):3#8
da22p1     gptid/b9de3232-bf05-11e8-b5f3-0cc47a9cd5a4  Emily         da22    ATA ST4000DM000-1F21      4000  HDD   xxxxxxxx            5900  SAS2308_2(0):2#13
da23p1     gptid/baf4aba8-bf05-11e8-b5f3-0cc47a9cd5a4  Emily         da23    ATA ST4000DM000-1F21      4000  HDD   xxxxxxxx            5900  SAS2308_2(0):2#12
da24p1     gptid/bbf26621-bf05-11e8-b5f3-0cc47a9cd5a4  Emily         da24    ATA ST4000DM000-1F21      4000  HDD   xxxxxxxx            5900  SAS2308_2(0):2#11
da29p1     gptid/acb0b918-ba5d-11e9-b6dd-00074306773b  Emily         da29    ATA ST4000DM000-1F21      4000  HDD   xxxxxxxx            5900  SAS2308_2(0):2#9
da30p1     gptid/d1ea0d87-ba96-11e9-b6dd-00074306773b  Emily         da30    ATA ST4000DM000-1F21      4000  HDD   xxxxxxxx            5900  SAS2308_2(0):2#8
da31p1     gptid/85d8ab3b-e442-11ea-99b6-00074306773b  Emily         da31    ATA ST4000DM005-2DP1      4000  HDD   xxxxxxxx            5980  SAS2308_2(0):2#10
nvd0p2     gptid/ae487c50-bec3-11e8-b1c8-0cc47a9cd5a4  Emily         nvd0    INTEL SSDPEDMD400G4        144  NVME  xxxxxxxxxxxxxxxx       0
nvd0p3     gptid/ae52d59d-bec3-11e8-b1c8-0cc47a9cd5a4  Emily         nvd0    INTEL SSDPEDMD400G4        144  NVME  xxxxxxxxxxxxxxxx       0
da8p1      gptid/c2938b94-4645-11eb-935f-00074306773b  Irene         da8     ATA ST4000NM0115-1YZ      4000  HDD   xxxxxxxx            7200  SAS2308_2(0):2#22
da10p1     gptid/c277c485-4645-11eb-935f-00074306773b  Irene         da10    ATA ST4000NM0115-1YZ      4000  HDD   xxxxxxxx            7200  SAS2308_2(0):2#21
da11p1     gptid/c1d68334-4645-11eb-935f-00074306773b  Irene         da11    ATA ST4000NM0115-1YZ      4000  HDD   xxxxxxxx            7200  SAS2308_2(0):2#20
da12p1     gptid/c3623afe-4645-11eb-935f-00074306773b  Irene         da12    ATA ST4000NM0115-1YZ      4000  HDD   xxxxxxxx            7200  SAS2308_2(0):2#19
da13p1     gptid/c412a29e-4645-11eb-935f-00074306773b  Irene         da13    ATA ST4000NM0115-1YZ      4000  HDD   xxxxxxxx            7200  SAS2308_2(0):2#18
da14p1     gptid/c4f8db9d-4645-11eb-935f-00074306773b  Irene         da14    ATA ST4000NM0115-1YZ      4000  HDD   xxxxxxxx            7200  SAS2308_2(0):2#17
da15p1     gptid/c835b314-4645-11eb-935f-00074306773b  Irene         da15    ATA ST4000NM0115-1YZ      4000  HDD   xxxxxxxx            7200  SAS2308_2(0):3#17
da16p1     gptid/c89f0922-4645-11eb-935f-00074306773b  Irene         da16    ATA ST4000NM0115-1YZ      4000  HDD   xxxxxxxx            7200  SAS2308_2(0):3#18
da17p1     gptid/c6c5b646-4645-11eb-935f-00074306773b  Irene         da17    ATA ST4000NM0115-1YZ      4000  HDD   xxxxxxxx            7200  SAS2308_2(0):3#19
da18p1     gptid/c8f13442-4645-11eb-935f-00074306773b  Irene         da18    ATA ST4000NM0115-1YZ      4000  HDD   xxxxxxxx            7200  SAS2308_2(0):3#20
da19p1     gptid/c96027bb-4645-11eb-935f-00074306773b  Irene         da19    ATA ST4000NM0115-1YZ      4000  HDD   xxxxxxxx            7200  SAS2308_2(0):3#21
da20p1     gptid/c794ee16-4645-11eb-935f-00074306773b  Irene         da20    ATA ST4000NM0115-1YZ      4000  HDD   xxxxxxxx            7200  SAS2308_2(0):3#22
ada0p2     gptid/1c8c1495-45f8-11eb-935f-00074306773b  freenas-boot  ada0    INTEL SSDSC2KW512G8        512  SSD   xxxxxxxxxxxxxxxx       0
ada1p2     gptid/864cf157-45f9-11eb-935f-00074306773b  freenas-boot  ada1    INTEL SSDSC2KW512G8        512  SSD   xxxxxxxxxxxxxxxx       0
                                                                     da21    HITACHI HUSSL4010BSS600    100  SSD   xxxxxxxx               0  SAS2308_2(0):2#23
                                                                     da33    HITACHI HUSSL4010BSS600    100  SSD   xxxxxxxx               0  SAS2308_2(0):2#16
                                                                     da34    HITACHI HUSSL4010BSS600    100  SSD   xxxxxxxx               0  SAS2308_2(0):3#23
                                                                     da35    HITACHI HUSSL4010BSS600    100  SSD   xxxxxxxx               0  SAS2308_2(0):3#16

39 selected disk(s)
root@Emily-NAS:~/scripts #
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
Lol

November '17

December '20

(To be fair you saw the value way sooner, but I thought the difference between this last post and the early one very funny)
Live and learn. If you are not learning, every day, you are doing in wrong.

I could have deleted the older post, long ago, or edited it, but I leave it because I don't feel any shame in acknowledging that I have learned a better way to do something.
 

Rand

Guru
Joined
Dec 30, 2013
Messages
906
Actually you edited one of them ("superfluous") ;)
but I totally agree re learning and that's exactly the message it was sending:)
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
Actually you edited one of them ("superfluous") ;)
but I totally agree re learning and that's exactly the message it was sending:)
I don't remember that. It has been years... You are looking at something from 2017 after all. That was most likely just a matter of different choice of words.

As for the script, it was just updated six months ago and I only found out about that recent update on (or about) the 23rd of December 2020.
I had a hard drive failure and went to check if there was an update in conjunction with my troubleshooting efforts.
 

MisterPi

Cadet
Joined
Mar 15, 2020
Messages
8
I'm going to give this another bump because I installed it long ago and never really understood the output (once and future noob). Back then I had one pool. I added another pool with some ST4000VNZ08 drives and thought I'd just let it sit a while before I used it. Turned out to be a good thing that I did because I have had some of those drives fail (under warranty). Going back and trying to figure out what was going on and how to fix it, I updated the script and read the release notes -- especially the part about not using glabel status and using gpart list instead which is the most educational command I've come across in a long time. It tells you EVERYTHING. Looking at the output of glabel status gave me some gptids that did not make any sense and didn't match any of the disks actually installed. Hours of head-scratching later, I tripped over this again and now I know how to proceed. Starting by replacing a drive which has simply disappeared then deleting the pool and starting over - it has no data on it anyway.

Sample before/after:

Code:
root@cervinia[~]# glabel status
                                      Name  Status  Components
gptid/ca1ae805-9b09-11ea-b794-1c1b0d075b31     N/A  ada0p2
gptid/d53028f4-ba82-11ea-b7c6-1c1b0d075b31     N/A  ada1p2
gptid/c9c72df0-9b09-11ea-b794-1c1b0d075b31     N/A  ada2p2
gptid/ca0b6bb0-9b09-11ea-b794-1c1b0d075b31     N/A  ada3p2
gptid/e8faf4fc-a895-11eb-bb9a-1c1b0d075b31     N/A  ada4p1
gptid/f1f64457-6d5f-11ea-ac8d-1c1b0d075b31     N/A  ada5p1
gptid/94c0d962-e36c-11ea-b6f0-1c1b0d075b31     N/A  da3p2
gptid/8cd4b7b9-15cb-11ec-909d-1c1b0d075b31     N/A  da1p1
gptid/c9e26dfb-9b09-11ea-b794-1c1b0d075b31     N/A  ada0p1

root@cervinia[~]# perl ./disklist.pl -i:zpool Pool.2-4TB -all
partition  fs           label                                       zpool       zpool-location       zpool-mount      device  sector  disk                  size  type  serial         rpm  sas-location 
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
da1p2      freebsd-zfs  gptid/8d24542b-15cb-11ec-909d-1c1b0d075b31  Pool.2-4TB  Pool.2-4TB/raidz2-0  /mnt/Pool.2-4TB  da1        512  ATA ST4000VN008-2DR1  4000  HDD   ZDHA8DTF      5980  SAS2008(0):1#1
da2p2      freebsd-zfs  gptid/969b5596-e36c-11ea-b6f0-1c1b0d075b31  Pool.2-4TB  Pool.2-4TB/raidz2-0  /mnt/Pool.2-4TB  da2        512  ATA TOSHIBA MG04ACA4  4000  HDD   56G8K1JEFVLC  7200  SAS2008(0):1#2
da3p2      freebsd-zfs  gptid/94c0d962-e36c-11ea-b6f0-1c1b0d075b31  Pool.2-4TB  Pool.2-4TB/raidz2-0  /mnt/Pool.2-4TB  da3        512  ATA TOSHIBA MG04ACA4  4000  HDD   56GAK1TVFVLC  7200  SAS2008(0):1#3

The output of disklist is clear and meaningful and aligns with what I know about the (remaining) disks in my system.

I want to thank nephri for writing this. It has made my life measurably better.
 
Last edited:

bisi

Cadet
Joined
Oct 14, 2011
Messages
7
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.
Why is this not part of the standard "kit" that comes with TrueNAS? (note - that remark is *not* directed at the author, who deserves kudos for fixing a giant hole in TrueNAS management tools. A deficit that kept me from adopting freeNAS long ago when I first looked for a more "client friendly" solution than my customized FreeBSD servers).
 

artlessknave

Wizard
Joined
Oct 29, 2016
Messages
1,506
Why is this not part of the standard "kit" that comes with TrueNAS? (note - that remark is *not* directed at the author, who deserves kudos for fixing a giant hole in TrueNAS management tools. A deficit that kept me from adopting freeNAS long ago when I first looked for a more "client friendly" solution than my customized FreeBSD servers).
unfortunately, the script is useless on SCALE.
the "disks" section of the webUI comes close, but fails to completely show what you need to map all the disks, particularly if you have a disk that dissapears: it'll tell you that the pool is degraded but you have to process of elimiation to figure out which frakking disk is the bad one.

the ability to include things like power on hours, temperature, and sector size (4k, 512) makes it more useful than basically everything in the UI.
 
Top