detect partitions

diskutil list
Sample Output
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *750.2 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS swap                    32.0 GB    disk0s2
   3: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF               536.9 MB   disk0s3
   4:                  Apple_HFS spare                   671.1 MB   disk0s4
   5:          Apple_CoreStorage                         99.5 GB    disk0s5
   6:                 Apple_Boot Boot OS X               650.0 MB   disk0s6
   7:          Apple_CoreStorage                         616.3 GB   disk0s7
   8:                 Apple_Boot Boot OS X               134.2 MB   disk0s8
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS OS                     *99.2 GB    disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *616.0 GB   disk2
   1:                        EFI                         209.7 MB   disk2s1
   2:                        ZFS                         615.7 GB   disk2s2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:             zfs_pool_proxy gjp22                  *614.2 GB   disk3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *640.1 GB   disk4
   1:                        EFI                         209.7 MB   disk4s1
   2:                        ZFS                         639.8 GB   disk4s2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:             zfs_pool_proxy zhandy                 *635.7 GB   disk5
   1:       zfs_filesystem_proxy Pocket Time Machine     85.1 GB    disk5s1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.0 TB     disk7
   1:                        EFI                         209.7 MB   disk7s1
   2:                        ZFS                         2.0 TB     disk7s2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:             zfs_pool_proxy tall                   *2.0 TB     disk8
   1:       zfs_filesystem_proxy backups                 62.4 GB    disk8s1
   2:       zfs_filesystem_proxy LaCie d2 Extreme        50.7 GB    disk8s1s1
   3:       zfs_filesystem_proxy 11G                     50.7 GB    disk8s1s1s1
   4:       zfs_filesystem_proxy 12A                     50.7 GB    disk8s1s1s2
   5:       zfs_filesystem_proxy blocky                  54.2 GB    disk8s1s2
   6:       zfs_filesystem_proxy gjp22                   376.0 GB   disk8s1s3
   7:       zfs_filesystem_proxy zhandy                  478.3 GB   disk8s1s4
   8:       zfs_filesystem_proxy Pocket Time Machine     107.4 GB   disk8s1s4s1

2012-10-06 21:18:27

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

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

    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/ or /etc/blkid/ (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

    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

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

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


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: