Changeset 3034

Show
Ignore:
Timestamp:
12/03/08 11:51:35 (16 months ago)
Author:
kris
Message:

Fixed a major installation bug, when trying to install PC-BSD to free space, and not an existing primary partition (slice).

Now the install script, will detect if the slice is non-existant, and figure out the starting block and size of the new slice, and set it up with fdisk properly

Location:
pcbsd
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pcbsd/branches/7.0/installcd-overlay/usr/local/pcbsd/scripts/PCBSD.FormatPartition.sh

    r2809 r3034  
    4040fi 
    4141 
    42 # Get the fdisk -s output of this device 
    43 fdisk -s /dev/${device} | grep -v "${device}:" | grep "${slicenum}:" | tr -s " " > /tmp/fdiskblk 
    44 startblock="`cat /tmp/fdiskblk | cut -d ' ' -f 3`" 
    45 endblock="`cat /tmp/fdiskblk | cut -d ' ' -f 4`" 
     42# Lets check if we are using a new slice, which needs to be initialized 
     43fdisk -s /dev/${device} | grep -v "${device}:" | grep "${slicenum}:" >/dev/null 2>/dev/null 
     44if [ "$?" != "0" ] 
     45then 
     46  # This slice isn't on the disk, lets create it now 
    4647 
    47 # Create the new fdiskconfig file now to set this partition to type 165 
    48 echo "p ${slicenum}     165     ${startblock}   ${endblock}" > /tmp/fdiskconfig 
     48  # Lets get the starting block first 
     49  if [ "${slicenum}" = "1" ] 
     50  then 
     51     startblock="1" 
     52  else  
     53     # Lets figure out where the prior slice ends 
     54     checkslice="`expr ${slicenum} - 1`" 
     55      
     56     # Get starting block of this slice 
     57     fdisk -s /dev/${device} | grep -v "${device}:" | grep "${checkslice}:" | tr -s " " >/tmp/pfdisk 
     58     pstartblock="`cat /tmp/pfdisk | cut -d ' ' -f 3`" 
     59     psize="`cat /tmp/pfdisk | cut -d ' ' -f 4`" 
     60     startblock="`expr ${pstartblock} + ${psize}`"    
     61  fi 
     62 
     63  # Now lets figure out the ending block for this slice 
     64  nextslice="`expr ${slicenum} + 1`" 
     65 
     66  # Check if we have a slice after where our free space one will go 
     67  fdisk -s /dev/${device} | grep -v "${device}:" | grep "${nextslice}:" >/dev/null 2>/dev/null 
     68  if [ "$?" != "0" ] 
     69  then 
     70    # No slice after the new slice, lets figure out the free space remaining and use it 
     71     
     72    # Get the cyl of this disk 
     73    cyl=`fdisk -s /dev/${device} | grep "${device}:" | tr -s ' ' | cut -d ' ' -f 2` 
     74  
     75    # Get the heads of this disk  
     76    head=`fdisk -s /dev/${device} | grep "${device}:" | tr -s ' ' | cut -d ' ' -f 4` 
     77 
     78    # Get the tracks/sectors of this disk 
     79    sec=`fdisk -s /dev/${device} | grep "${device}:" | tr -s ' ' | cut -d ' ' -f 6` 
     80 
     81    # Multiply them all together to get our total blocks 
     82    totalblocks="`expr ${cyl} \* ${head}`" 
     83    totalblocks="`expr ${totalblocks} \* ${sec}`" 
     84 
     85    # Now set the ending block to the total disk block size 
     86    sizeblock="`expr ${totalblocks} - ${startblock}`" 
     87 
     88  else 
     89    # Figure out the start block of the next slice, and subtract one to get our new ending block 
     90    fdisk -s /dev/${device} | grep -v "${device}:" | grep "${nextslice}:" | tr -s " " >/tmp/nfdisk 
     91    nstartblock="`cat /tmp/nfdisk | cut -d ' ' -f 3`" 
     92    sizeblock="`expr ${nstartblock} - ${startblock}`" 
     93  fi 
     94   
     95  # Create the new fdiskconfig file now to set this partition to type 165 
     96  echo "p       ${slicenum}     165     ${startblock}   ${sizeblock}" > /tmp/fdiskconfig 
     97 
     98else 
     99  # Slice already exists, lets mark it as 165 for FreeBSD 
     100  # Get the fdisk -s output of this device 
     101  fdisk -s /dev/${device} | grep -v "${device}:" | grep "${slicenum}:" | tr -s " " > /tmp/fdiskblk 
     102  startblock="`cat /tmp/fdiskblk | cut -d ' ' -f 3`" 
     103  sizeblock="`cat /tmp/fdiskblk | cut -d ' ' -f 4`" 
     104 
     105  # Create the new fdiskconfig file now to set this partition to type 165 
     106  echo "p       ${slicenum}     165     ${startblock}   ${sizeblock}" > /tmp/fdiskconfig 
     107fi 
    49108 
    50109sleep 4 
     110 
    51111 
    52112# Install new partition setup 
  • pcbsd/trunk/installcd-overlay/usr/local/pcbsd/scripts/PCBSD.FormatPartition.sh

    r2809 r3034  
    4040fi 
    4141 
    42 # Get the fdisk -s output of this device 
    43 fdisk -s /dev/${device} | grep -v "${device}:" | grep "${slicenum}:" | tr -s " " > /tmp/fdiskblk 
    44 startblock="`cat /tmp/fdiskblk | cut -d ' ' -f 3`" 
    45 endblock="`cat /tmp/fdiskblk | cut -d ' ' -f 4`" 
     42# Lets check if we are using a new slice, which needs to be initialized 
     43fdisk -s /dev/${device} | grep -v "${device}:" | grep "${slicenum}:" >/dev/null 2>/dev/null 
     44if [ "$?" != "0" ] 
     45then 
     46  # This slice isn't on the disk, lets create it now 
    4647 
    47 # Create the new fdiskconfig file now to set this partition to type 165 
    48 echo "p ${slicenum}     165     ${startblock}   ${endblock}" > /tmp/fdiskconfig 
     48  # Lets get the starting block first 
     49  if [ "${slicenum}" = "1" ] 
     50  then 
     51     startblock="1" 
     52  else  
     53     # Lets figure out where the prior slice ends 
     54     checkslice="`expr ${slicenum} - 1`" 
     55      
     56     # Get starting block of this slice 
     57     fdisk -s /dev/${device} | grep -v "${device}:" | grep "${checkslice}:" | tr -s " " >/tmp/pfdisk 
     58     pstartblock="`cat /tmp/pfdisk | cut -d ' ' -f 3`" 
     59     psize="`cat /tmp/pfdisk | cut -d ' ' -f 4`" 
     60     startblock="`expr ${pstartblock} + ${psize}`"    
     61  fi 
     62 
     63  # Now lets figure out the ending block for this slice 
     64  nextslice="`expr ${slicenum} + 1`" 
     65 
     66  # Check if we have a slice after where our free space one will go 
     67  fdisk -s /dev/${device} | grep -v "${device}:" | grep "${nextslice}:" >/dev/null 2>/dev/null 
     68  if [ "$?" != "0" ] 
     69  then 
     70    # No slice after the new slice, lets figure out the free space remaining and use it 
     71     
     72    # Get the cyl of this disk 
     73    cyl=`fdisk -s /dev/${device} | grep "${device}:" | tr -s ' ' | cut -d ' ' -f 2` 
     74  
     75    # Get the heads of this disk  
     76    head=`fdisk -s /dev/${device} | grep "${device}:" | tr -s ' ' | cut -d ' ' -f 4` 
     77 
     78    # Get the tracks/sectors of this disk 
     79    sec=`fdisk -s /dev/${device} | grep "${device}:" | tr -s ' ' | cut -d ' ' -f 6` 
     80 
     81    # Multiply them all together to get our total blocks 
     82    totalblocks="`expr ${cyl} \* ${head}`" 
     83    totalblocks="`expr ${totalblocks} \* ${sec}`" 
     84 
     85    # Now set the ending block to the total disk block size 
     86    sizeblock="`expr ${totalblocks} - ${startblock}`" 
     87 
     88  else 
     89    # Figure out the start block of the next slice, and subtract one to get our new ending block 
     90    fdisk -s /dev/${device} | grep -v "${device}:" | grep "${nextslice}:" | tr -s " " >/tmp/nfdisk 
     91    nstartblock="`cat /tmp/nfdisk | cut -d ' ' -f 3`" 
     92    sizeblock="`expr ${nstartblock} - ${startblock}`" 
     93  fi 
     94   
     95  # Create the new fdiskconfig file now to set this partition to type 165 
     96  echo "p       ${slicenum}     165     ${startblock}   ${sizeblock}" > /tmp/fdiskconfig 
     97 
     98else 
     99  # Slice already exists, lets mark it as 165 for FreeBSD 
     100  # Get the fdisk -s output of this device 
     101  fdisk -s /dev/${device} | grep -v "${device}:" | grep "${slicenum}:" | tr -s " " > /tmp/fdiskblk 
     102  startblock="`cat /tmp/fdiskblk | cut -d ' ' -f 3`" 
     103  sizeblock="`cat /tmp/fdiskblk | cut -d ' ' -f 4`" 
     104 
     105  # Create the new fdiskconfig file now to set this partition to type 165 
     106  echo "p       ${slicenum}     165     ${startblock}   ${sizeblock}" > /tmp/fdiskconfig 
     107fi 
    49108 
    50109sleep 4 
     110 
    51111 
    52112# Install new partition setup