Re: How to get device name with device id?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Thu, Jun 25, 2009 at 9:49 PM, Andreas Dilger <adilger@xxxxxxx> wrote:
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?
 I guess blkid uses the same interfaces but the command doesn't provide option to specify the device number. But when i wrote this what i wanted to do is to get the file system of the device on which  the file resides.  
 
 It doesn't need
root permission (if it is using the cache):
Yes.  

[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.


_______________________________________________
Ext3-users mailing list
Ext3-users@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/ext3-users

[Index of Archives]         [Linux RAID]     [Kernel Development]     [Red Hat Install]     [Video 4 Linux]     [Postgresql]     [Fedora]     [Gimp]     [Yosemite News]

  Powered by Linux