detect partitions

blkid -c /dev/null
`blkid` is an interface to libuuid - it can read Device Mapper, EVMS, LVM, MD, and regular block devices. -c /dev/null - Do not use cached output from /etc/blkid.tab or /etc/blkid/blkid.tab (RHEL) -i - Display I/O Limits (aka I/O topology) information (not available in RHEL) -p - Low-level superblock probing mode (not available in RHEL)
Sample Output
# blkid -pi -c /dev/null /dev/sda
MINIMUM_IO_SIZE=512
PHYSICAL_SECTOR_SIZE=512
LOGICAL_SECTOR_SIZE=512
PTTYPE=dos



# blkid -c /dev/null
/dev/mapper/srv-lvol0: UUID="ff838430-4058-47a4-abf8-91362eb57ba1" TYPE="ext3" 
/dev/mapper/VolGroup00-LogVol01: TYPE="swap" 
/dev/mapper/VolGroup00-LogVol02: UUID="2ba64b56-9c0c-40e1-a17b-c1bfe2040007" TYPE="ext3" 
/dev/mapper/VolGroup00-LogVol00: UUID="c22f3324-8c93-4bd3-b376-eed363e0c15f" TYPE="ext3" 
/dev/cciss/c0d4: UUID="07bc6be5-6f4e-409a-940c-b5ba398dd7b5" TYPE="ext4" 
/dev/cciss/c0d0p1: LABEL="/boot" UUID="0cfeec27-0c44-4991-a2cb-1e881dfb98c3" TYPE="ext3" 
/dev/VolGroup00/LogVol00: UUID="c22f3324-8c93-4bd3-b376-eed363e0c15f" TYPE="ext3" 
/dev/VolGroup00/LogVol01: TYPE="swap" 
/dev/loop0: LABEL="NOLABEL" TYPE="iso9660" 
/dev/loop1: LABEL="RMO_CDROM" TYPE="iso9660" 
/dev/mapper/mpath4: UUID="07bc6be5-6f4e-409a-940c-b5ba398dd7b5" TYPE="ext4" 
/dev/mapper/mpath29p1: LABEL="ORADATA001" TYPE="oracleasm" 
/dev/mapper/mpath16p1: UUID="79028217-73cf-497c-bcb4-2bde1cbebdeb" SEC_TYPE="ext2" TYPE="ext3" 
/dev/mapper/mpath18p1: UUID="e361ac4f-a9d3-4250-a14c-1cac6881844f" SEC_TYPE="ext2" TYPE="ext3" 
/dev/loop2: LABEL="INST_CD" TYPE="iso9660"

2
By: mhs
2012-09-12 13:34:41

7 Alternatives + Submit Alt

  • file(1) can print details about certain devices in the /dev/ directory (block devices in this example). This helped me to know at a glance the location and revision of my bootloader, UUIDs, filesystem status, which partitions were primaries / logicals, etc.. without running several commands. See also: file -s /dev/dm-* file -s /dev/cciss/* etc.. Show Sample Output


    24
    file -s /dev/sd*
    mhs · 2010-12-28 09:56:03 0
  • Shows all block devices in a tree with descruptions of what they are.


    3
    lsblk -o NAME,TYPE,FSTYPE,LABEL,SIZE,MODEL,MOUNTPOINT
    BasketCase · 2012-09-12 15:30:25 0

  • 0
    sudo file -bs /dev/sda | sed -e 's/.*partition 1\(.*\) code offset.*/partition 1\1/g' -e 's/\(.\);/\1\n/g'
    jlaunay · 2012-08-17 12:54:05 2
  • Another alternative to blkid, lsblk, file -s, cat /proc/paritions, fdisk -l, etc.. Show Sample Output


    0
    fsarchvier probe simple
    0xFF · 2013-04-28 10:16:18 0

  • -1
    diskutil list
    grahamperrin · 2012-10-06 21:18:27 0

What Others Think

is blkid a built-in command ?
seca · 159 weeks and 5 days ago
The util-linux package provides blkid, as well as other similar commands such as lsblk, wipefs, and blockdev. Almost every Linux distribution has util-linux.
mhs · 159 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: