script to disable writeback when a drive is idle

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I have two stacks of a HDD with a bcache SSD in front of it in writeback mode. I have made the following quick and dirty script to disable writeback when the HDD is in standby. I hope it helps somebody:

# cat writeback.sh
#!/bin/bash

function sdbGetState()
{
        hdparmstr=$(hdparm -C /dev/sdb | grep drive)
    echo $hdparmstr
}

function sddGetState()
{
        hdparmstr=$(hdparm -C /dev/sdd | grep drive)
        echo $hdparmstr
}

strSdb=$(sdbGetState)
echo $strSdb

strSdd=$(sddGetState)
echo $strSdd


if [ "$strSdd" = 'drive state is: active/idle' ];
then
    echo 1 > /sys/block/bcache0/bcache/writeback_running
    echo active
else
    echo 0 > /sys/block/bcache0/bcache/writeback_running
    echo idle
fi

if [ "$strSdb" = 'drive state is: active/idle' ];
then
        echo 1 > /sys/block/bcache1/bcache/writeback_running
        echo active
else
        echo 0 > /sys/block/bcache1/bcache/writeback_running
        echo idle
fi

---

Take your mailboxes with you. Free, fast and secure Mail & Cloud: https://www.eclipso.eu - Time to change!





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux ARM Kernel]     [Linux Filesystem Development]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux