We automatically run hdparm on external drives when they are automounted:
filter partitions {
optical = false
partition_table = false
usage = filesystem
}
filter optical-udf {
optical = true
partition_table = false
usage = filesystem
type = udf
}
filter optical-other {
optical = true
partition_table = false
usage = filesystem
}
filter disks {
optical = false
partition = false
}
match partitions {
automount = true
post_mount_command = '
sudo chmod a+rwx "%mount_point" 2>/dev/null
if [ -f /usr/bin/net ] && /bin/systemctl is-enabled samba > /dev/null 2>&1; then
count=120
while [ $count -gt 0 ]; do
if sudo /usr/bin/net usershare add "$(basename "%mount_point")" "%mount_point" "Auto-mount Volume" "$(hostname -s)\osmc:f"
then break
fi
sleep 5; let count-=5
done
fi'
post_unmount_command = '
if [ -f /usr/bin/net ]; then
sudo /usr/bin/net usershare delete "$(basename "%mount_point")"
fi'
}
match optical-udf {
automount = true
automount_options = { 'mode=0444','dmode=0555','uid=1000','gid=1000','umask=0000' }
post_mount_command = '
if [ -f /usr/bin/net ] && /bin/systemctl is-enabled samba > /dev/null 2>&1; then
count=120
while [ $count -gt 0 ]; do
if sudo /usr/bin/net usershare add "$(basename "%mount_point")" "%mount_point" "Auto-mount Volume" "$(hostname -s)\osmc:r"
then break
fi
sleep 5; let count-=5
done
fi'
post_unmount_command = '
if [ -f /usr/bin/net ]; then
sudo /usr/bin/net usershare delete "$(basename "%mount_point")"
fi
/usr/bin/eject %device_file'
}
match optical-other {
automount = true
automount_options = { 'mode=0444','dmode=0555','uid=1000','gid=1000' }
post_mount_command = '
if [ -f /usr/bin/net ] && /bin/systemctl is-enabled samba > /dev/null 2>&1; then
count=120
while [ $count -gt 0 ]; do
if sudo /usr/bin/net usershare add "$(basename "%mount_point")" "%mount_point" "Auto-mount Volume" "$(hostname -s)\osmc:r"
then break
fi
sleep 5; let count-=5
done
fi'
post_unmount_command = '
if [ -f /usr/bin/net ]; then
sudo /usr/bin/net usershare delete "$(basename "%mount_point")"
fi
/usr/bin/eject %device_file'
}
match disks {
post_insertion_command = '
if [ $(/bin/lsblk -n -d -o RM "%device_file") -eq 1 ] || [ $(/bin/lsblk -n -d -o ROTA "%device_file") -eq 0 ]; then
device=$(/bin/lsblk -n -d -o MAJ:MIN,TYPE -s "%device_file" | grep disk | sed "s/[^0-9:]*//g")
echo 1024 | sudo tee "/sys/dev/block/$device/queue/read_ahead_kb" > /dev/null
else
sudo /sbin/hdparm -S 240 %device_file
fi'
}
default {
post_insertion_command = 'echo "Device %device_file did not match any rules."; ls -al "%device_file"; echo "blkid: $(/sbin/blkid %device_file)"; /usr/bin/udisks --show-info %device_file'
}
However not all external USB drives support this, so it’s highly likely that your new drive doesn’t support the spindown commands sent by hdparm. I have two external 2.5" drives and neither one of them supports spinning down with hdparm.
Try running the following command and see whether it reports an error:
sudo /sbin/hdparm -S 240 /dev/sda