Skip site navigation (1)Skip section navigation (2)
Date:      22 Feb 2003 08:46:55 -0500
From:      Dan Pelleg <daniel+bsd@pelleg.org>
To:        Darren Spruell <darren_spruell@sento.com>
Cc:        questions@freebsd.org
Subject:   Re: USB flash drive mount - da device?
Message-ID:  <u2su1ewctrk.fsf@gs166.sp.cs.cmu.edu>
In-Reply-To: <3E569473.8050003@sento.com>
References:  <3E569473.8050003@sento.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Darren Spruell <darren_spruell@sento.com> writes:

> Greetz,
> 
> I use a USB pocket drive and am having the hardest time figuring out how to
> mount it into the filesystem. Following are what I thought to be important:
[snip]
> Generally I use the command 'mount -t msdos /dev/rda0s1 /mnt' to mount this
> to my filesystem. Sometimes it works, sometimes it fails. When it does work
> I can only mount it as root. In order to be able to mount this as a regular
> user, do I have to put some flags into a line in /etc/fstab? What would be
> the best way to make this drive user mountable?
> 
> The other question is, is there a better way to mount up the device or
> control it via a usb tool or is the way I am doing it correct?
> 

I'll tell you what I do with a CompactFlash card, which I believe should
work for you as well. Most of the time I just need to copy over the stuff
from the memory card to local disk. So I have a script that:

1. mounts the device
2. copies everything over from the card to a directory on the local disk
3. unmounts

This script is hooked from pccardd (and in your case it'll be hooked from
usbd) so it runs as root.

I'm using the -nrp flags to cp, so it won't overwrite any existing
files. This works ok if whatever is writing to the device is always
generating fresh names for new files (which is true in my case). If there
is possible name-collision, you can change the script to put everything in
a directory with a timestamp in its name.

Now, for the times I want to directly manipulate the CF card (usually big
deletions), I use the automounter. It'll automatically mount the card when
I access /auto/localhost/cf, and unmount it after 5 minutes of no
access. You need to remember not to pull the card/usb-thingie out while
it's still mounted (if you're in a hurry, become root and umount). For more
details about this, I recommend reading
http://www.daemonnews.org/200202/automounting.html

Also, for msdos mounts, it's usually most convenient to chown the directory
underneath the mount point so it's owned by the primary user of the machine
and his/her group. This way, once the files are copied over by the script,
they're still owned by "you" and you can write or delete them easily (I
found that the -u and -g flags to mount_msdos don't help you here: cp -r
will still create any intermediate directories as root/wheel).

Note you can use either the usbd/pccardd hook or the automount method, or
both - neither depends on the other to work.

-- 

  Dan Pelleg

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?u2su1ewctrk.fsf>