Interessanterweise gibt es bei der USB-HDD einen Returncode !=0
Bei der SSD kommt immer eine 0 (alles O.K.) als "result" zurück, bei der HDD eine 4... also Bit 2 gesetzt ...
ich vermute, aufgrund der folgenden Fehlermeldung mit anschließender Warnung
...
=== START OF READ SMART DATA SECTION ===
SMART Status command failed: scsi error unsupported scsi opcode
SMART overall-health self-assessment test result: PASSED
Warning: This result is based on an Attribute check.
....
smartctl -a /dev/sda >/root/scripte/Proxmox_Skripte/Testdata.txt
result=$?
Das bedeutet laut untenstehendem ...
Return Values
The return values of smartctl are defined by a bitmask. If all is well with the disk, the return value (exit status) of smartctl is 0 (all bits turned off). If a problem occurs, or an error, potential error, or fault is detected, then a non-zero status is returned. In this case, the eight different bits in the return value have the following meanings for ATA disks; some of these values may also be returned for SCSI disks.
Bit 0:
Command line did not parse.
Bit 1:
Device open failed, device did not return an IDENTIFY DEVICE structure, or device is in a low-power mode (see '-n' option above).
Bit 2:
Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data structure (see '-b' option above).
Bit 3:
SMART status check returned "DISK FAILING".
Bit 4:
We found prefail Attributes <= threshold.
Bit 5:
SMART status check returned "DISK OK" but we found that some (usage or prefail) Attributes have been <= threshold at some time in the past.
Bit 6:
The device error log contains records of errors.
Bit 7:
The device self-test log contains records of errors. [ATA only] Failed self-tests outdated by a newer successful extended self-test are ignored.
To test within the shell for whether or not the different bits are turned on or off, you can use the following type of construction (this is bash syntax):
smartstat=$(($? & 8))
This looks at only at bit 3 of the exit status $? (since 8=2^3). The shell variable $smartstat will be nonzero if SMART status check returned "disk failing" and zero otherwise.
This bash script prints all status bits:
status=$?
for ((i=0; i<8; i++)); do
echo "Bit $i: $((status & 2**i && 1))"
done