All Projects → adelolmo → Hd Idle

adelolmo / Hd Idle

Licence: gpl-3.0
Hard Disk Idle Spin-Down Utility

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to Hd Idle

Zpan
A self-hosted cloud disk base on the cloud storage./ 一个基于云存储的网盘系统,用于自建私人网盘或企业网盘。
Stars: ✭ 765 (+516.94%)
Mutual labels:  disk
Write
Write data to the file system, creating any intermediate directories if they don't already exist. Used by flat-cache and many others!
Stars: ✭ 68 (-45.16%)
Mutual labels:  disk
Cra Build Watch
A script for create-react-app that writes development builds to the disk
Stars: ✭ 110 (-11.29%)
Mutual labels:  disk
Ruby Stats
Fetch statistics about your machine using Ruby
Stars: ✭ 5 (-95.97%)
Mutual labels:  disk
Ansible Manage Lvm
Stars: ✭ 55 (-55.65%)
Mutual labels:  disk
Xfce4 Genmon Scripts
🐭 XFCE panel generic monitor scripts
Stars: ✭ 69 (-44.35%)
Mutual labels:  disk
Zenith
Zenith - sort of like top or htop but with zoom-able charts, CPU, GPU, network, and disk usage
Stars: ✭ 673 (+442.74%)
Mutual labels:  disk
Iocipher
make non-root mountable encrypted disk shares
Stars: ✭ 124 (+0%)
Mutual labels:  disk
Diskqueue
A thread-safe, multi-process(ish) persistent queue library for .Net and Mono
Stars: ✭ 66 (-46.77%)
Mutual labels:  disk
Bplustree
An efficient, conscise, and simple implementation of a purely on-disk B+ Tree data structure
Stars: ✭ 92 (-25.81%)
Mutual labels:  disk
Node Ntfs
Windows NT File System (NTFS) file system driver
Stars: ✭ 18 (-85.48%)
Mutual labels:  disk
Multibootusb
Create multiboot live Linux on a USB disk...
Stars: ✭ 1,042 (+740.32%)
Mutual labels:  disk
Ezio
BT-based Disk Deployment tool
Stars: ✭ 77 (-37.9%)
Mutual labels:  disk
Cleanmywechat
自动删除 PC 端微信缓存数据,包括从所有聊天中自动下载的大量文件、视频、图片等数据内容,解放你的空间。
Stars: ✭ 816 (+558.06%)
Mutual labels:  disk
Btree4j
Disk-based B+-tree written in Pure Java
Stars: ✭ 122 (-1.61%)
Mutual labels:  disk
Dua Cli
View disk space usage and delete unwanted data, fast.
Stars: ✭ 744 (+500%)
Mutual labels:  disk
Ruby Vmstat
A focused and fast library to gather memory, cpu, network, load avg and disk information
Stars: ✭ 68 (-45.16%)
Mutual labels:  disk
Distributed framework
python通用分布式函数调度框架 pip install function_scheduling_distributed_framework
Stars: ✭ 123 (-0.81%)
Mutual labels:  disk
Crossplatformdisktest
Windows, macOS and Android storage (HDD, SSD, RAM) speed testing/performance benchmarking app
Stars: ✭ 123 (-0.81%)
Mutual labels:  disk
Yandex
PHP SDK для работы с Яндекс Диском yandex disk
Stars: ✭ 82 (-33.87%)
Mutual labels:  disk

hd-idle

Reimplementation of Christian Mueller's hd-idle with some extra features.

hd-idle is a utility program for spinning-down external disks after a period of idle time. Since most external IDE disk enclosures don't support setting the IDE idle timer, a program like hd-idle is required to spin down idle disks automatically.

Index

Extra features

List of extra features compared to the original hd-idle:

Support ATA commands

The implementation of hd-idle written by Christian Mueller relies on the SCSI api to work. When listing the drives by id, disks starting with usb stop using the original implementation, but disk starting with ata do not.

$ ls /dev/disk/by-id/

ata-WDC_WD40EZRX-
ata-WDC_WD50EZRX-
usb-WD_My_Book_1140_

hdparm on the other hand stops always the drives without any problems. It uses ATA api calls to set disk on standby. hd-idle comes with ATA commands support to replicate hdparm's api calls.

Monitor the skew between monitoring cycles

Identify if the sleep took longer than expected and reset the spun down flag if it waited too long for the main loop sleep. This should capture suspend events as well as excessive machine load.

Resolve symlinks in runtime

hd-idle can resolve disk symlinks also in runtime. Disks added after application's start won't be hidden.

Log disk spin up

Show in standard output when disks spin up.

Install

There are various ways of installing hd-idle:

Precompiled binaries

Precompiled binaries for released versions are available in the releases section.

Build from source

To build hd-idle from the source code yourself you need to have a working Go environment with version 1.12 or greater installed.

You can directly use the go tool to download and install the hd-idle binaries into your GOPATH:

$ go get github.com/adelolmo/hd-idle
$ hd-idle

On Debian you can also clone the repository yourself and build using dpkg-buildpackage.

$ git clone https://github.com/adelolmo/hd-idle.git
$ cd hd-idle
$ dpkg-buildpackage -a armhf -us -uc -b

In the example above, the package is built for armhf, but you can build it also for the platforms i386, amd64, and arm64 by substituting the parameter -a.

Then install the package:

# dpkg -i ../hd-idle*.deb

Run hd-idle

In order to run hd-idle, type:

$ hd-idle

