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


Click here to return to the '10.5: Mount a partition or volume on demand' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.5: Mount a partition or volume on demand
Authored by: pub3abn on Aug 12, '09 08:03:21AM

This solution sounds nice. An alternative solution, for those who like GUI interfaces, is to use Lingon (http://sourceforge.net/projects/lingon/)

In Lingon, create a User Daemon.

You will need to give it a name. Use something like the following (it needs to be in the reversed hostname format, but otherwise it can be anything you want):

com.yourusername.UnmountMyDisk

The command will take the form:

/usr/bin/hdiutil unmount /dev/disk1s10

...where "disk1s10" is the name of the disk. Alternatively, in place of "/dev/disk1s10", I believe you can use the format "/Volumes/volumename" ... but I have not tried that.

Then tick the checkbox for "Run it when it is loaded by the system" (or "RunAtLoad" in older versions of the app). And then save.

This will run at startup, before anyone logs in. Seems to work great, and as I use Lingon for other things, it fits well in my workflow. I know I won't forget where the setting is or how to change it.

[ Reply to This | # ]

10.5: Mount a partition or volume on demand
Authored by: pub3abn on Aug 12, '09 08:07:15AM

I failed to mention that Lingon is simply a GUI for editing OS X's launchd daemon. It does not add any new background tasks or hacks to your system.



[ Reply to This | # ]
10.5: Mount a partition or volume on demand
Authored by: mmnw on Aug 12, '09 08:57:57AM

Your solution will only work for disks connected at startup, not for USB, Firewire or external SATA devices connected afterwards. Also, the device will be mounted, and then unmounted. I don't know, but eventually OS X will work on the drive before the unmount command is executed (i.e. TimeMachine or Spotlight).

I should also add: you can only use the /dev/disk** part with internal drives, not with externals. The reason being the actual disk number may change depending on the port the disk is connected to and the order in which the disks are connected.

You can use the /Volume/Partition_Name for unmounting (I have tested it). But what you should use is the UUID of the partition, which can be determined with diskutil info.

Also, you probably shouldn't use hdiutil (I know, it works ...), but diskutil as this hint suggests. hdiutil was made to manage disk images (like a dmg), diskutil to manage actual disks. Read the man hdiutil and man diskutil for further information.

So the command would actually look like this:

/usr/bin/diskutil unmount UUID-number


[ Reply to This | # ]
10.5: Mount a partition or volume on demand
Authored by: pub3abn on Aug 12, '09 12:46:55PM

Thanks, that was helpful.

In my case, I am unmounting a partition of an internal drive. I don't know about Spotlight, but it seems that Time Machine is only active when a user is logged in. In any case, we've never had any problems with corruption or failure to unmount, and I've been using that unmount technique for probably a year or more. But if I get around to tinkering with it again, I may try the alternate command you suggested.



[ Reply to This | # ]
10.5: Mount a partition or volume on demand
Authored by: mmnw on Aug 13, '09 03:27:00AM

I also am not sure if it can cause problems. Guess it won't. Since you are unmounting it grafecully without force.
But it could take longer than not mounting it at all. I'm pretty sure spotlight starts it's indexing process even if no user is logged in. Also I don't know if spotlight is already running at this point of boot.
So in the end, it's just a matter of elegance. Not mounting seems more "right" to me than mounting/unmounting ;)



[ Reply to This | # ]