> ## Content Index
> Fetch the complete content index at: https://notes.d4rkcyber.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# HDD Spindown Configuration via rc.local
- URL: https://notes.d4rkcyber.com/hdd-spindown-configuration-via-rc-local/
- Published: 2026-06-02T00:00:00.000Z
- Updated: 2026-10-28T16:57:40.000Z
- Description: Configure hard drive idle timeout for power savings using hdparm and rc.local systemd service to automatically spin down drives after inactivity.
- Author: David Dami
- Tags: Infrastructure, hdd, power-management, linux, systemd, storage

## Overview

HDDs can be configured to automatically spin down after a period of inactivity, reducing power consumption and heat. This guide uses `hdparm` with the `-S` flag to set idle timeout and ensures the setting persists across reboots using `/etc/rc.local`.

The `hdparm -S 240` command sets the idle timeout to 20 minutes (240 \* 5 seconds = 1200 seconds).

## Step 1: Open rc.local File

Edit the `/etc/rc.local` file:

```bash
sudo nano /etc/rc.local

```

## Step 2: Add hdparm Command

Add the `hdparm` command just before the `exit 0` line. Replace `/dev/sdX` with your actual disk device:

```bash
#!/bin/bash
# Your other startup commands here

# Set HDD idle timeout to 20 minutes (240 * 5 seconds = 1200 seconds)
sudo hdparm -S 240 /dev/sdX

exit 0

```

### Finding Your Disk Device

List all block devices to identify your HDD:

```bash
lsblk
# or
sudo fdisk -l
# or
sudo hdparm -I /dev/sdX | grep "Model"

```

Common device names: `/dev/sdb`, `/dev/sdc`, `/dev/sdd`, etc.

## Step 3: Make rc.local Executable

Ensure the file is executable:

```bash
sudo chmod +x /etc/rc.local

```

## Step 4: Enable rc.local Service (Ubuntu 18.04+)

Modern Ubuntu versions don't run `/etc/rc.local` by default. Create a systemd service file:

### Create the Service File

```bash
sudo nano /etc/systemd/system/rc-local.service

```

### Add Service Configuration

```ini
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target

```

### Enable and Start Service

```bash
sudo systemctl daemon-reload
sudo systemctl enable rc-local
sudo systemctl start rc-local

```

## Step 5: Reboot and Verify

Reboot the system to apply the configuration:

```bash
sudo reboot

```

After rebooting, verify the idle timeout is set correctly:

```bash
sudo hdparm -I /dev/sdX | grep -i idle

```

Expected output shows the idle timeout value set.

## hdparm Spindown Values

The `-S` flag uses a specific scale:

| **Value** | **Timeout**      |
| --------- | ---------------- |
| 1         | 5 seconds        |
| 2         | 10 seconds       |
| 3         | 15 seconds       |
| 12        | 1 minute         |
| 60        | 5 minutes        |
| 120       | 10 minutes       |
| 240       | 20 minutes       |
| 255       | 21 minutes (max) |

## Alternative: Using a systemd Service

For more control than `/etc/rc.local` gives you, define a oneshot systemd service that applies the setting at boot:

### Create Service File

```bash
sudo nano /etc/systemd/system/hdparm-spindown.service

```

```ini
[Unit]
Description=Set HDD Spindown Timeout
After=syslog.target

[Service]
Type=oneshot
ExecStart=/usr/sbin/hdparm -S 240 /dev/sdX
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

```

### Enable Service

```bash
sudo systemctl daemon-reload
sudo systemctl enable hdparm-spindown
sudo systemctl start hdparm-spindown

```

## Monitoring HDD Activity

Check current HDD power state:

```bash
sudo hdparm -C /dev/sdX

```

Output will show:

- `drive state is: active/idle` \- Currently active or idle
- `drive state is: standby` \- Spun down

Monitor real-time disk activity:

```bash
iotop
# or
iostat -x 1

```

## Troubleshooting

### hdparm Command Not Found

Install `hdparm`:

```bash
sudo apt install hdparm

```

### Service Won't Start

Check service status:

```bash
sudo systemctl status rc-local.service
sudo journalctl -u rc-local.service -n 20

```

### Setting Doesn't Persist

Verify `/etc/rc.local` is executable:

```bash
ls -la /etc/rc.local

```

### Device Not Found

Ensure the device path is correct:

```bash
sudo lsblk -o NAME,TYPE,SERIAL,SIZE

```

## Power Saving Benefits

- **Reduced power consumption**: Inactive drives consume \~0.1W vs 5-10W when spinning
- **Lower temperatures**: Cooler operating conditions extend disk lifespan
- **Quieter operation**: Spindown reduces fan noise

## Best Practices

- Don't set spindown time too short (causes excessive spin-up cycles)
- Monitor drives during spindown to ensure no data loss
- Use with backup drives or non-critical storage
- Test before production deployment