# RAID-5 Power Management

## el Mango

Hi,

   I'm having a bit of trouble getting power management to work correctly with my RAID-5 array. I can get the drives to spin down, but they spin right back up again about 30 seconds later. I think this has something to do with the dirty writes feature in linux, but i'm not totally sure.

   I emerged laptop-mode-tools then ran lm-profiler to see what is accessing my disk. The output looks something like this:

 *Quote:*   

> ...
> 
> Accesses at 344/600 in run: md5_raid5
> 
> Accesses at 345/600 in run: md5_raid5
> ...

 

I realize that md5 is the name of my raid5 array device and _raid5 refers to the fact that this particular array uses raid5. When searching google, I can't find a particularly clear description of what md*_raid5 actually does.

Is there a way to prevent md5_raid from accessing the disks so often? What is md5_raid doing?

----------

## el Mango

I tried setting hdparm to use -q -S244 for all SATA drives. Should I try setting it on the md5 raid5 array instead?

I don't see how that could help because md5_raid5 will still access the array every few seconds. I had an Infrant ReadyNAS that ran linux and it was able to spin down the drives when not in use (for as long as necessary until it was next accessed). I'd like to mimic this behavior. If anyone can help, I would greatly appreciate it.

----------

## Mad Merlin

md5_raid5 is the kernel thread that serves all requests to that particular RAID device. If possible, you should see what's accessing /dev/md5, rather than the disks themselves.

----------

## el Mango

It's that kernel thread that causes the drives to spin up again, I think. I'm not positive, but that's what lm-profiler says.

Does anyone know a way to configure the kernel, or hdparm, or etc to get my raid5 array to spin down when not being accessed by usermode apps such as samba or apache?

----------

## el Mango

I'm still having trouble with this. Does ANYONE know?

Do I need to use a special kernel version perhaps?

----------

## adsmith

have you tried setting laptop_mode, so writes/sync happen in bursts when possible?

try

vm.laptop_mode = 15

in /etc/sysctl.conf

and run sysctl -p

----------

## Cyker

I don't think you can make the array spin down, not without compromising its ability to recover from a power failure...

Like ext3 and some other journalling filesystems, the RAID5 in Linux executes a commit at a set interval, even if nothing has been written to the array.

On mine, I've tried to sync the ext3 journal commit and the RAID commit so that they occur close to each other, but the only way to 'disable' these commits are to increase the interval to some ludicrously large number.

However, this probably creates problems of its own...

----------

## el Mango

This is disappointing, because my old Infrant ReadyNAS NV+ was able to spin down the drives just fine.

If anyone thinks of a way for me to spin down the drives without compromising my data integrity, I would GREATLY appreciate it. Trying to save some money on the power bill (this system runs 24/7).

----------

## adsmith

today's article is kerneltrap reminded me:  Do you have the noatime option set on your filesystem?  IIRC, even if files are cached in memory, atime would be updated, so your disk would spin up and be written.

----------

## Akkara

Are you using reiserfs?  I had noticed that reiser seems to like to write to disks every few seconds even with laptop mode turned on.  When I unmounted the reiser partition it seemed to quiet down a lot.  I didn't have a chance to investigate further whether it really was reiser or something else that was merely accessing that partition.

----------

## adsmith

Another diagnostic to do is to turn on block-dump and watch your logs (which you should set to write to a tmpfs, so you don't keep watching it write its own logs!)

echo 1 > /proc/sys/vm/block_dump

----------

