From owner-freebsd-questions@FreeBSD.ORG Wed Mar 11 14:52:54 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 E68AB10656CD for ; Wed, 11 Mar 2009 14:52:54 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) by mx1.freebsd.org (Postfix) with ESMTP id A5FD68FC18 for ; Wed, 11 Mar 2009 14:52:54 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r55.edvax.de (port-92-196-109-64.dynamic.qsc.de [92.196.109.64]) by mx01.qsc.de (Postfix) with ESMTP id 119323D18C; Wed, 11 Mar 2009 15:52:49 +0100 (CET) Received: from r55.edvax.de (localhost [127.0.0.1]) by r55.edvax.de (8.14.2/8.14.2) with SMTP id n2BEqhLS002864; Wed, 11 Mar 2009 15:52:44 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Wed, 11 Mar 2009 15:52:43 +0100 From: Polytropon To: Peter Steele Message-Id: <20090311155243.57fdcb25.freebsd@edvax.de> In-Reply-To: <10423240.561236782522127.JavaMail.HALO$@halo> References: <7280394.541236782303889.JavaMail.HALO$@halo> <10423240.561236782522127.JavaMail.HALO$@halo> Organization: EDVAX X-Mailer: Sylpheed 2.4.7 (GTK+ 2.12.1; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2009 14:52:55 -0000 On Wed, 11 Mar 2009 07:42:04 -0700 (PDT), Peter Steele wrote: > I want to have a process running on my FreeBSD box that > automatically detects when a USB drive is inserted. What's > the easiest way to accomplish this? I know I could simply > monitor /var/log/messages and look for the appropriate > events to appear, but is there a more elegant way? The system will monitor it itself. :-) My question to you would be: What exactly do you mean by "automatically detect"? The drive *is* automatically detected. Should it be mounted afterwards? The creation of the device files (after system startup) is controlled by the file /etc/devfs.rules. You can use automounters to automatically mount devices when they appear. In order how to determine file systems, slices and partitions on such an USB device, you could, for example, have a look at how FreeSBIE does it. Additionally, there are already tools integrated in KDE and Gnome that automount USB devices. -- Polytropon >From Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...