Created
July 13, 2023 13:17
-
-
Save teknoraver/2f77a0a40b7294bf1b90f04b177382fb to your computer and use it in GitHub Desktop.
Given a partitioned block device, return the device representing the whole disk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
dev=$1 | |
dev=$(realpath "$dev") | |
dev=$(basename "$dev") | |
sys="/sys/class/block/$dev" | |
if [ -f "$sys/partition" ]; then | |
dev=$(realpath "$sys/..") | |
dev=$(basename "$dev") | |
fi | |
echo "/dev/$dev" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment