Identify a partition from script I have a bash script that needs to find out itself from which partition / disk it is running from. Unfortunately, I don't know how to do that or if there is a piece of software that can help me with this.
It would be really great if someone here could help me with this!
Here's a demonstration script which uses stat to print the device identifier of the running script. The device identifier can then be used to get the partition name with a utility such as diskutil.

#! /bin/bash
#
#  whscript: Print the Device Identifier
#            of the running script
#

#  This will return the name of the script

echo "$0"

#  Use stat to produce the Device Identifier

stat -f '%Sd' -- "$0"

#  Have diskutil print information
#  about the Device Identifier. Parse as
#  needed

diskutil info "$(stat -f '%Sd' -- "$0")"