Some time ago, I moved to OpenSolaris as the main OS for my laptop. One of the first things that I noticed was the annoying noise of my hard disk parking the heads quite often. This issue is due to the default apm configuration of the disk. For those that don't know, the Advanced Power Management, or apm, is one of the configuration features available with modern hard disks.
As the Infernal Click of Death, as I call it , didn't seem very healthy for my disk, I tried to get ride of it. This task would be easier to achieve if I'd be running Linux. I could use the hdparm utility to configure this and many other interesting features of my hard disk. In fact, my previous Debian automatically configured the apm level of my disk to 254 out of the box in one of its rc's, eliminating the noise without further intervention.
But now I'm running OpenSolaris, and things are quite different. There is a good post about this from my friend Sergio. He gives two options, but neither of the two were suitable for me for different reasons:
- Download some hard disk's manufacturer tools to disable the apm feature. Well, my disk is a Seagate ST9320421AS and, although there are some utilities on the manufacturer's web page, I haven't found any tool capable of doing such thing.
- Replace the driver with the one he modified. Unfortunately, my disk is SATA, not ATA, and the driver that OpenSolaris uses to manage it it's not the same, so I could not apply his fix.
As my disk is a SATA disk, I have to talk to it through SCSI commands. All the linux utilities (hdparm, sg utils...) use the SCSI command "ATA PASS THROUGH". This command is great, cause it allows you to encapsulate ATA commands inside the SCSI command you need to send to the disk, so you get access to all of your hard disk's features.
Unfortunately again, Solaris sata driver does not implement this command (neither 12 bytes CDB nor 16 bytes CDB version) and that's why this utilities are not easy to port to Solaris. They compile and build without problems, but if you use them you'll get a bunch of "Illegal SCSI command" stuff on your logs. Why Sun people is not implementing this command? Well, I really don't know, though I personally think they should...
Anyway, having a look at the OpenSolaris SATA driver, I found implemented another interesting feature, the "Advanced Acoustic Management" or aaa. This feature is interesting because it's very similar to the apm, so with minimal effort I was able to tweak the sata driver to implement apm instead of aaa. As the feature is implemented through SCSI page 0x30, you will also need a utility to send the SCSI MODE SENSE & MODE SELECT commands to activate it.
If you have the same problem, you can try my modified sata driver, and use it at your own risk (don't blame me if your disk explode, etc, etc...) Then you can use sgutils to send the page to adjust the apm level or to disable at all. I've compiled and packaged sg3utils for OpenSolaris (installs in /usr/local) in case you need it.
So these are the steps:
0. I recommend you to back up your os. Can be as simple as creating a new be or just snapshoting your root zfs. I'm using OpenSolaris 2008.11, so I compiled the driver from the build 101a. For me is working, but who knows...
1. Copy sata32 to /kernel/misc/sata (32 bits driver version).
2. Copy sata64 to /kernel/misc/amd64/sata (64 bits driver version)
3. Reboot your system.
4. If it boots you can configure the apm levels of your disk with sg3utils:
sg_wr_mode -v -l 6 -p 30 --contents=30,3,0,0,0 /dev/rdsk/c4t0d0s0