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

Remote mounting of disk images without logged in local user System
Reader ssevenup emailed me with a pointer to a thread on the forum site regarding how to mount a disk image from the Terminal (perhaps via SSH while trying to do remote maintenance) when no primary user was logged in on the machine.

The short answer is that, prior to running hdiutil mount some_image.dmg, if nobody is logged in on the machine you must first use disktool -c UID, where UID is a valid user's UID. For example, the first OS X user you created has a UID of 501, root has a UID of 0. So to mount a disk image named "newprogram.dmg" as your normal admin user via SSH when that admin user wasn't logged into the GUI locally, you'd type:
 % disktool -c 501
 % hdiutil mount newprogram.dmg
The disk should mount and be visible in the /Volumes directory. You can read a bit more about this in this archived lists.apple.com email.
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[5,160 views]  

Remote mounting of disk images without logged in local user | 8 comments | Create New Account
Click here to return to the 'Remote mounting of disk images without logged in local user' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Remote mounting of disk images without logged in local user
Authored by: discordantus on May 06, '03 12:43:39PM
Most people will want to use their own user id. Since teh shell sets a variable for this, you can use that instead of determining and typing in your UID... Thusly:

disktool -c $UID

[ Reply to This | # ]

Remote mounting of disk images without logged in local user
Authored by: sjk on May 06, '03 09:48:02PM

FYI: bash and zsh set the UID environment variable; tcsh
doesn't.



[ Reply to This | # ]
Remote mounting of disk images without logged in local user
Authored by: sjk on May 06, '03 09:50:38PM

Whoops... UID is a regular shell variable, not an environment
variable.



[ Reply to This | # ]
Remote mounting of disk images without logged in local user
Authored by: googoo on May 07, '03 08:58:56AM

Tcsh sets the variable $uid (lowercase) instead, and it is a shell variable, not an environment variable.

-Mark



[ Reply to This | # ]
Remote mounting of disk images without logged in local user
Authored by: randycarpenter on May 06, '03 10:49:51PM

You can also mount disk images remotely while someone is
logged in if you have a root shell, by using "diskutil -c 0". The
user will notice the disk icon appear on their desktop when you
"hdiutil mount" an image. I'm not sure but I think they can
unmount it unless you're shell's current working directory is in
the disk image directory (e.g. /Volumes/yadayadayada).



[ Reply to This | # ]
Remote mounting of disk images without logged in local user
Authored by: ssevenup on May 06, '03 11:35:47PM

I wonder if SetFile or one of the disk tools (in a shell script) would mount it hidden? Then I wonder if root can still get into it once it's mounted? This could be handy for remote admin. tasks.

--MM

---
Mark Moorcroft
ELORET Corp. - NASA/Ames RC
Sys. Admin.



[ Reply to This | # ]
Remote mounting of disk images without logged in local user
Authored by: randycarpenter on May 08, '03 11:11:09PM
We remotely install stuff like this all the time but haven't figured out how to hide it from the user yet. Here's a sample script that installs Java 1.4.1:
#!/bin/sh
#
# 5/7/03 - Install Java 1.4.1
#
COLLDIR="insert directory here that contains java 1.4.1 dmg 
file)"

# Change the current user to root (UID=0)
disktool -c 0 || exit 1

hdiutil mount $COLLDIR/Java1.4.1.dmg || exit 1
installer -pkg '/Volumes/Java 1.4.1 Update/Java1.4.1.pkg' -
target / || exit 1
DEV=`/sbin/mount | grep '/Volumes/Java 1.4.1 Update' | cut -
d" " -f1` || exit 1
hdiutil detach $DEV || exit 1

# hmm...installer seems to chmod g+w / which breaks 
sendmail.
chmod g-w / || exit 1

exit 0
The macosxhints editor is causing truncation of the commands in the script so you will need to do some editing (grrr).

You can also use this technique with typical "drag and drop" installs using the "ditto -rsrsFork" command. The frustrating this is that some vendors release binary installers (i.e. no convenient .pkg or .dmg files) so you have to install them and then figure out what files it installed, then create a .dmg after the fact. Is there a better way?

One other gotcha is that some installers (e.g. QuickTime 6.2) insist on popping up windows in Aqua for you to click which frustrates us remote installers. I suppose that an AppleScript would solve the problem but I haven't be ventured into that territory yet.

[ Reply to This | # ]
In Panther, with fast user switching
Authored by: aixccapt99 on Dec 31, '03 03:23:11PM

In Panther, if you are logged into the machine but have Fast-User-Switched to the login window, you don't need to perform the disktool step to accomplish remote mounting. Just issue the hdiutil command as described above.



[ Reply to This | # ]