How to get device name with device id?

Andreas Dilger adilger at sun.com
Fri Jun 26 04:49:50 UTC 2009


On Jun 25, 2009  18:58 -0700, Smit Shah wrote:
> I just ran through this post, and since no solution was posted, here's
> a piece of code that i had written
> Infact when i wrote this i wanted both the device name and also the
> file system on that partition.

What is wrong with just using the "blkid" program?  It doesn't need
root permission (if it is using the cache):

[adilger ~]$ blkid
/dev/sda1: LABEL="boot" UUID="1fe1d719-1a8c-45a0-969a-cba8b101cc57" TYPE="ext3" SEC_TYPE="ext2"
/dev/sda2: LABEL="FC8" UUID="3bf693a3-a288-45ea-9f8b-1d140254b44c" TYPE="ext3" SEC_TYPE="ext2"
/dev/sda3: TYPE="swap" LABEL="swap" UUID="d37ac19b-c8e1-42d5-8802-f1c98a6d7062"
/dev/sda5: UUID="zm1xpW-mGQT-wlXO-dgMR-Gtx0-F5iI-9SSlxK" TYPE="lvm2pv"
/dev/dm-0: LABEL="home" UUID="1bcd7718-3d7b-41ba-ab1a-f38e0fe40cf9" TYPE="ext3" SEC_TYPE="ext2"

and you can get the filesystem type of all or a specific device easily:

[adilger ~]$ blkid -s TYPE
/dev/sda1: TYPE="ext3" 
/dev/sda2: TYPE="ext3" 
/dev/sda3: TYPE="swap" 
/dev/sda5: TYPE="lvm2pv" 
/dev/dm-0: TYPE="ext3" 

[adilger ~]$ blkid -s TYPE /dev/sda2
/dev/sda2: TYPE="ext3"

or other information such as the filesystem label:

[adilger ~]$ blkid -s LABEL /dev/sda2
/dev/sda1: LABEL="boot"


Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.




More information about the Ext3-users mailing list