Jump to content

Unmount volumes at login


4 posts in this topic

Recommended Posts

Hey everyone, I finished my first real AppleScript last night. What it does, is that it will unmount specified volumes. Simple, but it also does it based on the computer architecture. I found this to be important as I have a firewire drive with 5 partitions, and want to close 4 of them, based on what system im running. Take a look and feel free to play with it :).

 

 

tell application "Finder"
display alert "Unmounting extra volumes, please wait." as informational buttons "OK" giving up after 2
end tell
tell application "Terminal"
activate
set HardwareType to do shell script "uname -p"
if HardwareType is "i386" then
	do script "diskutil unmount \"/Volumes/Intel Install\"" in ¬
		window frontmost
	delay 1
	do script "diskutil unmount \"/Volumes/PowerPC Install\"" in ¬
		window frontmost
	delay 1
	do script "diskutil unmount \"/Volumes/PowerPC Firewire\"" in ¬
		window frontmost
	delay 1
	do script "diskutil unmount \"/Volumes/Media Files\"" in ¬
		window frontmost
end if
if HardwareType is "PPC" then
	do script "diskutil unmount \"/Volumes/Intel Install\"" in ¬
		window frontmost
	delay 1
	do script "diskutil unmount \"/Volumes/PowerPC Install\"" in ¬
		window frontmost
	delay 1
	do script "diskutil unmount \"/Volumes/Intel Firewire\"" in ¬
		window frontmost
	delay 1
	do script "diskutil unmount \"/Volumes/Media Files\"" in ¬
		window frontmost
end if
delay 3
quit
end tell
tell application "Finder"
display alert "System is now ready." as informational buttons "OK" giving up after 2
end tell

Link to comment
Share on other sites

I had some problems with this original script as sometimes it would go too fast that not all the volumes wount unmount. I suggest increasing the delay times to 2 or 3 seconds so theres adequate time for each command to finish :thumbsup_anim:.

Link to comment
Share on other sites

Apple script is heavy and take some time to load. Better solution is to put shell script in startup files

 

 

cd /System/Library/StartupItems/Disks/

sudo nano Disks

 

add after "/sbin/autodiskmount -va"

 

PATH=$PATH:/usr/local/bin
export PATH
umount /Volumes/Win_XP
umount /Volumes/30\ GB\ NTFS

 

where Win_XP and 30\ GB\ NTFS are disk that you want to unmount

Link to comment
Share on other sites

 Share

×
×
  • Create New...