You are not logged in.

#1 2012-01-28 21:58:02

technolog
Member
From: Europe / Slovenia / Grosuplje
Registered: 2012-01-28
Posts: 117

hdparm -Y /dev/sdb in /etc/rc.conf no effect

Hello. I have added SSD disk to my laptop (/dev/sda), but I have kep old HDD (/dev/sdb).

Because HDD is rarely used, I decided to spare some power by putting this HDD to rest. So I checked out the command in terminal:

sudo hdparm -Y /dev/sdb

It worked. However, when I added

hdparm -Y /dev/sdb

to the bottom of /etc/rc.conf file, nothing happens.

Why is this and how can I debug that? Can I somehow prevent HDD spinning up in the first place?

Offline

#2 2012-01-28 22:34:43

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: hdparm -Y /dev/sdb in /etc/rc.conf no effect

/etc/rc.conf is very much the wrong place to put arbitrary commands. Perhaps you meant to use /etc/rc.local, or a sysinit hook.

Last edited by falconindy (2012-01-28 22:35:01)

Offline

#3 2012-01-29 09:28:03

technolog
Member
From: Europe / Slovenia / Grosuplje
Registered: 2012-01-28
Posts: 117

Re: hdparm -Y /dev/sdb in /etc/rc.conf no effect

Oh, sorry. Of course I meant /etc/rc.local. I don't konw why I had typed /etc/rc.conf

Here is the output:


[rok@rok-laptop ~]$ cat /etc/rc.local
#!/bin/bash
#
# /etc/rc.local: Local multi-user startup script.
#

# Let SSD handle data scheduling on it's own
echo deadline > /sys/block/sda/queue/scheduler
echo 1 > /sys/block/sda/queue/iosched/fifo_batch

# Turn off auxilary disk
hdparm -Y /dev/sdb

Are there any other startup files I can try putting that line into?

Offline

#4 2012-01-29 09:38:40

siriusb
Member
From: Hungary
Registered: 2010-01-01
Posts: 422

Re: hdparm -Y /dev/sdb in /etc/rc.conf no effect

You can try with

(sleep 30 && hdparm -Y /dev/sdb) & 

Maybe a process in your DE wakes up the drive if it is in sleep too early.
rc.local is a perfect place for this.

Offline

#5 2012-01-29 09:46:17

technolog
Member
From: Europe / Slovenia / Grosuplje
Registered: 2012-01-28
Posts: 117

Re: hdparm -Y /dev/sdb in /etc/rc.conf no effect

Thanks! That did it just perfectly. Nice idea.

I guess there persists only one question - is it possible not to spin up the disk in the first place? But I guess this is not really vital and I guess I'd take a lot of effort, as that'd probably involve BIOS tweaking.

Thanks again, If anyone has an idea, I'd be happy to hear it smile

Offline

#6 2012-01-29 10:43:15

siriusb
Member
From: Hungary
Registered: 2010-01-01
Posts: 422

Re: hdparm -Y /dev/sdb in /etc/rc.conf no effect

You're welcome.

It'll spin up, I don't think you can prevent it. If you use this for backup, just buy an USB3.0 docking station and USB3.0 PCI card. Safer if backup hdd is stored separately. Or if it's a SATA disk and AHCI is enabled you can hot swap, I mean you can attach power cable only when needed.

Offline

#7 2012-01-29 11:56:50

technolog
Member
From: Europe / Slovenia / Grosuplje
Registered: 2012-01-28
Posts: 117

Re: hdparm -Y /dev/sdb in /etc/rc.conf no effect

One more thing.

Does there exist startup file which is invoked after the start of X server instead of last boot stage? I have tried ~/.xinitrc but doesn't work.

The comand you provided has one weak point: I have to log in and startx within 30 seconds, because startx (gdm) wakes up disk. If I fail to do that fast, command has no effect.

Thanks for the help, I'm new to arch linux, but not to linux in general, and I'm catching up on some things.

Offline

#8 2012-01-29 12:46:07

siriusb
Member
From: Hungary
Registered: 2010-01-01
Posts: 422

Re: hdparm -Y /dev/sdb in /etc/rc.conf no effect

Is there any reason booting into console instead of X?
Start X at Boot

Problem is that hdparm needs root privilage to run. So if you want that command invoked in ~/.xinitrc you have to write a script which asks for root password then execute hdparm.
There may be other ways I'm not aware of, but I'm not a guru either. smile

Don't give up I learnt a lot about linux when I installed arch first and keep learning. My experience says arch community is very helpful and these people created an excellent and outstanding wiki.

Offline

#9 2012-01-29 14:49:28

technolog
Member
From: Europe / Slovenia / Grosuplje
Registered: 2012-01-28
Posts: 117

Re: hdparm -Y /dev/sdb in /etc/rc.conf no effect

I have come up with solution:

(
	until [ "$(pidof X)" ]; do
		sleep 1
	done
	sleep 10
	hdparm -Y /dev/sdb
) &

Is solution like this acceptable?

Offline

#10 2012-01-29 16:05:14

meph
Member
Registered: 2011-06-06
Posts: 160

Re: hdparm -Y /dev/sdb in /etc/rc.conf no effect

siriusb wrote:

Problem is that hdparm needs root privilage to run. So if you want that command invoked in ~/.xinitrc you have to write a script which asks for root password then execute hdparm.
There may be other ways I'm not aware of, but I'm not a guru either. smile

You can work around that with proper sudo configuration. Say, this should work for whole wheel group to be able to use sudo hdparm without root password:

%wheel ALL = NOPASSWD: /sbin/hdparm

Obviously could be done for other groups as well. Just an example.



technolog wrote:

I have come up with solution:

(
	until [ "$(pidof X)" ]; do
		sleep 1
	done
	sleep 10
	hdparm -Y /dev/sdb
) &

Is solution like this acceptable?

edit, nevermind, I'm just dumb tongue looks good
edit2 tongue actually... a script put this way will ask for a pid of a process, on whose creation it is waiting. Either I'm very very tired (which I am), or the logic is a bit faulty.

Last edited by meph (2012-01-29 16:08:24)


Running arch is like raising a puppy - if you spend a bit of time with it each day and do just a bit of training you'll end up with the most loyal partner you could want; if you lock it in a room and don't check on if for several days, it'll tear apart your stuff and poop everywhere.

Offline

#11 2012-01-29 16:41:32

technolog
Member
From: Europe / Slovenia / Grosuplje
Registered: 2012-01-28
Posts: 117

Re: hdparm -Y /dev/sdb in /etc/rc.conf no effect

The logic behind this script is:

1. wait until there exists proces named X
      (the pidof is actually used only to check if process exists, the result is not used anywhere else)
2. sleep 10 seconds for x to fully initialize
3. turn off the hard disk

siriusb wrote:

You can try with

(sleep 30 && hdparm -Y /dev/sdb) & 

Maybe a process in your DE wakes up the drive if it is in sleep too early.

Is it possible to configure X or GDM not to wake the -Y ed disk? I googled, found nothing. I guess that would be solving the problem the arch way. smile

Offline

#12 2012-01-29 21:19:52

meph
Member
Registered: 2011-06-06
Posts: 160

Re: hdparm -Y /dev/sdb in /etc/rc.conf no effect

I just realized I might suffer from an OCD. After a very long day at work and coming home tired to death, instead of dying into pillow I go and check Arch forums wink You are right, makes sense.

How about this. Get sg3_utils from extra repo, and do

sudo sg_start --stop --readonly /dev/sdb

That *should* stop the drive for good, until you wake it up with sg_start --start, or reboot. It's a tool originally made for generic SCSI drives, but it *should* work on SATA drives as well. I can't test it myself though, as I'm nowhere near a linux box with more than 1 physical drive. Can someone confirm?


Running arch is like raising a puppy - if you spend a bit of time with it each day and do just a bit of training you'll end up with the most loyal partner you could want; if you lock it in a room and don't check on if for several days, it'll tear apart your stuff and poop everywhere.

Offline

#13 2012-01-30 16:27:47

technolog
Member
From: Europe / Slovenia / Grosuplje
Registered: 2012-01-28
Posts: 117

Re: hdparm -Y /dev/sdb in /etc/rc.conf no effect

Your command has the same effect as hdparm -Y, gnome is able to wake the disk up again.

I managed to google this command:

echo 1 > /sys/block/sdb/device/delete

Which powers down device completely, but I am not able to undo that change (except reboot).

Offline

Board footer

Powered by FluxBB