Skip to content

Instantly share code, notes, and snippets.

@islander
Created October 29, 2019 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save islander/29f2e1ee3ae7cd23028d5c178e28a4d0 to your computer and use it in GitHub Desktop.
Save islander/29f2e1ee3ae7cd23028d5c178e28a4d0 to your computer and use it in GitHub Desktop.
Linux SATA hotswap
#!/bin/sh
if test -h "$1"
then
disk=$(chase "$1")
else
disk="$1"
fi
if test -b "$disk"
then
echo 1 >/sys/block/$(basename "$disk")/device/delete
else
echo "$0: not a block device: $1" >&2
exit 1
fi
#!/bin/bash
exec tee /sys/class/scsi_host/host*/scan <<<'- - -' >/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment