From owner-freebsd-questions@FreeBSD.ORG Thu Jan 5 00:59:54 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org 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 7B7B516A41F for ; Thu, 5 Jan 2006 00:59:54 +0000 (GMT) (envelope-from user@dhp.com) Received: from shell.dhp.com (shell.dhp.com [199.245.105.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id B455B43D55 for ; Thu, 5 Jan 2006 00:59:49 +0000 (GMT) (envelope-from user@dhp.com) Received: by shell.dhp.com (Postfix, from userid 896) id C13C1312F5; Wed, 4 Jan 2006 19:59:46 -0500 (EST) Date: Wed, 4 Jan 2006 19:59:46 -0500 (EST) From: user To: freebsd-questions@freebsd.org Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: how can I determine the lowest not-in-use md device (for use with mdconfig) ? 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: Thu, 05 Jan 2006 00:59:54 -0000 The command: mdconfig -l will tell me what md devices are in use currently on the system. I have a situation where I want to automatically mount a vnode filesystem with an md device ... and I won't know ahead of time which devices are in use ... So ... can anyone think of an elegant way to find the lowest available md device ? Basically, I want to know how to take thie output: # mdconfig -l md4 md0 # and find which md?, that is not in that list, is the lowest ... I don't even have a very good guess as to how to do this ... I am working this into a /bin/sh shell script. thanks.