You are not logged in.

#1 2016-07-26 21:55:16

p3r1c
Member
Registered: 2016-07-26
Posts: 3

hdparm - putting a drive directly to sleep after boot

Hi guys! I'm new to the forums, but I've been using Arch for several months now (I still have a lot of things to learn).
I am very grateful for this distro, and all the benefits and freedom it brings to it's users.

Anyway, here is my problem.

I've installed Mac OS X (hackintosh) on my old WD hdd which is 80gigs. HDD is very old and it's making a lot of noise, so I decided that I don't need it when I'm running Arch from my ssd.
I tried hdparm to put it on sleep and it worked. Then I tried running hdparm.service and putting hdd to sleep on boot, and it also worked. The problem is, when I login to my gnome session something triggers hdd back on again.
Now the apps that I have manually added to autostart are skype and guake terminal, nothing else.

At first, I created systemd service which runs hdparm on boot (like in hdparm - ArchWiki). Then I tried to add some commands by myself, and the only workaround I found out was to have sleep for around 20 seconds, but if I don't log in in that 20 seconds (before the drive spins down), it will wake up after login. It's an ugly solution to my problem, I tried to search the forums, and google for answers, but it seemed to me I couldn't find the solution.

Thank you in advance! I must say as a newcomer to Linux world that I love the idea of the open source communities! :-)

Offline

#2 2016-07-26 22:04:29

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,772

Re: hdparm - putting a drive directly to sleep after boot

I am going to leave this thread alone as long as it stays away from the topic of hackintosh.  https://wiki.archlinux.org/index.php/Co … licitation
It really has nothing to do with this thread and I really wish you had not brought it up in the first place.

Thanks.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2016-07-26 22:39:13

p3r1c
Member
Registered: 2016-07-26
Posts: 3

Re: hdparm - putting a drive directly to sleep after boot

I am very sorry. I wanted to be detailed as possible because the disk is journaled file system formatted because of a mac (I don't know if that has something to do with my hdd waking up), I also wanted to let you know that I'm coming from a PC (you're right it's irrelevant).
Once again, I apologize.

Offline

#4 2016-07-26 22:51:18

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,772

Re: hdparm - putting a drive directly to sleep after boot

No worries.  Oh, and welcome to Arch Linux.
And, I do appreciate the effort at being through in the presentation of the problem.  We do take a stand where it comes to honoring copyright.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#5 2016-07-27 07:37:35

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: hdparm - putting a drive directly to sleep after boot

Try hiding every partition on your HDD with this udev rule: https://wiki.archlinux.org/index.php/Ud … partitions

That should prevent at least gnome from seeing and trying to access the disk.

Offline

#6 2016-07-27 09:44:48

p3r1c
Member
Registered: 2016-07-26
Posts: 3

Re: hdparm - putting a drive directly to sleep after boot

Thank you for your suggestion!
Unfortunately it didn't work. I've installed udisks2, and have applied the udisks ignore rule, same thing happens every time when I login disk goes from standby to active/idle state and I can hear it's noise.

edited: Should I disable polling for the disk. I saw at udisks manual something like udisks --inhibit-polling /dev/sr0 ?

Last edited by p3r1c (2016-07-27 09:48:21)

Offline

#7 2016-07-27 11:55:49

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: hdparm - putting a drive directly to sleep after boot

p3r1c wrote:

Thank you for your suggestion!
Unfortunately it didn't work. I've installed udisks2, and have applied the udisks ignore rule, same thing happens every time when I login disk goes from standby to active/idle state and I can hear it's noise.

did you use UDISKS_IGNORE for udisks2, and not UDISKS_PRESENTATION_HIDE which only works with old udisks?

edited: Should I disable polling for the disk. I saw at udisks manual something like udisks --inhibit-polling /dev/sr0 ?

I think that only works with udisks, not udisks2. At least i don't see that option on 'man udisks' with udisks2 installed.
I guess you could try if 'udisksctl power-off' made any difference though.

Offline

#8 2024-04-13 01:23:54

Striffly
Member
Registered: 2023-07-03
Posts: 2

Re: hdparm - putting a drive directly to sleep after boot

I know this is an old post, but I found a simple solution for this case.
With this solution, disks spindown after logging into the Gnome session. I put a short delay in case any program queries my disks after login, then I shut them down.
Your user needs to be in the sudo group.

Step 1: Allow calling hdparm without a password for sudo users

# visudo

# No password for hdparm
%sudo ALL=(ALL:ALL) NOPASSWD: /usr/bin/hdparm

Step 2: Add a user systemd service that calls after login

# ~/.config/systemd/user/hdparm.service
# Use `ls -l /dev/disk/by-id/` to list disks by id. Furthermore, by using `/bin/bash` in ExecStart, you can spindown multiple disks simultaneously.

[Unit]
Description=Put HDD to sleep mode immediately
After=graphical-session.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/bin/sleep 10
ExecStart=/bin/bash -c 'sudo /usr/bin/hdparm -q -y /dev/disk/by-id/XXXXXXXXX && sudo /usr/bin/hdparm -q -y /dev/disk/by-id/XXXXXXXX'

[Install]
WantedBy=graphical-session.target

Step 3 : Activate service

systemctl --user enable hdparm.service

Unfortunately, I haven't managed to ensure that the service is called from the root user, because in that case, it triggers as soon as GDM starts.
The major downside of this solution is that it's possible to call hdparm without a password. Perhaps there's a more secure solution, where, for example, the absence of a password is only allowed within the context of a systemd service.

Last edited by Striffly (2024-04-13 01:32:12)

Offline

Board footer

Powered by FluxBB