A simple bash script to flash a hard drive's activity light in distinctive patterns, making it easy to physically identify which drive is which when you have multiple drives in a server.
When you're looking at a server with multiple hard drives and need to identify which physical drive corresponds to /dev/sda, /dev/sdb, etc., this script creates recognizable disk I/O patterns that cause the specific drive's activity light to flash. No more guessing which drive is which!
- π¨ SOS Morse Code Pattern - Classic distress signal (... --- ...)
- π‘ Multiple Flash Patterns - Blink, rapid, slow, and double-blink patterns
- π― Device-Specific - Target any block device by path
- π Safe & Non-Destructive - Only reads from the drive, never writes
- β‘ Direct I/O - Bypasses cache for guaranteed activity light response
- π Easy Stop - Just press Ctrl+C when you've found your drive
- Linux operating system
- Root access (sudo)
- Block device to flash (e.g.,
/dev/sda,/dev/nvme0n1) - Standard utilities:
dd,lsblk,sleep
# Download the script
wget https://github.com/th3fallen/flasher.sh/raw/main/flasher.sh
# Make it executable
chmod +x flasher.sh# Flash /dev/sda with default SOS pattern
sudo ./flasher.sh -device /dev/sda# Simple on/off blink pattern
sudo ./flasher.sh -device /dev/sda -p blink
# Fast blinking
sudo ./flasher.sh -device /dev/sdb -p rapid
# Slow blinking
sudo ./flasher.sh -device /dev/sdc -p slow
# Double-blink pattern
sudo ./flasher.sh -device /dev/nvme0n1 -p double
# SOS Morse code (default)
sudo ./flasher.sh -device /dev/sda -p morse_sos./flasher.sh -h| Pattern | Description | Visual |
|---|---|---|
morse_sos |
SOS in Morse code (... --- ...) | ββββββββββββββββββββββββββββββ |
blink |
Simple on/off blinking | ββββββββ |
rapid |
Fast blinking | ββββββββββββ |
slow |
Slow blinking | ββββββββββββ |
double |
Two quick flashes then pause | ββββββββββββ |
- Direct Device Access - The script reads directly from the specified block device (e.g.,
/dev/sda) - Direct I/O Flag - Uses
iflag=directto bypass the operating system's cache - Physical Disk Activity - Forces the drive controller to perform actual reads from the disk
- Activity Light Response - The hard drive's activity LED responds to these read operations
- Pattern Creation - Alternates between read phases (light on) and pause phases (light off)
β This script is completely safe:
- It only reads from the device, never writes
- No data is modified or at risk
- Uses standard
ddutility with read-only operations - Can be safely interrupted with Ctrl+C at any time
- Drive Identification - Figure out which physical drive is
/dev/sdbin a multi-drive server - Hot-Swap Bays - Identify drives in hot-swap caddies before removal
- Failed Drive Replacement - Locate the exact drive that needs replacing
- Storage Expansion - Verify new drives are detected in the correct bays
- Cable Tracing - Confirm which SATA/SAS port connects to which drive
- RAID Configuration - Identify physical drives before adding to arrays
- Server Maintenance - Verify drive bay numbers match device names
- Block Size: 4KB (4096 bytes)
- Block Count: 256 blocks per read (1MB total)
- I/O Method: Direct I/O (bypasses cache)
- Device Types: Any block device (HDD, SSD, NVMe)
- Short flash (dot): ~3 quick reads
- Long flash (dash): ~5 reads
- Pause duration: 0.1 to 2 seconds depending on pattern
- Ensure you're running as root:
sudo ./flasher.sh -device /dev/sda - Verify the device exists:
lsblk -d - Check device path is correct (e.g.,
/dev/sdanotsda)
- SSDs/NVMe: Some solid-state drives have less visible activity lights
- RAID controllers: Activity lights may behave differently on hardware RAID
- Try a different pattern: Use
-p rapidor-p blinkfor more frequent flashing - Check the right light: Ensure you're watching the correct drive's LED
- Must run with sudo:
sudo ./flasher.sh -device /dev/sda - Verify device is accessible:
ls -l /dev/sda
lsblk -d -o NAME,SIZE,MODEL# You have 4 drives in your server and need to replace /dev/sdb
# Run the flasher on /dev/sdb
sudo ./flasher.sh -device /dev/sdb -p morse_sos
# Look at your server's drive bays - the one flashing SOS is /dev/sdb
# Press Ctrl+C when found# On one terminal/session - flash /dev/sda
sudo ./flasher.sh -device /dev/sda -p rapid
# On another terminal - flash /dev/sdb
sudo ./flasher.sh -device /dev/sdb -p slow
# On another terminal - flash /dev/sdc
sudo ./flasher.sh -device /dev/sdc -p double
# Now you can see which physical drive corresponds to each device# SMART reports /dev/sdf is failing
# Flash it to locate the physical drive
sudo ./flasher.sh -device /dev/sdf -p blink
# Remove the drive that's blinking
# Press Ctrl+C after you've identified itContributions are welcome! Feel free to submit issues or pull requests.
- Custom pattern definition from command line
- LED brightness control (if supported by hardware)
- Multiple device flashing simultaneously
- Pattern speed adjustment
- Web interface for remote triggering
MIT License - feel free to use and modify as needed.
Inspired by the age-old problem of "where the hell is this drive on my server?" and countless trips to the rack with a laptop running dd if=/dev/zero of=/tmp/test in a loop.
Note: This script is intended for legitimate system administration purposes. Always ensure you have proper authorization before accessing any hardware or servers.