truenas / py-SMART

Wrapper for smartctl (smartmontools)
GNU Lesser General Public License v2.1
76 stars 35 forks source link

`DeviceList` not working on macOS 11 #43

Closed nvmnghia closed 2 years ago

nvmnghia commented 2 years ago

This line fails:

https://github.com/truenas/py-SMART/blob/68aeea9ce09b1875286eb9549e60516c7fb4bbc4/pySMART/device_list.py#L105

System:

The regex doesn't work because line doesn't match:

>>> print(line)
IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/SAT0@1F,2/AppleIntelPchSeriesAHCI/SPT4@4/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice -d ata # IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/SAT0@1F,2/AppleIntelPchSeriesAHCI/SPT4@4/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice, ATA device
ralequi commented 2 years ago

Hi @nvmnghia

Could you provide the complete output of the following commands?

smartctl --scan-open
smartctl -d ata --all <whole path to your failing device>

It would be nice to add a disk from MacOS to the test dataset.

Thank you!

nvmnghia commented 2 years ago
>>> smartctl --scan-open

IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/SAT0@1F,2/AppleIntelPchSeriesAHCI/SPT4@4/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice -d ata # IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/SAT0@1F,2/AppleIntelPchSeriesAHCI/SPT4@4/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice, ATA device
IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/SAT0@1F,2/AppleIntelPchSeriesAHCI/PRT2@2/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice -d ata # IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/SAT0@1F,2/AppleIntelPchSeriesAHCI/PRT2@2/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice, ATA device

The script

from pySMART import Device
Device('/dev/disk1')

seems OK to me, so there's no failing device for my case.

Full disclosure, I'm running Hackintosh, but there's no shady hack like forcing Big Sur on very very old hardware.

ralequi commented 2 years ago

Hi @nvmnghia,

Please, check the last commit at master and confirm that everything works.

And thank you for reporting the issue!

nvmnghia commented 2 years ago

TLDR: name can't be appended into /dev.


Sorry for not getting back immediately.

Now it doesn't print anything, empty DeviceList. I tracked down to this: the name in this line

https://github.com/truenas/py-SMART/blob/68aeea9ce09b1875286eb9549e60516c7fb4bbc4/pySMART/device_list.py#L106

is /dev/IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/SAT0@1F,2/AppleIntelPchSeriesAHCI/SPT4@4/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice, for example.

When passed into Device() constructor, it is appended after /dev:

https://github.com/truenas/py-SMART/blob/68aeea9ce09b1875286eb9549e60516c7fb4bbc4/pySMART/device.py#L785

And when I try the command in that call:

>>> smartctl -d ata --all '/dev/IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/SAT0@1F,2/AppleIntelPchSeriesAHCI/SPT4@4/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice'

smartctl 7.2 2020-12-30 r5155 [Darwin 20.6.0 x86_64] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

Smartctl open device: /dev/IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/SAT0@1F,2/AppleIntelPchSeriesAHCI/SPT4@4/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice failed: No such file or directory

This parsing method doesn't seem to work in macOS, especially when you don't have one to debug this yourself.

ralequi commented 2 years ago

Sorry @nvmnghia I absolutely forget about this issue.

Just to confirm I've understood this correctly:

The following command does not work ( which seems logic):

The correct one should be:

Please, confirm me when you are able that the previous command works, if not, please, provide me the custom command with smartctl that allows you to access your device

Thanks for your help

ralequi commented 2 years ago

Hi @nvmnghia ,

A MacOs user with 12.4 tould me that command smartctl --scan-open does nothing currently. Could you please check again if you have 12.4 version? Or if you find time, reply to my latests comment would be nice too.

Any other info would be appreciated

nvmnghia commented 2 years ago

Sorry @nvmnghia I absolutely forget about this issue.

Just to confirm I've understood this correctly:

The following command does not work ( which seems logic):

  • smartctl -d ata --all '/dev/IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/SAT0@1F,2/AppleIntelPchSeriesAHCI/SPT4@4/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice'

The correct one should be:

  • smartctl -d ata --all 'IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/SAT0@1F,2/AppleIntelPchSeriesAHCI/SPT4@4/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice'

Please, confirm me when you are able that the previous command works, if not, please, provide me the custom command with smartctl that allows you to access your device

Thanks for your help

That second command works.

Hi @nvmnghia ,

A MacOs user with 12.4 tould me that command smartctl --scan-open does nothing currently. Could you please check again if you have 12.4 version? Or if you find time, reply to my latests comment would be nice too.

Any other info would be appreciated

My hackintosh is stuck at 11.6, so I can't help you with that :(.

ralequi commented 2 years ago

I think pysmart is broken on MacOs 12, however, until I have more data I can't do much more...

In any case, I think for MacOs 11 should be fixed. Please, try the develop branch ( https://github.com/truenas/py-SMART/tree/develop ) whenerver you can and tell me if you find any other issues.

Thank you!

ralequi commented 2 years ago

I'm going to close the issue, please, feel free to reopen it if you find the problem is still there on MacOS 11.x

Thank you!