There are 20+ drives in the system. One of the drives is having issues according to the disk controller. The disk controller reports to me by the drives serial number. That drive serial I can map to a "Device / Media Name" (f.e. HPT DISK 1_7 Media).

Device / Media Name → Device Identifier

Next, I do wish to know the "Device Identifier" (like disk8) or "Device Node" (f.e. /dev/disk8).


Having to do a diskutil info /dev/diskZZ for all of the 20+ drives is quite inefficient.

What is the efficient way to do a command-line lookup for the disk its "Device Identifier" having the "Device / Media Name" using Lion (Mac OS X 10.7)?

2 Answers 2


The following will output the device node for any volume with a matching name by replacing <string> with the Device/ Media Name you're searching for.

for d in /dev/disk*; do
    if [ `diskutil info $d | grep -c <string>` == 1 ]; then
        diskutil info $d | grep "Node"


$ for disk in /dev/disk*; do [ `diskutil info $disk | grep -c '<string>'` == 1 ] && diskutil info $disk | grep Node; done

BTW, on my MacBook Pro I have two "drives" with the same device name as they are two volumes on an APFS drive so some people reading this may have similar happening. I also don't have a 10.7 Mac available to test it, but it doesn't rely on any fancy shell stuff so should work fine. It certainly works on 10.12 and 10.13.

  • This shell script loop (and the one-liner) also works as expected on 10.7.
    – Pro Backup
    Mar 26, 2018 at 10:06
for d in /dev/disk*; do
diskinfo info $d | grep <string>

Or similar.

  • Actually, that won't work. The output of diskutil info <device identifier> is multiple lines so your script will return "Device / Media Name: <string>" and nothing else. Mar 22, 2018 at 3:01
  • :thumbup: I may have rushed it, with no testing. Also thought OP might do some shell script research :) Mar 22, 2018 at 7:10
  • Yeh, looked at the output now, I see what you mean. You need to match the ID with the disk, then output the disk ID that that line appears in. Mar 22, 2018 at 8:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .