0

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.

  • Doesn't /Volumes/foo/bar work for you? If not, great fun was had figuring this one out - apple.stackexchange.com/questions/207089/… – Tetsujin Dec 11 '16 at 18:32
  • Tetsujin: No I need access to the physical device file, it won't be mounted under /Volumes/. And I can't just look it up after the fact, I really need it to be named persistently. – Bubbleshadow Dec 11 '16 at 18:35
  • Not sure how you're going to access any drive that isn't mounted. – Tetsujin Dec 11 '16 at 18:38
  • @Tetsujin The drive explicitly must not be mounted in this scenario. You access an non-mounted drive by using software that access the disk physically to parse the filesystem itself. This is essential what happens with VirtualBox and it's raw partition support which presents the physical disk to the guest OS, which then parses the file system. – jksoegaard Dec 11 '16 at 18:49
  • @jksoegaard - that sounds... so far beyond me I won't even ask for a further explanation ;-) Never used Virtual Box, only Parallels – Tetsujin Dec 11 '16 at 19:01
1

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.

  • Thank you, that will work if I end up having to script something (which it increasingly looks like I will have to). – Bubbleshadow Dec 11 '16 at 19:09
  • Yes, sounds that way. On macOS you haven't got a set of /dev/disk/by-xxx nodes like on Linux, where you can lookup the device by id, label, path or uuid directly in the file system. – jksoegaard Dec 11 '16 at 19:11

You must log in to answer this question.

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