How do I stop my external hard drives from changing disk IDs when I reboot on OS X?
August 14, 2009 8:08 PM
How do I stop my external hard drives from changing disk IDs when I reboot on OS X?
I have a simple rsync script that I just made for my OS X machine to backup data on my two main drives to two drives in an external enclosure. I wanted the script to mount and unmount the drives so that they wouldn't clutter my desktop and to keep them "hidden".
The problem is that the disk ID under /dev changes everytime I reboot. Sometimes the drive mounted at /Volumes/backup1 will be at /dev/disk3s3 and sometimes it will be at /dev/disk4s3. Other times it will be at /dev/disk2s3.
Is there anyway to keep the disk ID static, or to just mount by the directory name? I'm running 10.5.8, with the latest updates. My script uses the `diskutil`command to mount and unmount the drives. Oh, and AFAIK, Time Machine only works with one drive as a backup.
I have a simple rsync script that I just made for my OS X machine to backup data on my two main drives to two drives in an external enclosure. I wanted the script to mount and unmount the drives so that they wouldn't clutter my desktop and to keep them "hidden".
The problem is that the disk ID under /dev changes everytime I reboot. Sometimes the drive mounted at /Volumes/backup1 will be at /dev/disk3s3 and sometimes it will be at /dev/disk4s3. Other times it will be at /dev/disk2s3.
Is there anyway to keep the disk ID static, or to just mount by the directory name? I'm running 10.5.8, with the latest updates. My script uses the `diskutil`command to mount and unmount the drives. Oh, and AFAIK, Time Machine only works with one drive as a backup.
I tried that once.. didn't seem to work:
$ sudo diskutil mount /Volumes/backup1
Unable to find disk for /Volumes/backup1
posted by triolus at 8:32 PM on August 14, 2009
$ sudo diskutil mount /Volumes/backup1
Unable to find disk for /Volumes/backup1
posted by triolus at 8:32 PM on August 14, 2009
I do believe the best way is to refer the volumes by their UUID. While a volume is mounted, do: diskutil info /dev/disk{3,4}s3 and get the volume UUID. Then diskutil mount $UUID.
posted by sbutler at 8:32 PM on August 14, 2009
posted by sbutler at 8:32 PM on August 14, 2009
If you want to keep the volumes hidden, set their hidden attribute. Then you can continue to access them with command-line utilities, without having them clutter your desktop and Finder windows.
posted by Blazecock Pileon at 12:06 AM on August 15, 2009
posted by Blazecock Pileon at 12:06 AM on August 15, 2009
Yup, UUID is the only way to refer to the disk in a dependable, static way.
posted by pmbuko at 7:14 AM on August 15, 2009
posted by pmbuko at 7:14 AM on August 15, 2009
You can also, in your script, get the ID for the volume on the fly. Replace Backup in the line below with the name of the volume you want to mount. (Be careful with the quotes.) This is the way I've done it in my backup script for years. This will work even if you need to reformat or replace the drive for some reason (as this will change its UUID) so long as the name is the same.
/usr/sbin/diskutil mount `/usr/sbin/disktool -l | /usr/bin/grep -e "'Backup'" | /usr/bin/grep -o '\(disk[0-9s]*\)'`
posted by kindall at 7:49 AM on August 15, 2009
/usr/sbin/diskutil mount `/usr/sbin/disktool -l | /usr/bin/grep -e "'Backup'" | /usr/bin/grep -o '\(disk[0-9s]*\)'`
posted by kindall at 7:49 AM on August 15, 2009
Thanks for the info sbutler! Using the UUID works perfectly.
posted by triolus at 10:00 AM on August 15, 2009
posted by triolus at 10:00 AM on August 15, 2009
This thread is closed to new comments.
posted by nathan_teske at 8:23 PM on August 14, 2009