#!/bin/bash # Helper to call 'dmsetup setup' without syncing with udev # and then actively create the devices with the mknodes command. # Either pass the table contents as $2, or pipe them into the function # dmsetup_create_noudevsync [table] ( set -eo pipefail if [ -n "$2" ]; then printf "%s\n" "$2" | dmsetup create "$1" --noudevsync else dmsetup create "$1" --noudevsync fi dmsetup mknodes --noudevsync "$1" echo "dm: Created $1" ) ret=$? [ -b "/dev/mapper/$1" ] || ret=99 if [ $ret -ne 0 ]; then echo "dm: Error creating $1, removing..." dmsetup remove --noudevsync "$1" fi exit $ret