Add destroy functionality to zpool create, needed for generic use by zpios.sh
This commit is contained in:
parent
5bf49743a6
commit
db210bf236
|
@ -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
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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}
|
||||
}
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue