In Linux if I want to see all the devices currently connected to my computer in the command-line, I run:

lsblk

or

blkid

What's the equivalent command under Mac OS X?

NOTE

The goal here is to be able to obtain information about a device based on its label or other uniquely identifying attributes, even if it hasn't been mounted, thus df is not a viable option.


Examples of the kind of info I'm looking for are:

  • /dev/<dev-name>
  • uuid
  • label (if any)
  • mount point

NOTE

I need to be able to see network-attached drives as well!

up vote 92 down vote accepted

diskutil list will list all disks with their identifiers, even if unmounted.

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Mac SSD                 150.0 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:       Microsoft Basic Data Windows 8               100.1 GB   disk0s4
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *500.1 GB   disk1
   1:                  Apple_HFS George Garside          300.2 GB   disk1s1
   2:               Windows_NTFS GRGARSIDE               199.9 GB   disk1s2

For mounted disks only…

To find the raw device name (i.e. /dev/disk0s1) you can run df.

You can limit the results to locally-mounted filesystems, use df -Hl.
This results in a list of partitions and their raw device names, as shown below:

Filesystem     Size   Used  Avail Capacity  iused    ifree %iused  Mounted on
/dev/disk0s2   150G   130G    20G    87% 31761475  4859615   87%   /
/dev/disk0s4   100G    83G    17G    83%   184667 17015601    1%   /Volumes/Windows 8
/dev/disk1s1   300G   282G    19G    94% 68771109  4529660   94%   /Volumes/George Garside
/dev/disk1s2   200G   172G    27G    87%   144125 26731127    1%   /Volumes/GRGARSIDE
  • Where is the UUID? – Frozen Flame Aug 31 '15 at 13:03
  • Toward helping some users: this command won't do the job if one do the disks has certain corruptions, like btree errors. Then the diskutil will error out before showing the USB device. An impediment when you need to backup to said USB drive before reformatting the corrupt disk – New Alexandria Sep 19 '15 at 18:08

Mac OS X offers the system_profiler utility that can be run from Terminal. You can pipe it through grep to find specific strings that you want.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.