X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=scripts%2Fcommon.sh.in;h=0e792dbdc1d9d5872c0c4ae824355ad2e14cdb2d;hb=26099167e6b39d719ade3be2b5e087e29f1121cd;hp=56706194ccb7875a8e20a0bfea152e433c75873d;hpb=5cbf6db937a304c4d2b60878a2405a1e2900abdf;p=zfs.git diff --git a/scripts/common.sh.in b/scripts/common.sh.in index 5670619..0e792db 100644 --- a/scripts/common.sh.in +++ b/scripts/common.sh.in @@ -308,6 +308,48 @@ destroy_loop_devices() { } # +# 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() {