On Thu, 14 Jun 2007 17:51:24 -0500
Dallas Clement <[EMAIL PROTECTED]> wrote:

> Can anyone please recommend the best way to programatically obtain disk
> drive information, partition, and format from an install script?
> 
> I presume I could parse the output of "fdisk -l" to get the drive info.
> Seems like there has got to be a better or less error prone method for
> doing this sort of stuff.  Also, fdisk is interactive.  I'd like to
> emulate something like the Debian installer that lists the various
> drives and partitions, allows the user to setup partitions and format,
> as well as select the partition to install Linux to.
> 
> Any recommendations will be greatly appreciated!
> 
> Regards,
> 
> Dallas Clement
> 
> 
> -- 
> To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

I have been done this a while ago, it's bad, but it works for me even with the 
problems that this script have.


#!/bin/sh

# BEGIN

fdisk=$(which fdisk)


case "$1" in
        scsi)

        $fdisk -l | grep dev | gawk -F' *' '{ print $1 }' | gawk -F'/dev/' '{ 
print $0 }' | grep '/dev/sd' > particiones.txt
        MSG="Se han detectado un total de $(cat particiones.txt | wc -l) 
particiones a escanear"
        echo $MSG del tipo $1

        for particion in $(cat particiones.txt)
        do
        detecta2=$($fdisk -l | grep $particion | grep + | gawk -F'+' '{ print 
$2}' | gawk -F' ' '{ print $2 }')
        detecta3=$($fdisk -l | grep $particion | grep + | gawk -F'+' '{ print 
$2}' | gawk -F' ' '{ print $1 }')
        echo "Detectando tipo de particion $1 para $particion:  $detecta2 con 
numero magico $detecta3"
        #rm -v particiones.txt 2&>1
        done
        ;;
        ide)

        $fdisk -l | grep dev | gawk -F' *' '{ print $1 }' | gawk -F'/dev/' '{ 
print $0 }' | grep '/dev/hd' > particiones.txt
        MSG="Se han detectado un total de $(cat particiones.txt | wc -l) 
particiones a escanear"
        echo $MSG del tipo $1
        for particion in $(cat particiones.txt)
        do
        detecta2=$($fdisk -l | grep $particion | grep + | gawk -F'+' '{ print 
$2}' | gawk -F' ' '{ print $2 }')
        detecta3=$($fdisk -l | grep $particion | grep + | gawk -F'+' '{ print 
$2}' | gawk -F' ' '{ print $1 }')
        
        echo "Detectando tipo de particion $1 para $particion:  $detecta2 con 
numero magico $detecta3"
        #rm -v particiones.txt 2&>1
        done
        ;;
        *)
        echo "Uso: $0 ide | scsi "
        exit 0
esac
# END




Greetings,
Orestes


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to