Debian – How to stop waking all attached drives on reboot / deactivating swap

debianpower-managementswap

A fresh install of Debian 6.0.6 for a system has 13 SATA drives attached. 12 refurbished WD-10EARS drives are yet unpartitioned. 1 WD1500BLFS drive is configured for OS and swap. Swap partition is configured on /dev/sda5 according /etc/fstab

root@debian:~# cat /etc/fstab | grep swap
# swap was on /dev/sda5 during installation
UUID=641cc8ad-838d-4e92-8c2c-0b73359a5aa3 none            swap    sw              0       0

Because the 12 drives have no disk activity, the drive state goes from "active/idle" to "standby" after a while.

root@debian:~# hdparm -C /dev/sdm

/dev/sda:
 drive state is:  active/idle

root@debian:~# hdparm -C /dev/sdm

/dev/sda:
 drive state is:  standby

When issueing a reboot command the console shows "Deactivating swap..." and then staggered all 12 drives start to spinup as verified by sound and power consumption. Having a drive state change from standby to active can take up to 30 seconds. In other words a reboot now takes between 3 and 7 minutes. How long would a reboot take when 70 drives are attached!

Update #1
The issue is related to "sd" (storage device) that wishes to "Synchronizing SCSI cache" on each drive.

How to stop changing all drives its state from "standby" to "active" on reboot (most likely caused by the "deactivating swap" process)?

# uname -mrsn
Linux debian 2.6.32-5-amd64 x86_64

Best Answer

After changing to backports kernel 3.2.0-0.bpo.3-amd64 there is no longer a wake of all drives between issuing reboot and message Will now restart. appears, with or without swap being enabled.

Note that the console "end_request I/O error, dev sdb, sector {0, 8, 16, 128, 4096}" error messages are still there when the drives are in standby state.

Update #1

The "Synchronizing SCSI cache before rebooting" issue re-appears in 3.2.0-0.bpo.4-amd64. Although both seem to share the same version of the mpt2sas module:

# modinfo /lib/modules/3.2.0-0.bpo.{3,4}-amd64/kernel/drivers/scsi/mpt2sas/mpt2sas.ko | grep ^version
version:        10.100.00.00
version:        10.100.00.00

Update #2

The issue doesn't seem to be kernel and storage module related. After changing back to kernel 2.6.32-5-amd64, setting all drives to standby, and commanding a reboot, there were no "Synchronizing SCSI cache", no drive spin ups, and therefore no delays.

Update #3

When turning off write cache hdparm -W0 /dev/sd? and flushing the write cache with sync && sdparm --command=sync /dev/sd? && sleep 1 and finally setting the drive to standby using hdparm -y /dev/sd? then there is no "Synchronizing SCSI cache" for every drive after running reboot and seeing output "Mounting root filesystem read-only...done." and "Will now restart." when using:

  1. Linux debian 2.6.32-5-amd64 #1 SMP Sun Sep 23 10:07:46 UTC 2012 x86_64
  2. Linux debian 3.2.0-0.bpo.3-amd64 #1 SMP Thu Aug 23 07:41:30 UTC 2012 x86_64

Kernel 3.2.0-0.bpo.4-amd64 is faulty and does "Synchronizing SCSI cache" for every drive on every reboot.

Related Question