Use file(1) to view device information

file -s /dev/sd*
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..
Sample Output
/dev/sda: x86 boot sector; GRand Unified Bootloader, stage1 version 0x3, stage2 address 0x2000, stage2 segment 0x200; partition 1: ID=0x83, active, starthead 1, startsector 63, 497952 sectors; partition 2: ID=0x5, starthead 0, startsector 498015, 141741495 sectors, code offset 0x63
/dev/sda1: Linux rev 1.0 ext3 filesystem data, UUID=e56c6019-7b10-44c9-8692-6137b93648dd (needs journal recovery)
/dev/sda2: x86 boot sector; partition 1: ID=0x8e, starthead 1, startsector 63, 141741432 sectors, extended partition table (last)\011, code offset 0x0
/dev/sda5: LVM2 (Linux Logical Volume Manager) , UUID: WETkEg8anaR7V9Kkc39GKs410FKlw5K
/dev/sdb: x86 boot sector; partition 1: ID=0xee, starthead 0, startsector 1, 426759839 sectors, extended partition table (last)\011, code offset 0x0
/dev/sdb1: LVM2 (Linux Logical Volume Manager) , UUID: Y6gkfwuq7FZeqoE35bIboE4HkdlOcme

24
By: mhs
2010-12-28 09:56:03

8 Alternatives + Submit Alt

  • 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
  • `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) Show Sample Output


    2
    blkid -c /dev/null
    mhs · 2012-09-12 13:34:41 2

  • 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

  • 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

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: