mdconfig not returning error when listing a non-existing device.

Scot Hetzel swhetzel at
Fri May 11 18:41:57 UTC 2007

I created a vnode filesystem to use with mdconfig and added it to the
/etc/rc.conf file:

#ncvs filesystem to be mounted by zfs
mdconfig_md99="-t vnode -f /usr/home/ncvs.dsk"

The problem is that when the mdconfig2 rc script is executed, it fails
to create the md device.

hp010# ls /dev/md*
hp010# /etc/rc.d/mdconfig2 start md99
/etc/rc.d/mdconfig2: DEBUG: run_rc_command: start_precmd: [ -n
"${_mdconfig2_list}" ]
/etc/rc.d/mdconfig2: DEBUG: load_kld: geom_md kernel module already loaded.
/etc/rc.d/mdconfig2: DEBUG: run_rc_command: doit: mdconfig2_start
/etc/rc.d/mdconfig2: DEBUG: md99 config: -t vnode -f /usr/home/ncvs.dsk
/etc/rc.d/mdconfig2: DEBUG: md99 type: vnode
/etc/rc.d/mdconfig2: DEBUG: md99 dev: /dev/md99
/etc/rc.d/mdconfig2: DEBUG: md99 file: /usr/home/ncvs.dsk
/etc/rc.d/mdconfig2: DEBUG: md99 fs: /usr/home
/etc/rc.d/mdconfig2: DEBUG: md99 owner:
/etc/rc.d/mdconfig2: DEBUG: md99 perms:
/etc/rc.d/mdconfig2: DEBUG: md99 files:
/etc/rc.d/mdconfig2: DEBUG: md99 populate cmd:
/etc/rc.d/mdconfig2: ERROR: md99 already exists

This error comes from when it is checking if the device already exists:

if mdconfig -l -u ${_md} >/dev/null 2>&1; then
        err 3 "${_md} already exists"

The problem is that mdconfig -l doesn't return an error code when it
is asked to list a non-existant device.

hp010# ls /dev/md*
hp010# mdconfig -l -u md99 ; echo $?
hp010# mdconfig -a -t vnode -f /usr/home/ncvs.dsk -u md99 ; echo $?
hp010# mdconfig -l -u md0 ; echo $?
md0     vnode     5.0G  /usr/home/ncvs.dsk

This problem affects both the /etc/rc.d/mdconfig and mdconfig2 scripts.


NOTE: The attached patch adds mdconfig[,2]_list - its use is to allow
the scripts to configure md devices that don't start at 0.
No electrons were mamed while sending this message. Only slightly bruised.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mdconfig.patch
Type: text/x-diff
Size: 1333 bytes
Desc: not available
Url :

More information about the freebsd-current mailing list