# Find and return an unused loopback device.
#
unused_loop_device() {
- for DEVICE in `ls -1 /dev/loop* 2>/dev/null`; do
+ for DEVICE in `ls -1 /dev/loop[0-9]* 2>/dev/null`; do
${LOSETUP} ${DEVICE} &>/dev/null
if [ $? -ne 0 ]; then
echo ${DEVICE}
}
#
+# Create a device label.
+#
+label() {
+ local DEVICE=$1
+ local LABEL=$2
+
+ ${PARTED} ${DEVICE} --script -- mklabel ${LABEL} || return 1
+
+ return 0
+}
+
+#
+# Create a primary partition on a block device.
+#
+partition() {
+ local DEVICE=$1
+ local TYPE=$2
+ local START=$3
+ local END=$4
+
+ ${PARTED} --align optimal ${DEVICE} --script -- \
+ mkpart ${TYPE} ${START} ${END} || return 1
+ udev_trigger
+
+ return 0
+}
+
+#
+# Create a filesystem on the block device
+#
+format() {
+ local DEVICE=$1
+ local FSTYPE=$2
+
+ # Force 4K blocksize, else mkfs.ext2 tries to use 8K, which
+ # won't mount
+ /sbin/mkfs.${FSTYPE} -b 4096 -F -q ${DEVICE} || return 1
+
+ return 0
+}
+
+#
# Check that the mdadm utilities are installed.
#
check_md_utils() {