Created
August 15, 2017 02:11
-
-
Save glennswest/fb453288ab43b9819527199e385f019c to your computer and use it in GitHub Desktop.
Find Linux Root drive and partition
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
rootdev=`findmnt --target / -o SOURCE -n` | |
echo $rootdev | |
rootdrivename=`lsblk -no pkname $rootdev` | |
rootdrive="/dev/"$rootdrivename | |
echo $rootdrive | |
majorminor=`lsblk $rootdev -o MAJ:MIN | tail -1` | |
echo $majorminor | |
part_number=${majorminor#*:} | |
echo $part_number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output is:
[glennswest@gswone ~]$ ./x.sh
/dev/sda2
/dev/sda
8:2
2