Unable to get device /dev/nvme1 info
When invoking shd on my machine I get thrown the following error:
ewout@enthoo ~ % sudo shd -y
: /dev/nvme1Unable to get device /dev/nvme1 info: EOF while parsing a value at line 1 column 0
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ()', src/main.rs:225:26
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
My machine uses the following disk layout:
ewout@enthoo ~ % lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 1 119,2G 0 disk
├─sda1 8:1 1 512M 0 part
└─sda2 8:2 1 118,7G 0 part
└─cryptlvm 254:2 0 118,7G 0 crypt
sdb 8:16 1 1,8T 0 disk
└─sdb1 8:17 1 1,8T 0 part
└─crypthdd 254:3 0 1,8T 0 crypt
nvme0n1 259:0 0 931,5G 0 disk
├─nvme0n1p1 259:1 0 512M 0 part /boot
└─nvme0n1p2 259:2 0 931G 0 part
└─cryptroot 254:0 0 931G 0 crypt /
nvme1n1 259:3 0 119,2G 0 disk
└─nvme1n1p1 259:4 0 20G 0 part
└─cryptswap 254:1 0 20G 0 crypt [SWAP]
Good day,
please try 0.1.4, it should now skip devices with smartctl errors.
Good day,
please try 0.1.4, it should now skip devices with smartctl errors.
Appreciate the fix! No longer crashes! :+1:
Digging further, it's smartctl that crashes with a free(): invalid pointer sent to stdout.
ewout@enthoo ~ % sudo smartctl -a /dev/nvme1 -j
{
"json_format_version": [
1,
0
],
"smartctl": {
"version": [
7,
2
],
"svn_revision": "5155",
"platform_info": "x86_64-linux-5.13.13-arch1-1",
"build_info": "(local build)",
"argv": [
"smartctl",
"-a",
"/dev/nvme1",
"-j"
],
"exit_status": 0
},
"device": {
"name": "/dev/nvme1",
"info_name": "/dev/nvme1",
"type": "nvme",
"protocol": "NVMe"
},
"model_name": "ADATA SX6000LNP",
"serial_number": "2K38291DQ2XG",
"firmware_version": "V9002s45",
"nvme_pci_vendor": {
"id": 4332,
"subsystem_id": 4332
},
"nvme_ieee_oui_identifier": 57420,
"nvme_controller_id": 1,
"nvme_version": {
"string": "1.3",
"value": 66304
},
"nvme_number_of_namespaces": 1,
"nvme_namespaces": [
{
"id": 1,
"size": {
"blocks": 250069680,
"bytes": 128035676160
},
"capacity": {
"blocks": 250069680,
"bytes": 128035676160
},
"utilization": {
"blocks": 250069680,
"bytes": 128035676160
},
"formatted_lba_size": 512
}
],
"user_capacity": {
"blocks": 250069680,
"bytes": 128035676160
},
"logical_block_size": 512,
"local_time": {
"time_t": 1630504706,
"asctime": "Wed Sep 1 15:58:26 2021 CEST"
},
"smart_status": {
"passed": true,
"nvme": {
"value": 0
}
},
"nvme_smart_health_information_log": {
"critical_warning": 0,
"temperature": 44,
"available_spare": 100,
"available_spare_threshold": 32,
"percentage_used": 0,
"data_units_read": 181694,
"data_units_written": 164990,
"host_reads": 761961,
"host_writes": 687549,
"controller_busy_time": 0,
"power_cycles": 364,
"power_on_hours": 2,
"unsafe_shutdowns": 8,
"media_errors": 0,
"num_err_log_entries": 8,
"warning_temp_time": 0,
"critical_comp_time": 0
},
"temperature": {
"current": 44
},
"power_cycle_count": 364,
"power_on_time": {
"hours": 2
}
}
free(): invalid pointer
[1] 31142 abort sudo smartctl -a /dev/nvme1 -j
JSON looks fine but I guess the problem is that invalid pointer is printed to stdout. can u run smartctl with 2>/dev/null and check the output?
JSON looks fine but I guess the problem is that invalid pointer is printed to stdout. can u run smartctl with 2>/dev/null and check the output?
It does the correct thing. errors are sent to stderr indeed. :smiley_cat:
ewout@enthoo ~ % sudo smartctl -a /dev/nvme1 -j 2>/dev/null
{
"json_format_version": [
1,
0
],
"smartctl": {
"version": [
7,
2
],
"svn_revision": "5155",
"platform_info": "x86_64-linux-5.13.13-arch1-1",
"build_info": "(local build)",
"argv": [
"smartctl",
"-a",
"/dev/nvme1",
"-j"
],
"exit_status": 0
},
"device": {
"name": "/dev/nvme1",
"info_name": "/dev/nvme1",
"type": "nvme",
"protocol": "NVMe"
},
"model_name": "ADATA SX6000LNP",
"serial_number": "2K38291DQ2XG",
"firmware_version": "V9002s45",
"nvme_pci_vendor": {
"id": 4332,
"subsystem_id": 4332
},
"nvme_ieee_oui_identifier": 57420,
"nvme_controller_id": 1,
"nvme_version": {
"string": "1.3",
"value": 66304
},
"nvme_number_of_namespaces": 1,
"nvme_namespaces": [
{
"id": 1,
"size": {
"blocks": 250069680,
"bytes": 128035676160
},
"capacity": {
"blocks": 250069680,
"bytes": 128035676160
},
"utilization": {
"blocks": 250069680,
"bytes": 128035676160
},
"formatted_lba_size": 512
}
],
"user_capacity": {
"blocks": 250069680,
"bytes": 128035676160
},
"logical_block_size": 512,
"local_time": {
"time_t": 1630506916,
"asctime": "Wed Sep 1 16:35:16 2021 CEST"
},
"smart_status": {
"passed": true,
"nvme": {
"value": 0
}
},
"nvme_smart_health_information_log": {
"critical_warning": 0,
"temperature": 44,
"available_spare": 100,
"available_spare_threshold": 32,
"percentage_used": 0,
"data_units_read": 181694,
"data_units_written": 164990,
"host_reads": 761961,
"host_writes": 687549,
"controller_busy_time": 0,
"power_cycles": 364,
"power_on_hours": 2,
"unsafe_shutdowns": 8,
"media_errors": 0,
"num_err_log_entries": 8,
"warning_temp_time": 0,
"critical_comp_time": 0
},
"temperature": {
"current": 44
},
"power_cycle_count": 364,
"power_on_time": {
"hours": 2
}
}
[1] 31424 abort sudo smartctl -a /dev/nvme1 -j 2> /dev/null
then I guess the prob. is with exit code. can u give echo $? plz
then I guess the prob. is with exit code. can u give echo $? plz
root@enthoo ~ # shd -y
: /dev/nvme1Unable to get device /dev/nvme1 info: EOF while parsing a value at line 1 column 0
Disk Model Serial Temp PoH PCC Int Capacity RRate Firmware
-------------------------------------------------------------------------------------------------------
nvme0 Samsung SSD 980 PRO 1TB S5GXNG0N906899Y 52 C 934 376 nvme 1.00 TB 1B2QGXA7
sda Crucial_CT128MX100SSD1 14180C1C7F37 36 C 21412 3263 sat 128.04 GB MU01
sdb WDC WD20EZRZ-00Z5HB0 WD-WCC4M7TX4AHP 34 C 13699 1070 sat 2.00 TB 5400 80.00A80
root@enthoo ~ # echo $?
0
no, mean running smartctl directly
no, mean running smartctl directly
Woops. Brainfart there. Apologies. Here you go:
[1] 33599 abort sudo smartctl -a /dev/nvme1 -j 2> /dev/null
134 ewout@enthoo ~ % echo $?
134
that's the problem. it doesn't exit with 0 and the executor function doesn't return the output. you should report the bug to smartmontools guys to let the fix that memleak, on my side I'll replace the function a bit later to more safe executor to let it obtain stdout even if a command crashed.