#!/bin/bash #Syn-3 diskinit (C)2005 DatuX #-partitions all the specified discs for use with syn3 #-erases all the data! #-automaticly runs initboot and initdata to initialize partitions with raid, lvm and filesystems . dialoglib.sh || exit 1 exec 2>&1 ######################## clean and partition all disks # Cleans and partitions all discs for Syn-3 raid. BOOT_PARTS= DATA_PARTS= for DISC in $*; do echo -e "\n* Partitioning disc $DISC:" #DISCBASE=`dirname $DISC` #remove any existing raid disc superblocks #(may fail) mdadm --misc --zero-superblock --force $DISC &>/dev/null #remove any other confusing stuff on the disc dd if=/dev/zero of=$DISC bs=1024k count=1 &>/dev/null #Repartitioning. Syn3 uses 2 partions: #partion 1: boot partition (fixed size, mirrored over all disks ) #partion 2: LVM (rest of the space, mirror + spares) if [ "$USE_GPT" ]; then # In GPT a "Linux RAID partition" has type A19D880F-05FC-4D3B-A006-743F0F84911E echo -e "size=$SIZE_BOOT, type=A19D880F-05FC-4D3B-A006-743F0F84911E, attrs=LegacyBIOSBootable, bootable\ntype=A19D880F-05FC-4D3B-A006-743F0F84911E"|sfdisk -q -f $DISC --label gpt >/dev/null || exit 1 else # In dos a "Linux RAID partition" has type 0xFD echo -e "size=$SIZE_BOOT, type=FD, bootable\ntype=FD"|sfdisk -q -f $DISC --label dos >/dev/null || exit 1 fi #wait for devicenames to be created udevadm settle #determine partitions names PART1=`listpartitions $DISC | head -1` PART2=`listpartitions $DISC | head -2 | tail -1` #remove raid partition superblocks #(may fail) mdadm --misc --zero-superblock --force "$PART1" &>/dev/null mdadm --misc --zero-superblock --force "$PART2" &>/dev/null #remove other confusing stuff thats in the partition dd if=/dev/zero of="$PART1" bs=4k count=1 &>/dev/null || exit 1 dd if=/dev/zero of="$PART2" bs=4k count=1 &>/dev/null || exit 1 #remember this parition for later BOOT_PARTS="$BOOT_PARTS $PART1" DATA_PARTS="$DATA_PARTS $PART2" done ./initboot.sh $BOOT_PARTS || exit $? ./initdata.sh $DATA_PARTS || exit $? echo -e "\n* DONE" #release the flying monkeys: exit 0