In an effort to create a Linux installation script, I'd like to check if
/dev/sda is currently in use by the Kernel, and exit if so. I guess this means finding out what partitions are associated to the device and see if any of them is mounted... am I right with my guess? Is it possible for a device to be in use without having a mounted partition? What's the best way I should make the test? This is what I've come up with until now:
if [ $(findmnt -no SOURCE | grep ^/dev/sda) ]; then echo 'Hard disk drive is already in use.' exit fi
I'd appreciate any suggestions.