From owner-freebsd-questions@FreeBSD.ORG Wed Mar 11 17:43:07 2009 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 818CA106564A for ; Wed, 11 Mar 2009 17:43:07 +0000 (UTC) (envelope-from rsmith@xs4all.nl) Received: from smtp-vbr16.xs4all.nl (smtp-vbr16.xs4all.nl [194.109.24.36]) by mx1.freebsd.org (Postfix) with ESMTP id EFC608FC08 for ; Wed, 11 Mar 2009 17:43:06 +0000 (UTC) (envelope-from rsmith@xs4all.nl) Received: from slackbox.xs4all.nl (slackbox.xs4all.nl [213.84.242.160]) by smtp-vbr16.xs4all.nl (8.13.8/8.13.8) with ESMTP id n2BHh5EB029244; Wed, 11 Mar 2009 18:43:05 +0100 (CET) (envelope-from rsmith@xs4all.nl) Received: by slackbox.xs4all.nl (Postfix, from userid 1001) id EF986BA9A; Wed, 11 Mar 2009 18:43:04 +0100 (CET) Date: Wed, 11 Mar 2009 18:43:04 +0100 From: Roland Smith To: Peter Steele Message-ID: <20090311174304.GA67007@slackbox.xs4all.nl> References: <21664605.661236783895798.JavaMail.HALO$@halo> <20138265.681236784246466.JavaMail.HALO$@halo> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="BXVAT5kNtrzKuDFl" Content-Disposition: inline In-Reply-To: <20138265.681236784246466.JavaMail.HALO$@halo> X-GPG-Fingerprint: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 X-GPG-Key: http://www.xs4all.nl/~rsmith/pubkey.txt X-GPG-Notice: If this message is not signed, don't assume I sent it! User-Agent: Mutt/1.5.19 (2009-01-05) X-Virus-Scanned: by XS4ALL Virus Scanner Cc: questions@freebsd.org Subject: Re: How to auto-detect a USB drive? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2009 17:43:07 -0000 --BXVAT5kNtrzKuDFl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Mar 11, 2009 at 08:10:46AM -0700, Peter Steele wrote: > >My question to you would be: What exactly do you mean by=20 > >"automatically detect"? The drive *is* automatically detected.=20 > >Should it be mounted afterwards?=20 >=20 > Yeah, I guess my wording was a little vague. I know that the system > automatically detects when a USB drive is inserted, and creates the > appropriate entries under /dev. I want to follow this up with having > the drive automatically mounted, and I'll then examine the USB drive > for specific files I expect to be present, and possible run something > that's installed on the disk, then unmount the disk. We want to use > this approach to deploy our software on large clusters of machines > that may not have an IP identity. The easiest way (I think) is to use devd, in combination with a USB drive that has a unique label. Say you have a USB drive formatted with a UFS filesystem. You use 'tunefs -L' to give this drive a unique label, e.g. 'FOO'. Then you can put the following in /etc/devd.conf notify 1000 { match "system" "DEVFS"; match "subsystem" "CDEV"; match "cdev" "/dev/ufs/FOO"; action "sh /usr/local/sbin/autorun /dev/ufs/FOO &"; }; Where the script /usr/local/sbin/autorun would contain the required actions (mount, check, run, umount, beep). The reason for using a labeled device is that you might not want to run the script on any old USB drive! If you want to use a FAT formatted drive you should use /dev/msdosfs/FOO for the path. Last week I submitted a patch to get this system and subsystem documented in the manual page of devd.conf. It should be in CURRENT now, and will be MFC'd to STABLE in a week or so. Roland --=20 R.F.Smith http://www.xs4all.nl/~rsmith/ [plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated] pgp: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 (KeyID: C321A725) --BXVAT5kNtrzKuDFl Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (FreeBSD) iEYEARECAAYFAkm3+CgACgkQEnfvsMMhpyWe8gCeNYpK/Q6l20TwbolEMRt1gC2q 87oAn0vaaNoxWKCtIJo3SXUWWEATTCdf =a9G5 -----END PGP SIGNATURE----- --BXVAT5kNtrzKuDFl--