3

On macOS, I'm trying to learn how to determine what a given 'disk' (as listed under /dev/disk*) maps to.
E.g., in the following, I can't tell from "ls" or "df" that /dev/disk5 is associated with the .iso disk file ... but the Mac "Disk Utility" can!

Example:

$ ls -l /dev/disk*
brw-r-----  1 root    operator    1,   0 Apr 30 13:06 /dev/disk0
brw-r-----  1 root    operator    1,   3 Apr 30 13:06 /dev/disk0s2
brw-r-----  1 root    operator    1,  10 Apr 30 13:06 /dev/disk3
brw-r-----  1 root    operator    1,  12 Apr 30 13:06 /dev/disk3s2
br--r-----  1 sieler  staff       1,  13 May  4 15:06 /dev/disk5

$ df
Filesystem            512-blocks       Used  Available Capacity   iused     ifree %iused  Mounted on
/dev/disk0s2          1873705792 1586327624  286866168    85% 198354951  35858271   85%   /
/dev/disk3s2          5859794856 2811923000 3047871856    48% 351490373 380983982   48%   /Volumes/sea3b
/dev/disk5               8282556    8282556          0   100% 18446744073707482787   2070639 1019157131144059776%   /Volumes/CSLA_X64FREO_EN-US_DV5

From Disk Utilility I see:

  • disk0 is an internal SATA drive.
  • disk3 is an external USB drive.
  • disk5 is a .iso file that has been mounted as a drive.

I'd like to be able to determine the same thing (SATA, USB, .iso) with non-GUI commands (or, better yet, via functions callable from C, but I'll screen-scrape command line tool output if I have to :)

Thanks, Stan

3

Use mount to determine which mounted volumes corresponds to which /dev/diskX devices. Alternatively you can Use ⌘I in Disk Utility to see what /dev/diskX identifier a particular volume uses.

1
  • thanks, this (using 'mount') answered it for me! (The Disk Utility method is interesting, but not amenable to screen-scraping / capturing the result programmatically.) May 17 '17 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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