This will start hd-idle with the default options, causing all SCSI (read: USB, Firewire, SCSI, ...) hard disks to spin down after 10 minutes of inactivity.

If the Debian package was installed, after editing /etc/default/hd-idle and enabling it (START_HD_IDLE=true), run hd-idle with:

# systemctl start hd-idle

To enable hd-idle on reboot:

# systemctl enable hd-idle    

Please note that hd-idle uses /proc/diskstats to read disk statistics. If this file is not present, hd-idle won't work.

In case of problems, use the debug option -d to get further information.

Configuration

Command line options:

  • -a name
    Set device name of disks for subsequent idle-time parameters -i. This parameter is optional in the sense that there's a default entry for all disks which are not named otherwise by using this parameter. This can also be a symlink (e.g. /dev/disk/by-uuid/...)

  • -i idle_time
    Idle time in seconds for the currently named disk(s) (-a name) or for all disks.

  • -c command_type
    Api call to stop the device. Possible values are scsi (default value) and ata.

  • -s symlink_policy
    Set the policy to resolve symlinks for devices. If set to 0, symlinks are resolve only on start. If set to 1, symlinks are also resolved on runtime until success. By default symlinks are only resolve on start. If the symlink doesn't resolve to a device, the default configuration will be applied.

  • -l logfile
    Name of logfile (written only after a disk has spun up or spun down). Please note that this option might cause the disk which holds the logfile to spin up just because another disk had some activity. On single-disk systems, this option should not cause any additional spinups. On systems with more than one disk, the disk where the log is written will be spun up. On raspberry based systems the log should be written to the SD card.

Miscellaneous options:

  • -t disk
    Spin-down the specified disk immediately and exit.

  • -d
    Debug mode. It will print debugging info to stdout/stderr (/var/log/syslog if started with systemctl)

  • -h
    Print usage information.

Regarding the parameter -a:

The parameter -a can be used to set a filter on the disk's device name (omit /dev/) for subsequent idle-time settings.

  1. A -i option before the first -a option will set the default idle time.

  2. In order to disable spin-down of disks per default, and then re-enable spin-down on selected disks, set the default idle time to 0.

    Example:

    hd-idle -i 0 -a sda -i 300 -a sdb -i 1200
    

    This example sets the default idle time to 0 (meaning hd-idle will never try to spin down a disk) and default scsi api command, then sets explicit idle times for disks which have the string sda or sdb in their device name.

  3. The option -c allows to set the api call that sends the spindown command. Possible values are scsi (the default value) or ata.

    Example:

    hd-idle -i 0 -c ata -a sda -i 300 -a sdb -i 1200 -c scsi
    

    This example sets the default idle time to 0 (meaning hd-idle will never try to spin down a disk) and default ata api command, then sets explicit idle times for disks which have the string sda or sdb in their device name and sets sdb to use scsi api command.

Understand the logs

By default hd-idle only logs into the standard output. You can find them in the syslog if the application starts via service.

If you set the log file (-l flag) then the application writes extra details on it. (Check the Configuration section).

Standard log

The standard log output registers two kinds of events:

  • disk spin up
  • disk spin down
Aug  8 00:14:55 enterprise hd-idle[9958]: sda spindown
Aug  8 00:14:55 enterprise hd-idle[9958]: sdb spindown
Aug  8 00:14:56 enterprise hd-idle[9958]: sdc spindown
Aug  8 00:17:55 enterprise hd-idle[9958]: sdb spinup
Aug  8 00:28:55 enterprise hd-idle[9958]: sdb spindown

Log file

You can enable the log file with the flag -l follow by the log path. (Check the Configuration section).

This is the kind of entry shown in the log file:

date: 2020-07-29, time: 07:59:57, disk: sdc, running: 601, stopped: 76654

Explanation:

  • date and time when the disk spins up.
  • disk involved.
  • running seconds the device was running before it spun up the last time.
  • stopped seconds since last spin down. This is the time the disk was down before spinning up.

A bit more on running explained with an example:

timestamp current disk spin event running stopped
5:00 down disk activity ? ?
6:00 up go to sleep - -
9:00 down disk activity 6:00 - 5:00 = 1h (3600s) 9:00 - 6:00 = 3h (10800s)

Explanation:

At 5:00 the disk is on standby and hd-idle detects disk activity.

At 6:00 the disk is active and hd-idle determines inactivity of the disk and spins it down.

At 9:00 the disk is on standby and hd-idle detects disk activity. It writes on the log file 1h of previous disk spin up and 3h of standby.

Warning on spinning down disks

A word of caution: hard disks don't like spinning up too often. Laptop disks are more robust in this respect than desktop disks but if you set your disks to spin down after a few seconds you may damage the disk over time due to the stress the spin-up causes on the spindle motor and bearings. It seems that manufacturers recommend a minimum idle time of 3-5 minutes, the default in hd-idle is 10 minutes.

One more word of caution: hd-idle will spin down any disk accessible via the SCSI layer (USB, IEEE1394, ...) but it will NOT work with real SCSI disks because they don't spin up automatically. Thus it's not called scsi-idle and I don't recommend using it on a real SCSI system unless you have a kernel patch that automatically starts the SCSI disks after receiving a sense buffer indicating the disk has been stopped. Without such a patch, real SCSI disks won't start again and you can as well pull the plug.

You have been warned...

Troubleshot

This section covers some usual issues that user's face while using hd-idle.

SCSI response not ok

You can find information about the issue here: SCSI-response-not-ok

License

GNU General Public License v3.0, see LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].