Skip to content

Instantly share code, notes, and snippets.

@isaaclw
Last active November 22, 2019 21:09
Show Gist options
  • Save isaaclw/51d4a82ca24302abcfd57a6f91cd0f1d to your computer and use it in GitHub Desktop.
Save isaaclw/51d4a82ca24302abcfd57a6f91cd0f1d to your computer and use it in GitHub Desktop.
Detect Sata (may not work) #hardware #blockdevices #bash
# first list devices that are connected:
ls /dev/sd*
# then list devices listed in /sys/block:
ls /sys/block/sd* # I expect they agree, but unsure atm
# find the 'hostid' of the existing devices
for i in $(ls /dev/); do if [[ "$i" =~ "sd" ]]; then (echo -n "$i => "; readlink /sys/block/$i | cut -d '/' -f 5; echo "") | grep "host"; fi; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment