Merge commit 'refs/top-bases/linux-user-disk' into linux-user-disk

This commit is contained in:
Brian Behlendorf 2009-10-26 10:49:28 -07:00
commit 757cbd422e
4 changed files with 135 additions and 0 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}