Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

LERsince1991

macrumors 65816
Original poster
Jul 24, 2008
1,245
37
UK
Hi,

Context
I am trying to set up my drives for an automated backup workflow using Carbon Copy Cloner.


I didn't want the cloned drives mounted all the time - just when they are to be backed up.

I edited the fstab file through terminal to noauto mount the backup drives on boot.

I set up some small scripts to mount a drive.
Set these to launch from iCal 15 mins before CCC clones it.
Then once the clone is complete CCC also unmounts that drive before moving onto the next clone job.

The Problem
The issue I have is that the script I am using to mount the drive is referring to the Disk Identifier of each drive which is apparently changing when I reboot, or unplug and replug the drives in a different usb port - I'm on a macbook.

The script is:
Code:
do shell script "diskutil mount /dev/disk4s2"

The disk identifier is obtained from the info in disk utility and is correct at that time as I have tested it and it works. - but after reboot etc, the DI has changed.

The solution
How can I modify the script to mount using the disk UUI (UUID) instead which is unique and always constant.

Alternatively how can I set the Disk Identifier of these drives to always mount to a specific number which is reserved for that drive only?
 
What OS version is this for?


The man page for diskutil says this about how to identify disks:
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/diskutil.8.html
A device parameter to any of the above commands (except where explicitly required otherwise) is usually any of the following:

• The disk identifier (see below). Any entry of the form of disk*, e.g. disk1s9.

• The device node entry containing the disk identifier. Any entry of the form of /dev/disk*,
e.g. /dev/disk2.

• The volume mount point. Any entry of the form of /Volumes/*, e.g. /Volumes/Untitled.

• The Universally Unique Identifier or UUID. Any entry of the form of e.g.
11111111-2222-3333-4444-555555555555.
So anywhere you would give an identifier like disk4s2 you can give the UUID instead. Given this principle, which you will need to test and confirm, try the following.

1. Determine the UUID of the disk. To do this, you'll need to manually mount it and determine its disk identifier. So mount the disk, then use this command in Terminal:
Code:
diskutil list

2. Take note of the disk identifier for the desired disk in the output. Let's say it's disk4s2 for now. You then use this command in Terminal:
Code:
diskutil info disk4s2 | grep -i uuid
3. The above command should output a line that lists the volume UUID. You can select, copy, and paste it from the Terminal window.

4. To test that the UUID is correct, use this command in Terminal:
Code:
diskutil info YOUR_UUID_HERE
The output of this command should be a lengthy list of info about the disk volume. If so, confirm it's the disk volume you want to use.
As noted in step 3, don't retype the UUID, simply select it using the mouse, cmd-C, then paste (cmd-V) in the Terminal window.

5. Finally, edit your script and replace the /dev/diskwhatever with the entire UUID. Test the script by unmounting the volume and seeing if it works.
 
Thanks both, I didn't realise CCC does this anyway, but I did try it and it didn't seem to mount it when it was scheduled to clone - I will try again.

Anyway, the scripts still useful as I have added shortcuts to a folder so I can mount them quicker rather than using disk utility in future when I need access.

Thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.