Persistent USB External Drive Naming

usb

Based on the order I insert USB disks, they can be named either /dev/disk2 or /dev/disk3 for example, and this is a problem for me. Is there a way to make the naming persistent, or reference them in a persistent way?

Under linux I would use udev, or I would reference them under /dev/disk/by-uuid/ — is there something similar for Mac?

To clarify, although I could specify the UUID in /etc/fstab, I need to access the physical device file under a persistent name.

The reason I'm doing this is I'm accessing the raw physical partition under VirtualBox (giving the guest OS access to it). And with virtualbox I create a file that contains a reference to /dev/disk2, so if the device number changes, the file I've created with virtualbox won't work and I either need to unplug things and replug them in, or run the command again with the correct device.

Thank you.

Best Answer

A way to get the device node from the disk UUID is this:

diskutil info UUID|grep 'Device Node'|awk '{print $3}'

Replace UUID with the actual disk UUID.