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

Keep a single partition mounted when ejecting others Desktop
I have a very large external Firewire drive with multiple partitions. Most of the time, i only want the Scratch partition mounted. But if I drag any one partition to the Trash to eject it, all partitions on the volume will unmount.

To prevent this, I could use certain applications to just unmount the unneeded partitions, use a utility to just mount that particular partition, or I can keep open a file on the Scratch partition when ejecting the others. So, I keep a simple AppleScript open at the top level of that partition. The script unmounts the partitions and quits. Because the script is open, the Scratch partition won't eject.
    •    
  • Currently 2.50 / 5
  You rated: 4 / 5 (2 votes cast)
 
[6,902 views]  

Keep a single partition mounted when ejecting others | 9 comments | Create New Account
Click here to return to the 'Keep a single partition mounted when ejecting others' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Keep a single partition mounted when ejecting others
Authored by: kirkmc on Mar 31, '05 10:25:53AM

If you use Terminal, simply cd into the volume; you don't need to have an actual file open. As long as Terminal is open and the pwd is on the volume, you won't be able to eject it.

---
Read my blog: Kirkville -- http://www.mcelhearn.com
Musings, Opinion and Miscellanea, on Macs, iPods and more



[ Reply to This | # ]
Keep a single partition mounted when ejecting others
Authored by: chabig on Mar 31, '05 10:45:24AM

You can mount and unmount individual partitions with Disk Utility.

Chris



[ Reply to This | # ]
Keep a single partition mounted when ejecting others
Authored by: rotero on Mar 31, '05 12:10:09PM

Could you provide the text of this script? I've been using Disk Utility to unmount individual partitions on a drive, but this is obviously a lot easier and more efficient.



[ Reply to This | # ]
More info...
Authored by: victory on Mar 31, '05 08:07:09PM
More info in this hint.

[ Reply to This | # ]
Keep a single partition mounted when ejecting others
Authored by: hypert on Mar 31, '05 09:54:23PM
I have a simple AppleScript which I use to unmount disks. Mostly I use this to unmount shared drives and disk images if they're piling up, but the same method should work for local drives and partitions.

tell application "Finder"
	set bootDisk to name of startup disk
	set otherDisks to every disk whose (name is not bootDisk) and (name is not "Media")
	repeat with myDisk in otherDisks
		try
			eject myDisk
		end try
	end repeat
end tell


[ Reply to This | # ]
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 | # ]