View previous topic :: View next topic |
Author |
Message |
solamour l33t


Joined: 21 Dec 2004 Posts: 727 Location: San Diego, CA
|
Posted: Mon Dec 19, 2022 9:33 pm Post subject: [Solved] Q: Use UUID with hdparm? |
|
|
I use hdparm to spin down an external disk after the disk is idle for a while.
Code: | [/etc/conf.d/hdparm]
sdc_args="-S 241" |
Whenever the system boots, the disk gets a random letter; it's usually "sdc", but often it's "sdb" or "sde".
Is there a way to assign a disk with a specific UUID to a certain letter? Or better yet, how do I configure hdparm to look for a disk with a specific UUID?
__
sol
Last edited by solamour on Mon Dec 19, 2022 10:34 pm; edited 1 time in total |
|
Back to top |
|
 |
alamahant Advocate

Joined: 23 Mar 2019 Posts: 3953
|
Posted: Mon Dec 19, 2022 10:06 pm Post subject: |
|
|
Plz use
Code: |
hdparm <> /dev/disk/by-id/xxxxxxxxxxxxx
|
but not in /etc/conf.d/hdparm.
Find the correct entry by
Code: |
ls -l /dev/disk/by-id
|
Use it either in an /etc/local.d/hdparm.start script or a cronjob @reboot.
Code: |
hdparm -S 241 /dev/disk/by-id/xxxxxxxxxxxxx
|
_________________
 |
|
Back to top |
|
 |
Hu Administrator

Joined: 06 Mar 2007 Posts: 23145
|
Posted: Mon Dec 19, 2022 10:18 pm Post subject: |
|
|
The /etc/init.d/hdparm script that consumes this conf.d file is very simple. It does not support using UUIDs. It only works on block devices of a few well known paths. You might be able to use a udev rule to force the device to have a particular name. You could also consider an enhancement request to make the init script able to work with the by-id path that alamahant suggested. |
|
Back to top |
|
 |
solamour l33t


Joined: 21 Dec 2004 Posts: 727 Location: San Diego, CA
|
Posted: Mon Dec 19, 2022 10:34 pm Post subject: |
|
|
I put hdparm command with "by-uuid" in "local" script, which seems to work fine.
Code: | [/etc/local.d/local.start]
hdparm -S 241 /dev/disk/by-uuid/... |
Thanks everyone for taking time to share your knowledge and suggestions.
__
sol |
|
Back to top |
|
 |
sublogic Guru


Joined: 21 Mar 2022 Posts: 316 Location: Pennsylvania, USA
|
Posted: Mon Dec 19, 2022 10:49 pm Post subject: |
|
|
The right way would be to muck with udev rules --which I have no idea how to do.
As an alternative, you could ignore the hdparm service and do it instead from a shell script in /etc/local.d . The script can run hdparm on a block device under /dev/disk/by-id/ . Use one of the entries labeled by model number and serial number. (And add the local service to the default runlevel.)
Oops, three replies while I was typing. Oh well. |
|
Back to top |
|
 |
Zucca Moderator


Joined: 14 Jun 2007 Posts: 3963 Location: Rasi, Finland
|
Posted: Tue Dec 20, 2022 8:55 am Post subject: |
|
|
sublogic wrote: | The right way would be to muck with udev rules --which I have no idea how to do. | Yes. I think so.
A udev rule which (if possible) matches all the external drives, and then runs a command to adjust whatever user wants.
A more brute forced way would be write an udev rule to catch all drives, then a run a script to determine if the drive is a) spinning one b) external.
Third option could be to use inotify to watch /dev/ , but I don't know if it can work on devfs. Also it's a dirty hack if it works. _________________ ..: Zucca :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
 |
|