summaryrefslogtreecommitdiffstats
path: root/helperscripts/pokedisks/pokedisks
blob: 99ab0add4d8fe5722240980aa3fef00998477567 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
#
# Workaround for certain power management misfeatures of some harddisks
# Copyright (c) 2012-2020 Michael Buesch <m@bues.ch>
# Licensed for any use.
#

# Regular expression of affected harddisk models
# This regex matches on /sys/block/DISK/device/model
models='(^EZRX)|(^HDS5C)|(^DT01ACA)|(2CX188)'


block="$(hexdump -n 2 -e '/2 "%u"' /dev/urandom)"
for disk in /dev/hd? /dev/sd?; do
	[ -b "$disk" ] || continue
	base="$(basename "$disk")"
	grep -qEe "$models" "/sys/block/$base/device/model" || continue
#	echo "Poking $disk block $block"
	dd if="$disk" of=/dev/null bs=512 count=1 skip="$block" >/dev/null 2>&1
done

exit 0
bues.ch cgit interface