Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Jan 2006 16:55:59 -0500 (EST)
From:      Ensel Sharon <user@dhp.com>
To:        freebsd-questions@freebsd.org
Subject:   shell scripting question (mdconfig device choosing)
Message-ID:  <Pine.LNX.4.21.0601241650570.8684-100000@shell.dhp.com>

next in thread | raw e-mail | index | archive | help

Hello,

When I mdconfig a device and _do not_ specify a particular numbered md
device (with the -u flag), it just chooses an unused device number for
me.  Which makes me happy.

Unfortunately, mdconfig chooses the next available device, from the
highest device currently in use, regardless of whether or not there are
much lower devices unused.

For instance, if I have md0 and md1 in use, mdconfig will auto choose
md2.  Good.  However if I only have md10 and md11 in use, mdconfig will
NOT choose md0, it will choose md12.

I need it to choose the lowest available unused device.

How can I do this in a bit of /bin/sh shell code ?  I can check what
devices are in use with `mdconfig -l`, like so:

# mdconfig -l
md0

and I know how to use awk to strip away the leading "md" from each piece
of the output ... but I do not know how to take output like:

8 9 11 14

and decide that the lowest available number is "0".  How can I do this ?

Thank you.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.21.0601241650570.8684-100000>