Script to automatically UNMOUT all disks EXCEPT Booting Disk
The following script works directly as "AppleScript Editor" script or application (without any extra modification required) to automatically unmount the "Macintosh HD" disk after booting from other external disk:
---------------------
set volname to "Macintosh HD" -- # name of target volume
set p to (POSIX path of (volname & ":" as alias))'s text 1 thru -2
set sh to "diskutil umount " & quoted form of p & " &> /dev/null &"
do shell script sh
---------------------
How to modify it (or create a new one from scratch) to unmount all disks (except the booting one, of course), whatever their names and number?
Better if the script does not issue any confirmation or warning of any kind, but works in the background without any feedback to the user.
That is great to automatically unmount ALL disks (except the booting one) after rebooting or booting, saving energy, heat, noise and speeding up the Mac performance (eg., when selecting save as, etc, since such unused disks do not show), extending the life of the unused disks.
Of course, any disk can be later on manually mounted using the Disk Utility at any time, if required.
Thanks.