diff --git a/scripts/zpool-config/hda-raid0.cfg b/scripts/zpool-config/hda-raid0.cfg deleted file mode 100644 index 13a55e194c..0000000000 --- a/scripts/zpool-config/hda-raid0.cfg +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# -# Single disk /dev/hda Raid-0 Configuration -# - -DEVICES="/dev/hda" - -${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES} || exit 1 diff --git a/scripts/zpool-config/hda-raid0.sh b/scripts/zpool-config/hda-raid0.sh new file mode 100644 index 0000000000..9ddfdb3629 --- /dev/null +++ b/scripts/zpool-config/hda-raid0.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# +# Single disk /dev/hda Raid-0 Configuration +# + +DEVICES="/dev/hda" + +zpool_create() { + msg "${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES}" + ${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES} || exit 1 +} + +zpool_destroy() { + msg "${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME}" + ${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME} || exit 1 +} diff --git a/scripts/zpool-config/lo-raid0.cfg b/scripts/zpool-config/lo-raid0.cfg deleted file mode 100644 index 75a411c9b5..0000000000 --- a/scripts/zpool-config/lo-raid0.cfg +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# -# 5 Device Loopback Raid-0 Configuration -# - -DEVICES="/tmp/zpool-vdev0 \ - /tmp/zpool-vdev1 \ - /tmp/zpool-vdev2 \ - /tmp/zpool-vdev3 \ - /tmp/zpool-vdev4" -DEVICE_SIZE=512 - -for DEV in ${DEVICES}; do - msg "Creating ${DEV} loopback device (${DEVICE_SIZE} Mib)" - rm -f ${DEV} || exit 1 - dd if=/dev/zero of=${DEV} bs=1024k count=${DEVICE_SIZE} &>/dev/null || exit 1 - losetup `/sbin/losetup -f` ${DEV} || exit 1 -done - -${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES} || exit 1 - diff --git a/scripts/zpool-config/lo-raid0.sh b/scripts/zpool-config/lo-raid0.sh new file mode 100644 index 0000000000..fb40b15868 --- /dev/null +++ b/scripts/zpool-config/lo-raid0.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# +# 5 Device Loopback Raid-0 Configuration +# + +DEVICES="/tmp/zpool-vdev0 \ + /tmp/zpool-vdev1 \ + /tmp/zpool-vdev2 \ + /tmp/zpool-vdev3 \ + /tmp/zpool-vdev4" +DEVICE_SIZE=512 + +zpool_create() { + for DEV in ${DEVICES}; do + LO=`/sbin/losetup -f` + msg "Creating ${DEV} using loopback device ${LO}" + rm -f ${DEV} || exit 1 + dd if=/dev/zero of=${DEV} bs=1024k count=${DEVICE_SIZE} &>/dev/null || exit 1 + losetup ${LO} ${DEV} || exit 1 + done + + msg "${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES}" + ${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES} || exit 1 +} + +zpool_destroy() { + msg "${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME}" + ${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME} + + for DEV in ${DEVICES}; do + LO=`/sbin/losetup -a | grep ${DEV} | head -n1 | cut -f1 -d:` + msg "Removing ${DEV} using loopback device ${LO}" + rm -f ${DEV} || exit 1 + done +} diff --git a/scripts/zpool-config/sda-raid0.sh b/scripts/zpool-config/sda-raid0.sh new file mode 100644 index 0000000000..aa43b56517 --- /dev/null +++ b/scripts/zpool-config/sda-raid0.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# +# Single disk /dev/sda Raid-0 Configuration +# + +DEVICES="/dev/sda" + +zpool_create() { + msg "${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES}" + ${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES} || exit 1 +} + +zpool_destroy() { + msg "${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME}" + ${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME} || exit 1 +} diff --git a/scripts/zpool-config/x4550-raid0.cfg b/scripts/zpool-config/x4550-raid0.sh similarity index 70% rename from scripts/zpool-config/x4550-raid0.cfg rename to scripts/zpool-config/x4550-raid0.sh index 05bbfdf77f..32e608fcef 100644 --- a/scripts/zpool-config/x4550-raid0.cfg +++ b/scripts/zpool-config/x4550-raid0.sh @@ -12,4 +12,12 @@ DEVICES="/dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf \ /dev/sdak /dev/sdal /dev/sdam /dev/sdan /dev/sdao /dev/sdap \ /dev/sdaq /dev/sdar /dev/sdas /dev/sdat /dev/sdau /dev/sdav" -${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES} || exit 1 +zpool_create() { + msg "${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES}" + ${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES} || exit 1 +} + +zpool_destroy() { + msg "${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME}" + ${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME} +} diff --git a/scripts/zpool-create.sh b/scripts/zpool-create.sh index 4b8e3a8bf2..e613e671c8 100755 --- a/scripts/zpool-create.sh +++ b/scripts/zpool-create.sh @@ -14,8 +14,9 @@ DESCRIPTION: OPTIONS: -h Show this message -v Verbose - -c Zpool configuration - -p Zpool name + -c Configuration for zpool + -p Name for zpool + -d Destroy zpool (default create) EOF } @@ -39,8 +40,9 @@ check_config() { ZPOOL_CONFIG=zpool_config.cfg ZPOOL_NAME=tank +ZPOOL_DESTROY= -while getopts 'hvc:p:' OPTION; do +while getopts 'hvc:p:d' OPTION; do case $OPTION in h) usage @@ -55,6 +57,9 @@ while getopts 'hvc:p:' OPTION; do p) ZPOOL_NAME=${OPTARG} ;; + d) + ZPOOL_DESTROY=1 + ;; ?) usage exit @@ -69,6 +74,12 @@ fi check_config || die "${ERROR}" . ${ZPOOL_CONFIG} +if [ ${ZPOOL_DESTROY} ]; then + zpool_destroy +else + zpool_create +fi + if [ ${VERBOSE} ]; then echo echo "zpool list"