Attaching (vs. detaching) a USB disk with hdiutil?

For a very specific and very arcane reason, I need to be able to do this at the command line as opposed to physically plugging and unplugging.

So, if I can "hdiutil detach /dev/disk1s1" as an alternative to ejecting the disk icon, how do I do the reverse -- recreating at the command line what automount (I assume) does when I plug in the USB disk? (This is with the USB disk plugged in but not mounted.)


iBook G4 Mac OS X (10.3.9)

Posted on Jan 2, 2006 12:02 AM

Reply
7 replies

Jan 3, 2006 4:49 PM in response to Mark Jalbert

06:36 PM: ~ > diskutil mountDisk /dev/disk1s1
Disk Utility Tool ?2002-2003, Apple Computer, Inc.
Usage: diskutil [mount(Disk)|unmount(Disk)|eject] <force>
[Mount Point|Disk Identifier|Device Node]
Mount, unmount or eject disks or volumes.
force is only valid on unmount or unmountDisk.
Example: diskutil unmount /Volumes/SomeDisk

06:47 PM: ~ > disktool -m disk1s1
Cannot find device /dev/disk1s1

06:48 PM: ~ > disktool -m disk1
Cannot find device /dev/disk1

Jan 3, 2006 6:30 PM in response to jccc

Hi jccc,
I'm not sure from where "mountDisk" came but I gather that you figured out that the verb you want is simply "mount". Mounting and unmounting is the part of the process designed for user control so I think you have the most important information.

I don't think you're supposed to be able to eject and then remount. Eject and unmount are very different. Aside from doing everything unmount does ejecting also deletes the device file. Generally a device file is a prerequisite for mounting. While there may be some obscure command that tells the system (maybe diskarbitrationd) to rebuild the device tree, I've never heard of it. You might try sending diskarbitrationd a SIGHUP with "sudo killall -HUP diskarbitrationd". However, be ready with "sudo /sbin/SystemStarter start Disks" should diskarbitrationd die. Mac utilities don't always trap signals like their UNIX brethren. Of course I bet that causes the device tree to be rebuilt.

The simple "workaround" is to use it the way it was designed to be used. If you want to "forget about" the device for a while but not disconnect irreparably, unmount it. Ejecting should be reserved for the moment you actually wish to yank it out.
--
Gary
~~~~
Q. Doctor, Doctor, it hurts when I do this!
A. So don't do that.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Attaching (vs. detaching) a USB disk with hdiutil?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.