Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A contextual menu item to unmount parttions' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A contextual menu item to unmount parttions
Authored by: hombre on Apr 03, '05 09:18:59AM
As alluded to elsewhere, disktool with the -p option unmounts partitions, but requires the device name rather than the volume name for input. The following script lets you use the volume name:
disktool -p `df | grep $1 | awk '/\/dev\/disk[0-9]*/ {print substr($1,6,100)}'`
If you use OnMyCommand, this can be made into a convenient contextual menu item in the Finder as below. You can then select all the partitions you want to unmount simultaneously.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>COMMAND_LIST</key>
  <array>
    <dict>
      <key>ACTIVATE_ONLY_IN</key>
      <array>
        <string>Path Finder</string>
        <string>Finder</string>
      </array>
      <key>ACTIVATION_MODE</key>
      <string>act_folder</string>
      <key>COMMAND</key>
      <array>
        <string>disktool -p `df | grep </string>
        <string>__OBJ_PATH__</string>
        <string> | awk '/\/dev\/disk[0-9]*/ {print substr($1,6,100)}'`</string>
      </array>
      <key>EXECUTION_MODE</key>
      <string>exe_shell_script_with_output_window</string>
      <key>NAME</key>
      <string>Unmount Partition</string>
      <key>SUBMENU_NAME</key>
      <string>..</string>
      <key>VERSION</key>
      <integer>1</integer>
    </dict>
  </array>
  <key>VERSION</key>
  <integer>2</integer>
</dict>
</plist>


[ Reply to This | # ]
diskutil vs. disktool
Authored by: sjk on Apr 03, '05 05:40:38PM
With diskutil unmount device the device can be a volume name.

[ Reply to This | # ]
diskutil vs. disktool
Authored by: hombre on Apr 08, '05 12:05:30AM

Well that is certainly more straightforward. Thanks. On the off-chance that I was not the only one who did not know that this has been around since Jaguar, Apple Technical Note TN2053 states: 'Supplemented the "disktool" command line tool (which was always intended as a test tool) with a more user-oriented "diskutil" command line tool. (r. 2817377).'



[ Reply to This | # ]
A contextual menu item to unmount parttions
Authored by: syzygies on Jan 18, '06 10:40:31AM
Here is an AppleScript snippet for extracting this name:

try
	set a to do shell script "diskutil list | egrep '^ +[[:digit:]]+: +[[:graph:]]+ +" & diskname & " +[.[:digit:]]+ GB +disk[[:alnum:]]+$'"
	do shell script "diskutil mount `echo '" & a & "' | sed 's/" & diskname & "//' | awk '{print $5}'`"
on error
	return false
end try

Most code has issues with spaces in volume names, or volume names containing other volume names as substrings. The above search pattern matches entire lines of the diskutil listing, then removes the name, to avoid these problems.

[ Reply to This | # ]