Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] Q: Use UUID with hdparm?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
solamour
l33t
l33t


Joined: 21 Dec 2004
Posts: 727
Location: San Diego, CA

PostPosted: Mon Dec 19, 2022 9:33 pm    Post subject: [Solved] Q: Use UUID with hdparm? Reply with quote

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
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3953

PostPosted: Mon Dec 19, 2022 10:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 23145

PostPosted: Mon Dec 19, 2022 10:18 pm    Post subject: Reply with quote

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
View user's profile Send private message
solamour
l33t
l33t


Joined: 21 Dec 2004
Posts: 727
Location: San Diego, CA

PostPosted: Mon Dec 19, 2022 10:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
sublogic
Guru
Guru


Joined: 21 Mar 2022
Posts: 316
Location: Pennsylvania, USA

PostPosted: Mon Dec 19, 2022 10:49 pm    Post subject: Reply with quote

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
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3963
Location: Rasi, Finland

PostPosted: Tue Dec 20, 2022 8:55 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum