You are not logged in.
Hi,
I want to spin down 3 hard drives after a few minutes of idling.
It works fine with: hdparm -S 120 /dev/sdX
My question is, where is the best place to put this to make it persistent across reboots?
Thanks.
EDIT:
Also, is there anyway to check if a given drive has an idle spin down time set on it?
Last edited by tntcoda (2010-08-09 01:26:48)
Offline
Put those commands at the bottom of your /etc/rc.local file.
"sudo hdparm -I /dev/sdX" should give you the info you want.
Philosophy is looking for a black cat in a dark room. Metaphysics is looking for a black cat in a dark room that isn't there. Religion is looking for a black cat in a dark room that isn't there and shouting "I found it!". Science is looking for a black cat in a dark room with a flashlight.
Offline
The current power mode status can be checked using the -C flag.
-S 120 means 10 minutes.
Offline
Put those commands at the bottom of your /etc/rc.local file.
"sudo hdparm -I /dev/sdX" should give you the info you want.
Thanks very much.
Can I make use of that script on a non-sudo system? I always use su to get root.
Offline
lagagnon wrote:Put those commands at the bottom of your /etc/rc.local file.
"sudo hdparm -I /dev/sdX" should give you the info you want.Thanks very much.
Can I make use of that script on a non-sudo system? I always use su to get root.
You mean
su -c "hdparm -I /dev/sda1"
? Sure, you can use su, why not.
Offline
tntcoda wrote:lagagnon wrote:Put those commands at the bottom of your /etc/rc.local file.
"sudo hdparm -I /dev/sdX" should give you the info you want.Thanks very much.
Can I make use of that script on a non-sudo system? I always use su to get root.
You mean
su -c "hdparm -I /dev/sda1"
? Sure, you can use su, why not.
I just wanted to avoid entering the root password on every boot with su when the script runs, but given that I should probably just get sudo up and running Thanks.
EDIT: oops, it looks like rc.local runs as root anyway so shouldnt be an issue
Last edited by tntcoda (2010-08-09 00:51:39)
Offline
karol wrote:tntcoda wrote:Thanks very much.
Can I make use of that script on a non-sudo system? I always use su to get root.
You mean
su -c "hdparm -I /dev/sda1"
? Sure, you can use su, why not.
I just wanted to avoid entering the root password on every boot with su when the script runs, but given that I should probably just get sudo up and running Thanks.
After you get sudo, you can set all the things you want via the 'visudo' command - passwordless executing commands too.
Offline
As far as I know rc.local is ran as root so there is no need to add su or sudo, at least it works for me™ without those.
R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K
Offline
I needed to do something similar: with a funky mobo/BIOS/drive combo, one of my drives doesn't always save SMART settings, which results in bad things happening if the drive comes up with this turned off and various services (DBUS-related mostly) start sending SMART commands. Also, write-caching s/b turned off for drives with mysql database files. rc.conf would execute both of these things much too late in the boot process. I found this buried in /etc/rc.d/functions:
###############################
# Custom hooks in initscripts #
###############################
# Hooks can be used to include custom code in various places in the rc.* scripts
#
# Define a hook function in a functions.d file using:
# function_name() {
# ...
# }
# add_hook hook_name function_name
# It is allowed to register several hook functions for the same hook
# Is is also allowed to register the same hook function for several hooks
#
# Currently, the following hooks exist:
# sysinit_start: at the beginning of rc.sysinit
# multi_start: at the beginning of rc.multi
# single_start: at the beginning of rc.single
# shutdown_start: at the beginning of rc.shutdown
# sysinit_end: at the end of rc.sysinit
# multi_end: at the end of rc.multi
# single_end: at the end of rc.single
# sysinit_udevlaunched: after udev has been launched in rc.sysinit
# single_udevlaunched: after udev has been launched in rc.single
# sysinit_udevsettled: after uevents have settled in rc.sysinit
# single_udevsettled: after uevents have settled in rc.single
# sysinit_premount: before local filesystems are mounted, but after root is mounted read-write in rc.sysinit
# shutdown_prekillall: before all processes are being killed in rc.shutdown
# single_prekillall: before all processes are being killed in rc.single
# shutdown_postkillall: after all processes have been killed in rc.shutdown
# single_postkillall: after all processes have been killed in rc.single
# shutdown_poweroff: directly before powering off in rc.shutdown
#
# Make sure to never override the add_hook and run_hook functions via functions.d
Armed with this knowledge, I added a new file - /etc/rc.d/functions.d/hd_settings - with the commands and the hook setup like so:
hd_settings() {
/usr/sbin/smartctl -s on /dev/sda
/usr/sbin/smartctl -s on /dev/sdb
/sbin/hdparm -W0 /dev/sda
}
add_hook sysinit_udevsettled hd_settings
This executes the needed commands as soon as udev has settled - i.e., as soon as dev nodes are available.
Offline