You are not logged in.

#1 2008-12-20 09:20:16

panecillo
Member
From: Spain
Registered: 2007-07-21
Posts: 44

Spun-down hard disk being spun-up just before poweroff

Hi folks,

I have two SATA disks attached to my computer, one of them is my main disk and the other one is a backup disk I bought some weeks ago. That second disk is used just once a day, so I spin-down it on boot time with sdparm, being very careful about not frequently spininng-up the hard disk.

So everything is all right until I decide to shutdown my computer: just before the "POWER OFF" text appears on screen, the second hard disk spins-up and two seconds later my computer power offs. That means an extra spin-up for my hard disk, and I would like to avoid it.

I have studied /etc/rc.shutdown, and I think I have found the reason which causes this to happen. From /etc/rc.shutdown:

  /sbin/poweroff -d -f -h -i

The -h flag puts all hard drives in standby mode, so my hard disk spins-up on that moment.

Has anyone managed to keep spinned-down disks just that way? Is there any way to tell poweroff not to put spun-down hard disk in standby?

Thank you very much.

Last edited by panecillo (2008-12-26 19:14:34)

Offline

#2 2008-12-31 22:53:33

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 694
Website

Re: Spun-down hard disk being spun-up just before poweroff

Hi,

The problem is that newer kernels send a flush and standby and some disk spun up, then "clack" sound. This is not funny.

A msg from kernel will be appear when this occurrs

        } else {
                /* XXX: This is for backward compatibility, will be
                 * removed.  Read Documentation/feature-removal-schedule.txt
                 * for more info.
                 */
                if ((qc->dev->flags & ATA_DFLAG_SPUNDOWN) &&
                    (system_state == SYSTEM_HALT ||
                     system_state == SYSTEM_POWER_OFF)) {
                        static unsigned long warned;

                        if (!test_and_set_bit(0, &warned)) {
                                ata_dev_printk(qc->dev, KERN_WARNING,
                                        "DISK MIGHT NOT BE SPUN DOWN PROPERLY. "
                                        "UPDATE SHUTDOWN UTILITY\n");
                                ata_dev_printk(qc->dev, KERN_WARNING,
                                        "For more info, visit "
                                        "http://linux-ata.org/shutdown.html\n");

                                /* ->scsi_done is not used, use it for
                                 * delayed completion.
                                 */
                                scmd->scsi_done = qc->scsidone;
                                qc->scsidone = ata_delayed_done;
                        }
                        scmd->result = SAM_STAT_GOOD;
                        return 1;
                }

                /* Issue ATA STANDBY IMMEDIATE command */
                tf->command = ATA_CMD_STANDBYNOW1;
        }

This line is bad, -h flag not needed on newer kernels since libata send a FLUSH_CACHE and STANDBYNOW.

Try remove the -h flag, but this is for IDE disk only.

More info at http://linux-ata.org/shutdown.html

I will create a ticket in the bugtracker.

Good Bye, Good Year big_smile

Last edited by djgera (2008-12-31 23:08:22)

Offline

#3 2009-01-01 10:54:23

panecillo
Member
From: Spain
Registered: 2007-07-21
Posts: 44

Re: Spun-down hard disk being spun-up just before poweroff

Hmmm, I suspected so after looking at poweroff source code: it just searched for IDE disks.

So it's a kernel issue... I'll stick to always-running disks configuration by the moment sad

Thank you very much for your reply djgera!

Offline

#4 2009-01-02 03:00:13

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 694
Website

Re: Spun-down hard disk being spun-up just before poweroff

Hi,

You can set a kernel flag to don't shutdown the harddisk, but warning when disk is on, it's the same if PC is shutdown on POST/BIOS.

The flag is at /sys/class/scsi_disk/1\:0\:0\:0/manage_start_stop for sdb, 1: shutdown, 0: no shutdown.

You can put for example a "if" in the rc.local_shutdown, that test if the harddisk is in standby (hdparm -C) and set it to 0 otherwise set to 1.

echo 0 > /sys/class/scsi_disk/1\:0\:0\:0/manage_start_stop

This backguard compatibility will be removed sad

What is your hard disk model?

For example in my case i do the same as you: secondary disk backup i put in shutdown, but my disk model don'n re-spinup when send another standby.


PD: jejeje al re leer tu mensaje veo que sos de España, hubiese escrito en español desde el comienzo, aunque creo que no se puede, no soy bueno para el inglés. De nada y saludos desde Argentina tongue

Last edited by djgera (2009-01-02 03:01:18)

Offline

Board footer

Powered by FluxBB