Products > Embedded Computing

Removing power from idle hard drives via IO pin and FET from the kernel?

(1/4) > >>

cedric!:
I'm building a NAS. It contains large hard drives, with smaller SSD's as read/write cache in front of them. [1] The hard drives only spin up when the write cache is full, or when a read request comes in that's not in the cache. This results in the hard drives being almost always spun down. I use older drives, that use 10W while spinning, and about 1 watt while being idle.

I would like to completely remove the power from the idle harddrives, and power them back up when they are needed again. I'm thinking about using smart fets [2,3] for this, controlled by output pins on my single board computer (rockpi-3A)

Can the Linux kernel be configured to raise an IO pin when a harddrive must spin up, and lower the pin again after the drive has returned to idle?
Can the Linux kernel be configured to deal with suddenly appearing drives just after they receive power?
What's the best community to ask for guidance on writing a linux driver that does this?

My hardware:
RockPi 3A version 1.31 running Armbian https://wiki.radxa.com/Rock3/3a
M.2 e-key to PCIE+USB adapter: https://nl.aliexpress.com/item/32998283993.html 12
PCI-E to sata bridge: https://nl.aliexpress.com/item/1005003060227206.html 5
4 sata hard drives and 4 sata ssd's connected to the PCI-E to sata bridge

References:
[1] arch linux bcache: https://wiki.archlinux.org/title/Bcache#Situation:_3_hard_drives_and_3_read/write_cache_SSD's
[2] high side switch: https://nl.farnell.com/on-semiconductor/fdc6330l/ic-mosfet-dual-np-supersot-6-6/dp/9844864
[3] high side switch: https://nl.farnell.com/infineon/bts50902ekaxuma1/power-load-sw-aec-q100-13-5v-soic/dp/2709907

Berni:
Both linux and windows can handle a HDD disappearing and showing up again.

The whole trick behind it is that the SATA port must support hotplug. Most modern motherboards support that, but usually needs to be turned on in the BIOS. Once that is on, you can just plug a drive into SATA and it simply shows up. Tho on linux it might not automatically mount the filesystem when the drive shows up, but there are ways to make that automatic too.

Getting the linux kernel to automatically spin them up tho might be tricky since once you disconnect the drive, the filesystem will also unmount. So there is nothing to access at that point if the filesystem is not there. You also have to be careful disconnecting the drives as linux might not have flushed all the data in RAM buffers down onto the disk. You have to gracefully unmounted the filesystem or at least manually tell it to sync before cutting power to a HDD.

Id say first try to manually do it by unplugging disks live then plug them in again, seeing if your SSD caching solution can handle the drives disappearing at all.

If that works then id say find out a way to check how full the SSD cache is, then have a script running in the background that powers on the drives every few days or when the SSD write cache is full so that you can flush data down to HDDs.

But in my opinion id say don't bother. The couple of watts you might save is not worth the effort. Even after the energy prices going trough the roof due to the world situation we still get 0.15€ per kWh. So 1W per year costs 1.30€. So if i calculate the cost of my man hours required to get this power saving thing to work, it is cheaper to just pay for the power cost to run it.

magic:
In Linux you will need to unmount the filesystem before powering down and then mount it after powering back up. There is no way of knowing that the disk that re-appears is the same disk which disappeared and that it hasn't been modified on other machine in the meantime. If you simply power cycle a disk with a mounted filesystem on it, a "phantom" device associated with the old disk will remain in the system, it will remain mounted, and the filesystem will I/O error on every operation other than unmounting. It will not be automatically switched over to the newly connected disk, even if it's the same disk.

I highly recommend using "native" HDD power saving features instead, such as standby on command or after a preset time of inactivity. Consider the hdparm utility and -y, -Y, -S options in particular. These features spin the disk down, saving a majority of its power, but they keep the electronics powered up maintaining connection so Linux knows that it is still the same disk being there all the time. Filesystems can stay mounted and as soon as any access is made, the disk will be automatically woken up from standby as if nothing happened. The access will only need to wait a few seconds for the disk to spin up.

DiTBho:
disk cache on both disk and linux needs to be flushed

dobsonr741:
Are you equipped to write kernel mods, compile and test them? To deploy them again and again as the OS updates coming in? And test again. With your live NAS containing g all your data. Would you trust your data on a system concept (power to to NS drives) no one else in the NAS scene produced? Just asking, IMO it’s a high risk to your data, and the data is presumably you care about.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod