Changeset 2581

Show
Ignore:
Timestamp:
08/12/08 11:47:06 (4 months ago)
Author:
kris
Message:

Redesigned the PCBSD.FindDisk?.sh script, so that it traverses the /dev
directory looking for valid disk drives to install onto. This should help
make it more reliable in identifying disks, instead of relying on /var/run/dmesg.boot which may not always be dependable.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pcbsd/trunk/installcd-overlay/usr/local/pcbsd/scripts/PCBSD.FindDisk.sh

    r2312 r2581  
    66FOUND="0" 
    77 
    8 # Check for IDE a badly formatted /var/run/dmesg.boot file first 
    9 cat /var/run/dmesg.boot | grep "^md0:" | grep "ad0: " >/dev/null 2>/dev/null 
    10 if [ "$?" = "0" ] 
    11 then 
    12  # Looks like we have a messed up line, clean it up 
    13  VAR="`cat /var/run/dmesg.boot | grep "^md0:" | grep "ad0: " | cut -d ":" -f 3`" 
     8# Create our device listing 
     9ls /dev/ > /tmp/devlist 
    1410 
    15  # Make sure this line isn't already in the file 
    16  cat /var/run/dmesg.boot | grep "^ad0: " >/dev/null 2>/dev/null 
    17  if [ "$?" != "0" ] 
    18  then 
    19    echo "ad0:${VAR}" >>/var/run/dmesg.boot 
    20  fi 
    21 fi 
     11# Remove any old devlist.new file 
     12rm /tmp/devlist.new >/dev/null 2>/dev/null 
    2213 
    23 # Check for SCSI in a badly formatted /var/run/dmesg.boot file first 
    24 cat /var/run/dmesg.boot | grep "^md0:" | grep "da0: " >/dev/null 2>/dev/null 
    25 if [ "$?" = "0" ] 
    26 then 
    27  # Looks like we have a messed up line, clean it up 
    28  VAR="`cat /var/run/dmesg.boot | grep "^md0:" | grep "da0: " | cut -d ":" -f 3`" 
    29   
    30  # Make sure this line isn't already in the file 
    31  cat /var/run/dmesg.boot | grep "^da0: " >/dev/null 2>/dev/null 
    32  if [ "$?" != "0" ] 
    33  then 
    34    echo "da0:${VAR}" >>/var/run/dmesg.boot 
    35  fi 
    36 fi 
     14# Loop through the list and add a : to the end of each dev 
     15while read line 
     16do 
     17   echo "${line}:" >> /tmp/devlist.new 
     18done < /tmp/devlist 
    3719 
     20# Move our fixed list over to the valid list 
     21mv /tmp/devlist.new /tmp/devlist 
    3822 
    39 for i in `egrep "^(ad|aacd|mlxd|mlyd|amrd|idad|twed|da|ar|ips|)[0-9]:" /var/run/dmesg.boot | cut -d':' -f1 | sort | uniq` 
     23# Now loop through these devices, and list the disk drives 
     24for i in `egrep "^(ad|aacd|mlxd|mlyd|amrd|idad|twed|da|ar|ips|)[0-9]:" /tmp/devlist | sort | uniq` 
    4025do 
    41   LN="`cat /var/run/dmesg.boot | grep ^$i | grep -v "MB/s" | grep MB`" >/dev/null 
    42   echo ${LN} 
    43   fdisk /dev/${i} >/tmp/${i} 
    44   FOUND="1" 
     26 
     27  # Get the raw device name, no : 
     28  DEV="`echo ${i} | cut -d ':' -f 1`" 
     29   
     30  # Check the dmesg output for some more info about this device 
     31  dmesg | grep ^$DEV: | grep '<' | grep '>' >/dev/null 2>/dev/null 
     32  if [ "$?" = "0" ] 
     33  then 
     34     LN="`dmesg | grep ^${DEV}: | grep '<' | grep '>'`" 
     35     NEWLINE="`echo ${LN} | cut -d ':' -f 2`" 
     36  else 
     37     NEWLINE="<Unknown Device>" 
     38  fi 
     39 
     40  # Echo out the found line for PCInstall to display 
     41  echo "${DEV}: ${NEWLINE}" 
     42 
     43  # Get the fdisk output to be read by PCInstall next 
     44  fdisk /dev/${DEV} >/tmp/${DEV} 
     45 
    4546done 
    4647 
    47 #If we couldn't find anything in the dmesg file, look for devices instead 
    48 if [ "${FOUND}" = "0" ] 
    49 then 
    50   if [ -e "/dev/ad0" ] 
    51   then 
    52      echo "ad0: XXXXXXMB <Unprobed IDE Disk>" 
    53      fdisk /dev/ad0 >/tmp/ad0   
    54   fi 
    55   if [ -e "/dev/da0" ] 
    56   then 
    57      echo "ad0: XXXXXXMB <Unprobed SCSI Disk>" 
    58      fdisk /dev/ad0 >/tmp/ad0   
    59   fi 
    60 fi 
    61