2009-01-20 22:10:30 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2009-01-21 00:57:45 +00:00
|
|
|
# 4 Device Loopback Raid-0 Configuration
|
2009-01-20 22:10:30 +00:00
|
|
|
#
|
|
|
|
|
2009-01-21 00:57:45 +00:00
|
|
|
FILES="/tmp/zpool-vdev0 \
|
|
|
|
/tmp/zpool-vdev1 \
|
|
|
|
/tmp/zpool-vdev2 \
|
|
|
|
/tmp/zpool-vdev3"
|
|
|
|
DEVICES=""
|
2009-01-20 22:10:30 +00:00
|
|
|
|
|
|
|
zpool_create() {
|
2009-01-21 00:57:45 +00:00
|
|
|
for FILE in ${FILES}; do
|
2009-07-21 23:17:54 +00:00
|
|
|
DEVICE=`unused_loop_device`
|
2009-01-21 00:57:45 +00:00
|
|
|
msg "Creating ${FILE} using loopback device ${DEVICE}"
|
|
|
|
rm -f ${FILE} || exit 1
|
2009-01-21 05:34:29 +00:00
|
|
|
dd if=/dev/zero of=${FILE} bs=1024k count=256 &>/dev/null ||
|
2009-01-21 00:57:45 +00:00
|
|
|
die "Error $? creating ${FILE}"
|
|
|
|
losetup ${DEVICE} ${FILE} ||
|
|
|
|
die "Error $? creating ${FILE} -> ${DEVICE} loopback"
|
|
|
|
DEVICES="${DEVICES} ${DEVICE}"
|
2009-01-20 22:10:30 +00:00
|
|
|
done
|
|
|
|
|
2009-01-21 00:57:45 +00:00
|
|
|
msg ${CMDDIR}/zpool/zpool create ${ZPOOL_NAME} ${DEVICES}
|
|
|
|
${CMDDIR}/zpool/zpool create ${ZPOOL_NAME} ${DEVICES} || exit 1
|
2009-01-20 22:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
zpool_destroy() {
|
2009-01-20 23:34:38 +00:00
|
|
|
msg ${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME}
|
2009-01-20 22:10:30 +00:00
|
|
|
${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME}
|
|
|
|
|
2009-01-21 00:57:45 +00:00
|
|
|
for FILE in ${FILES}; do
|
2009-01-21 05:34:29 +00:00
|
|
|
DEVICE=`/sbin/losetup -a | grep ${FILE} | head -n1|cut -f1 -d:`
|
2009-01-21 00:57:45 +00:00
|
|
|
msg "Removing ${FILE} using loopback device ${DEVICE}"
|
|
|
|
losetup -d ${DEVICE} ||
|
|
|
|
die "Error $? destroying ${FILE} -> ${DEVICE} loopback"
|
|
|
|
rm -f ${FILE} || exit 1
|
2009-01-20 22:10:30 +00:00
|
|
|
done
|
|
|
|
}
|