actually, in my macbook, there is not one harddisk, there are two partitions of the same disk. but this should not affect the process - it should work with one partition just as well.
Actually, I believe you should use the volume name, rather than the physical disk name. But if you did the
"tell application "Finder" to get name of every disk" thing, then any name returned there should work.
I entered a message, but it seems not to have been posted.
The message to softwater was:
indeed: I tried your last script:
works perfectly well on the USB connected disk/partition (external);
it did not do anything to a disk/partition connected to the DVD sata connector (inside): not even the error message.
Obviously the script does not reach the internal dvd sata connector. ???
...yes, that is it.
connected an external drive with 2 partitions via firewire. recorded clicks to eject (as described in above post), then remounted and tried script.
script works fine - ejects both partitions without any problem on first try.
so what works on HD SATA, USB and firewire does not work on DVD SATA. strange.
now that we have cornered the problem, a solution still does not seem any closer to me than before... :-(
Thanks Lex and mdesignffm. Yup, it does seem to be the fact that we're dealing with the DVD bus that is the issue.
OK then, let's try a different approach. This time we're telling Applescript to invoke the Bash shell to do the dirty work:
set theDisk to "Media 300GB"
do shell script "diskutil umount " & quoted form of ("/Volumes/" & theDisk)
There's no error dialog in this one, but if you look in the bottom panel of the Applescript editor under 'Results' you should see whether the disk was unmounted or not.
I'll leave you to solve the mystery of ประเทศไทย on your own (Google, as ever, is your... )...
However, for the sake of completeness (and learning), and since we're in one of those all-too rare but nevertheless heart-warming 'caring and sharing' moments on ASC, I'd like to point out that there's a third way of tackling this problem. So far we have:
1. Don't mount the disk at all (see Leroy's link to Topher's article, marked as the Answer to the thread).
2. Unmount the disk automatically (as we've discovered together; don't forget to save the script as an .app and add to your login items)
3. Leave the disk mounted but have it power down if not in use.
The third option may be more suitable for some, particularly laptop users. After all, once the disk is powered down, it's not affecting system resources even though mounted.
By default, on battery power OS X powers down any disk after 10 minutes of inactivity. You can reduce this default time by manipulating the pmset power management settings in Terminal.
In Terminal.app, copy/paste this command:
sudo pmset -b disksleep 5
After pressing 'return' on your keyboard, you will need to enter an Admin password, which will be invisible when you type it (so type carefully!).
This tells OS X to power down any disk that has not been accessed for 5 minutes (if you want to change it back to the default setting use the same command and replace '5' with '10').
Note that this setting also applies to your startup disk, but since your startup disk is in more or less constant use, it's unlikely to be affected. However, the good thing about this command is OS X will immediately and automatically power the disk back up as soon as you do anything that calls a file on the disk (i.e., you don't have to do anything to get it to power up, OS X will handle it without your intervention).
Personally, I have this set to 5 minutes for my startup disk (I don't have a secondary internal) simply because my battery is 69% health and well past the stage it needs servicing. Having the disk power down after 5 instead of 10 minutes eeks out a bit of extra battery time when I'm not connected to the mains.
You can of course set the disksleep time to less than 5 minutes, but you probably don't want to for two reasons. One, because it affects all connected disks. And two because powering the disk up repeatedly after every, say, 2 minutes (say you're reading something on the net) will likely use more power over all than leaving the disk on. 5 minutes is a useful compromise, but it depends on the user. For your secondary disk, if you're not using it at all, it'll stay powered off after 5 minutes (but still mounted and available) until or unless you access it or call a file that resides on it.
So moved to Thailand, I remember something like Wales or so before ???
1. I do not want to unmount the HD that is in the DVD location: It is partitioned in 2 partitions: one for the daily clone, and one for some backups and the large Photo and Music libraries accessed by iTunes and the Photo apps that reside on the startup SSD.
2. I do not need to unmount the HD because it is accessed very regularly, and I not sure about the startup-gravel down procedure being non destructive.
3. Aha, I am aware of this but I did not find conclusive evidence that is is good or bad for the SSD. The battery is my least important issue in the MBP. When this "put the disks to sleep when possible" command (either in preferences or in Terminal) should be separate for each Sata port, so no, I have them powered continuesly.
4. I will use your script for the 2 external portable disks, that have together 3 partitions: one for (you guessed it already) a clone, and two for backups of my libraries.
Thanks for the lessons taught here, was fun....
Lex (Davos 1641m)