epcim
10/20/2015 - 11:29 AM

fdisk.howto.md

Fdisk scripted (create additional disk)

    partition=1

    echo "- - -" > /sys/class/scsi_host/host0/scan
    extradisk=`fdisk -l 2>&1 |grep "doesn't"|awk '{print $2}'`
    echo Found "$extradisk"

    #find more fancy options?
    printf "n\n p\n 1\n 1\n \n w\n" > /tmp/fdisk.input
    fdisk "$extradisk" < /tmp/fdisk.input

    extradisk="$extradisk$partition"
    echo "$extradisk"

    sleep 5
    mkfs.ext3 "$extradisk" 2>&1
    if [ $? == 0 ]; then
        echo initialized "$extradisk"
    fi

    rm /tmp/fdisk.input