I have an older laptop. A few years ago, I installed Fedora along with opensuse (I think it was 11.4 at that time).
Fedora saw the hard drive as “/dev/sdb” if there was a USB flash drive, and otherwise saw it as “/dev/sda”. Opensuse did not have that “problem”.
There really isn’t a way to force the device name.
What you instead need to do, is use a permanent name with “hddtemp”.
Here’s an example. On my current system, the partitions on “/dev/sda” have device id of the form:
/dev/disk/by-id/ata-WDC_WD10EZEX-75ZF5A0_WD-WCC1S1730155-part2
where that final digit (“2” in the example) is the partition number.
I can refer to the disk itself as “/dev/disk/by-id/ata-WDC_WD10EZEX-75ZF5A0_WD-WCC1S1730155” (I just removed the “-part2” from the end of the name.
If I use “ls” to check that device identifier, I get:
% ls -l /dev/disk/by-id/ata-WDC_WD10EZEX-75ZF5A0_WD-WCC1S1730155
lrwxrwxrwx 1 root root 9 Dec 14 15:37 /dev/disk/by-id/ata-WDC_WD10EZEX-75ZF5A0_WD-WCC1S1730155 -> ../../sda
so you can see that it is a link to “/dev/sda”. But the device ID path won’t change if a USB is plugged in.
Your solution is to find the appropriate device id, and use that in your “hddtemp” command. Having used it once, you can then go back to using bash history. Or you could create a bash alias or a shell script that uses the device ID.
To find the ID, use the following command:
ls -l /dev/disk/by-id/* | grep -v .-part
then look for the lines that contain “…/…/sda” (or “…/…/sdb” depending on the current name). You may find that there are several possible choices, so just pick one.