How do I prevent disk renumbering on reboot in OS X?
I have 3 physical drives in my Mac Pro with Mac OS X 10.6.4. Occasionally after rebooting the machine, the disk numbering changes such that the /dev/disk# does not reference the same drive as it did before the reboot.
Example
/dev/disk0 -> 64GB SSD drive
/dev/disk1 -> 640GB Hitachi
/dev/disk2 -> 160GB WD (BootCamp)
After rebooting the mapping might be
/dev/disk0 -> 160GB WD (BootCamp)
/dev/disk1 -> 640GB Hitachi
/dev/disk2 -> 64GB SSD drive
Even more confusing is that the remapping is not consistent. For most stuff this is irrelevant. However I also have Parallels installed to allow access to the BootCamp partition from within OS X. Parallels uses the /dev/disk# path in it's configuration file so, after rebooting OS X I launch Parallels and it tells me that the disk is no longer present.
Is there a way to tell OS X to always assign a given drive to /dev/disk0?
Solution 1:
As far as i understand MacOS doesn't have that capability, although for running parallels it might not be strictly necessary.
using macports and installing e2fsprogs with a small patch:
diff -r e2fsprogs-1.41.12/misc/Makefile e2fsprogs-1.41.12.patched/misc/Makefile
399c399
> $(LIBEXT2FS) $(LIBCOM_ERR)
---
< $(LIBEXT2FS)
401,402c401
you can use blkid -s UUID /dev/rdisk* to enumerate partitions, disks and get their respective uuids (for any supported file-system which is quite a few).
After that a adding a softlink with 'ln -s' or creating an alternate device node with mknod should work (and then reference that psudo-/clone-device from Parallels). I've done similar tricks with Fusion, but I haven't got Paralells installed right now (so I can't test)
stat -f "%Sr %Z" /dev/rdisks gives you a map over device to major,minor to be used if parallels doesn't accept a soft-link to the device.
which can be used as in the following example:
some@host:/e2fsprogs-1.41.12$ blkid -s UUID /dev/rdisk*s*
/dev/rdisk0s1: UUID="76D6-1701"
/dev/rdisk0s2: UUID="654F73AE51849687"
/dev/rdisk1s1: UUID="51FC4E72-BFA9-4DBD-9A5C-0E5H731DB0ED"
some@host:/e2fsprogs-1.41.12$ stat -f "%Sr %Z" /dev/rdisk*
rdisk0 14,0
rdisk0s1 14,1
rdisk0s2 14,2
rdisk1 14,3
rdisk1s1 14,4
# okay, UUID 51FC4E72-BFA9-4DBD-9A5C-0E5H731DB0ED is a partition
# on the disk we want to use. so we make a 'private' device node
# pointing to the device containing that partition.
some@host:/e2fsprogs-1.41.12$ sudo mknod /dev/pdisk1 b 14 3
# just a quick verify that the mknod worked as expected ...
some@host:/~$ sudo dd if=/dev/rdisk1 count=10 2>/dev/null | md5
19d55b28485771bc80acdddbd1b45faf
some@host:/~$ sudo dd if=/dev/pdisk1 count=10 2>/dev/null | md5
19d55b28485771bc80acdddbd1b45faf
Now the only thing left is to write a script and using the instructions in http://support.apple.com/kb/HT2420?viewlocale=en_US to make it run at boot.
But that will be for somebody else to finish ...
Solution 2:
I've heard smarter Mac guys than me imply that the disk numbering is somewhat arbitrary and one can not depend on the same device getting the same number after a reboot. It was mentioned in reference to creating RAID slices via diskutil in the Terminal.
None of the low level utilities I've found, such as diskutil, pdisk or gpt, appear to be able to affect the disk numbering. I'm afraid it may not be controllable.