From owner-freebsd-questions Sat Feb 22 5:47:36 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8C1E137B401 for ; Sat, 22 Feb 2003 05:47:34 -0800 (PST) Received: from gs166.sp.cs.cmu.edu (GS166.SP.CS.CMU.EDU [128.2.205.169]) by mx1.FreeBSD.org (Postfix) with SMTP id B684A43F75 for ; Sat, 22 Feb 2003 05:47:33 -0800 (PST) (envelope-from dpelleg@gs166.sp.cs.cmu.edu) To: Darren Spruell Cc: questions@freebsd.org Subject: Re: USB flash drive mount - da device? References: <3E569473.8050003@sento.com> From: Dan Pelleg Date: 22 Feb 2003 08:46:55 -0500 In-Reply-To: <3E569473.8050003@sento.com> Message-ID: Lines: 55 User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Cuyahoga Valley) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Darren Spruell 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