PDA

View Full Version : Disable Automount or Mount All MSDOS filesystems in RO


sysnak
01-30-2007, 11:21 AM
Hi there;

I'm trying to use a mac to clone 2 external USB drives to eachother. Ordinarily, I plug in and run dd if=/dev/rdisk1 of=/dev/rdisk2 , etc. .

I need to keep these drives in a virgin state, so the problem I'm running into is that osx writes a .Trash and .Desktop file to any volume mounted as RW, either Fat16/Fat32 (MSDOS) or any other Read/Write volume that is mounted.

I'm trying to either
a) temporarily prevent auto-mounting of external hot-pluggable drives
or
b) make all MSDOS volumes mount as Read Only.

I've tried avenues under both methods, both :
a) did a ps -aux and killed both processes that had the text "automount" in them, no effect
b) edited fstab to try and encompass all MSDOS volumes, however I don't beleive this is working because either UUID or VolumeName must be specified for the entry... names or mount points which can't be known until the device is plugged in!!! (chicken or the egg problem).

perhaps I'm not throwing in the wildcard appropriately? I tried using an asterisk (*), but no effect.

Now today, I found something on the net about relocating a swap drive.


I notice that a variable called "${AUTODISKMOUNT:=-YES-}" ... is this user modifiable anywhere in the system?

Any ideas?



http://www.xlr8yourmac.com/OSX/OS_x_swapfile_notes.html

1) Back-up your /etc/rc file, because that is the file that we will be editing.
2) As root, open /etc/rc in a text editor and find the section that begins with:

##
# Start the virtual memory system.
##

ConsoleMessage "Starting virtual memory"

swapdir=/private/var/vm

3) Because OS X/Darwin normally mounts other disks *after* setting up swap, you must open /System/Library/StartupItems/Disks/Disks in a text editor and copy/paste the following lines to /etc/rc just before the section shown above:

##
# Mount any remaining filesystems
##

if [ ! -f /var/db/volinfo.database ]; then Uninitialized_VSDB=-YES-; fi

if [ "${AUTODISKMOUNT:=-YES-}" != "-NO-" ]; then

ConsoleMessage "Mounting media"

case ${AUTODISKMOUNT} in

-REMOVABLE-)
autodiskmountflags="-a" ;; # Mount removeable media
*)
autodiskmountflags="" ;;
esac

autodiskmount -v ${autodiskmountflags}
fi

if [ "${Uninitialized_VSDB:=-NO-}" = "-YES-" ]; then vsdbutil -i; fi

4) Now change the line 'swapdir=/private/var/vm' to the desired drive location...It should begin with /Volumes/. I've placed mine in /Volumes/harp/DO_NOT_TOUCH/.vm ... harp is the name of the volume. The directory DO_NOT_TOUCH is a visible warning, and the directory that will actually contain the swapfiles is invisible to the Finder because it has a "." in front of it.

I hope that makes sense...And don't get rid of the
/System/Library/StartupItems/Disks/ because other start-up items are dependent on it. Alternatively, you could probably create an OS X style StartupItem for starting up swap, but I'd rather have my swap ready earlier in the boot process.
Eugene Chan "

giskard22
01-30-2007, 03:27 PM
It looks like they're referring to editing /etc/rc, which is one of the scripts that initalizes the OS. Modifications in there would likely only effect the startup process, so it might solve your problem if the disks are already connected when you boot the computer. I would guess you would just need to add the line about AUTODISKMOUNT to /etc/hostconfig.

OTOH, I think OS 10.4 only automounts external devices when a user is logged in. So you could enable Remote Login (SHH), log out, connect the disks, and do what you need to do from another computer. I'd test that with an OK-to-modify disk first, though.

tlarkin
01-30-2007, 03:49 PM
not sure if this helps, but whenever I install windows on an intel mac I hide the partition via /etc/fstab and it works great, you can also configure this to make a volume read only.

in the terminal type this sudo pico /etc/fstab (or use whatever text editor you prefer)

add this line


LABEL=Windows XP none ntfs ro,noauto 0 0


the ro stands for mounting the volume as read only, and the no auto stands for code that tells the system not to automatically mount the volume at start up. I would have to mount it manually to get it to show up again in finder/aqua.

My volume's name is Windows XP so you would put the volume's name in there.

Now, if you have whole volumes that are in FAT32 format you can use UUID instead of the volume label. To do this, use this code:


diskutil info (drag the volume to the terminal and drop it after info, but make sure there is a space)


There you will see the UUID of the device, you can use that in fstab instead. so for you it may be this code, and this only applies if the whole volume is one file system and you want it mounted a certain way. I can't use UUID for my HD on the laptop because I have multiple partitions on the same device.

again sudo pico /etc/fstab


UUID-xxx-xxxx none fat32 ro,auto 0 0


You would plug in your UUID of that device. Now everytime that device is connected to your mac it will mount the way you want to. Notice that in the last code I had the fat32 volume automount but as read only

Hopefully this may give you a solution.

**EDIT**

Just reread your post and it seems I missed the fstab part the first time. However, if you are going to use the same drives over and over again UUID would work because that identifier number is unique to that device, just like a MAC address on a NIC. So you would have to plug the device in once to get the UUID, and then after that you would not have to.

Or you could just use Linux and do the same thing but with out the hassle.

biovizier
01-30-2007, 07:20 PM
Maybe this is being overly simplistic, but since automount mounts at "/Volumes", can you simply 'sudo chflags uchg /Volumes'? A device that is plugged in afterwards doesn't mount but does seem to show up in '/dev' so I would imagine it would be possible to mount them from the command line as "read only" (specifying an arbitrary mount point) or just running 'dd' directly (I haven't tested any of this). Don't forget to 'nouchg' afterward though...

sysnak
01-30-2007, 07:53 PM
Tlarkin, thanks very much for your input, however the main problem i am having here is that I don't know the volume name or UUID, and I can't plug it in to find out without osx touching it! Hence, the chicken and the egg problem.

biovizier, that sounds like a HELL OF AN IDEA! Thanks, I'm going to give it a try with a flash drive for testing...

sysnak
01-30-2007, 09:10 PM
it works! thanks!