diff --git a/scripts/zpool-config/dm0-raid0.sh b/scripts/zpool-config/dm0-raid0.sh new file mode 100644 index 0000000000..fa965ac019 --- /dev/null +++ b/scripts/zpool-config/dm0-raid0.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Four disk Raid-0 DM in a single Raid-0 Configuration +# + +PVCREATE=${PVCREATE:-/sbin/pvcreate} +PVREMOVE=${PVREMOVE:-/sbin/pvremove} +PVDEVICES=${PVDEVICES:-"/dev/sd[abcd]"} + +VGCREATE=${VGCREATE:-/sbin/vgcreate} +VGREMOVE=${VGREMOVE:-/sbin/vgremove} +VGNAME=${VGNAME:-"vg_tank"} + +LVCREATE=${LVCREATE:-/sbin/lvcreate} +LVREMOVE=${LVREMOVE:-/sbin/lvremove} +LVNAME=${LVNAME:-"lv_tank"} +LVSTRIPES=${LVSTRIPES:-4} +LVSIZE=${LVSIZE:-4G} + +DEVICES="/dev/${VGNAME}/${LVNAME}" + +zpool_create() { + # Remove EFI labels which cause pvcreate failure + for DEVICE in ${PVDEVICES}; do + dd if=/dev/urandom of=${DEVICE} bs=1k count=32 &>/dev/null + done + + msg ${PVCREATE} -f ${PVDEVICES} + ${PVCREATE} -f ${PVDEVICES} || exit 1 + + msg ${VGCREATE} ${VGNAME} ${PVDEVICES} + ${VGCREATE} ${VGNAME} ${PVDEVICES} || exit 2 + + msg ${LVCREATE} --size=${LVSIZE} --stripes=${LVSTRIPES} \ + --name=${LVNAME} ${VGNAME} + ${LVCREATE} --size=${LVSIZE} --stripes=${LVSTRIPES} \ + --name=${LVNAME} ${VGNAME} || exit 3 + + msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} + ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} || exit 4 +} + +zpool_destroy() { + msg ${ZPOOL} destroy ${ZPOOL_NAME} + ${ZPOOL} destroy ${ZPOOL_NAME} || exit 1 + + msg ${LVREMOVE} -f ${VGNAME}/${LVNAME} + ${LVREMOVE} -f ${VGNAME}/${LVNAME} || exit 2 + + msg ${VGREMOVE} -f ${VGNAME} + ${VGREMOVE} -f ${VGNAME} || exit 3 + + msg ${PVREMOVE} ${PVDEVICES} + ${PVREMOVE} ${PVDEVICES} || exit 4 +} diff --git a/scripts/zpool-config/md0-raid10.sh b/scripts/zpool-config/md0-raid10.sh new file mode 100644 index 0000000000..4b1a979041 --- /dev/null +++ b/scripts/zpool-config/md0-raid10.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Four disk Raid-10 in a single Raid-0 Configuration +# + +MDADM=${MDADM:-/sbin/mdadm} +MDDEVICES=${MDDEVICES:-"/dev/sd[abcd]"} +MDCOUNT=${MDCOUNT:-4} +MDRAID=${MDRAID:-10} + +DEVICES="/dev/md0" + +zpool_create() { + msg ${MDADM} --create ${DEVICES} --level=${MDRAID} \ + --raid-devices=${MDCOUNT} ${MDDEVICES} + ${MDADM} --create ${DEVICES} --level=${MDRAID} \ + --raid-devices=${MDCOUNT} ${MDDEVICES} || exit 1 + + msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} + ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} || exit 2 +} + +zpool_destroy() { + msg ${ZPOOL} destroy ${ZPOOL_NAME} + ${ZPOOL} destroy ${ZPOOL_NAME} || exit 1 + + msg ${MDADM} --manage --stop ${DEVICES} + ${MDADM} --manage --stop ${DEVICES} || exit 2 + + msg ${MDADM} --zero-superblock ${MDDEVICES} + ${MDADM} --zero-superblock ${MDDEVICES} || exit 3 +} diff --git a/scripts/zpool-config/md0-raid5.sh b/scripts/zpool-config/md0-raid5.sh new file mode 100644 index 0000000000..9bf17181b0 --- /dev/null +++ b/scripts/zpool-config/md0-raid5.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Four disk Raid-5 in a single Raid-0 Configuration +# + +MDADM=${MDADM:-/sbin/mdadm} +MDDEVICES=${MDDEVICES:-"/dev/sd[abcd]"} +MDCOUNT=${MDCOUNT:-4} +MDRAID=${MDRAID:-5} + +DEVICES="/dev/md0" + +zpool_create() { + msg ${MDADM} --create ${DEVICES} --level=${MDRAID} \ + --raid-devices=${MDCOUNT} ${MDDEVICES} + ${MDADM} --create ${DEVICES} --level=${MDRAID} \ + --raid-devices=${MDCOUNT} ${MDDEVICES} || exit 1 + + msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} + ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} || exit 2 +} + +zpool_destroy() { + msg ${ZPOOL} destroy ${ZPOOL_NAME} + ${ZPOOL} destroy ${ZPOOL_NAME} || exit 1 + + msg ${MDADM} --manage --stop ${DEVICES} + ${MDADM} --manage --stop ${DEVICES} || exit 2 + + msg ${MDADM} --zero-superblock ${MDDEVICES} + ${MDADM} --zero-superblock ${MDDEVICES} || exit 3 +} diff --git a/scripts/zpool-config/ram0-raid0.sh b/scripts/zpool-config/ram0-raid0.sh new file mode 100644 index 0000000000..b1939bfaae --- /dev/null +++ b/scripts/zpool-config/ram0-raid0.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# +# Single ram disk /dev/ram0 Raid-0 Configuration +# + +DEVICES="/dev/ram0" + +zpool_create() { + msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} + ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} || exit 1 +} + +zpool_destroy() { + msg ${ZPOOL} destroy ${ZPOOL_NAME} + ${ZPOOL} destroy ${ZPOOL_NAME} || exit 1 +}