Last active
January 26, 2017 04:59
-
-
Save mpontillo/0b92a7da2fba43fb5dce705be2dcf38b to your computer and use it in GitHub Desktop.
Print detailed information about each block device. (Tested on Ubuntu 16.04.)
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/bash | |
# Note: excluding ramdisks, floppy drives, and loopback devices. | |
lsblk --exclude 1,2,7 -d -P | |
echo "" | |
for dev in $(lsblk -n --exclude 1,2,7 --output KNAME); do | |
echo "$dev:" | |
udevadm info -q all -n $dev | |
echo "" | |
echo " size64: $(sudo -n blockdev --getsize64 /dev/$dev 2> /dev/null || echo unknown)" | |
echo " bsz: $(sudo -n blockdev --getbsz /dev/$dev 2> /dev/null || echo unknown)" | |
done | |
echo "" | |
# Enumerate the mappings that were generated (by device). | |
find /dev/disk -type l | xargs ls -ln | awk '{ print $9, $10, $11 }' | sort -k2 | |
echo "" | |
sudo -n echo "" 2> /dev/null || echo "Please re-run this script with 'sudo' for more details." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment