Changeset 37f4931


Ignore:
Timestamp:
Jul 27, 2013 6:28:59 PM (9 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1
Children:
f4066f6
Parents:
2c2c1a5
Message:

Update the grub2 30_os-prober script, now use grub-probe to auto-detect
NTFS / Windows 7 partitions, and set root via fs_uuid

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-sh/pc-extractoverlay/ports-overlay/usr/local/etc/grub.d/30_os-prober

    r8a9837c r37f4931  
    2929check_ntfs_part() 
    3030{ 
    31    if [ "$3" = "MBR" ] ; then 
    32      cDisk="${1}s${2}"  
    33    else 
    34      cDisk="${1}p${2}"  
     31   local disk="$1" 
     32   fs_label=`grub-probe --device /dev/${disk} --target=fs_label` 
     33 
     34   # For now check if its labeled system-reserved, need to test 
     35   # this on vista / 8 / XP still 
     36   if [ "$fs_label" != "System Reserved" ] ; then return; fi 
     37 
     38   fs_uuid=`grub-probe --device /dev/${disk} --target=fs_uuid` 
     39   if [ -z "$fs_uuid" ] ; then 
     40      echo "Warning: Could not get fs_uuid for $disk" 
     41      return 
    3542   fi 
    36    # Check the partition for a boot sector 
    37    glabel status ${cDisk} 2>/dev/null | grep -q "System Reserved" 
    38    if [ $? -ne 0 ] ; then return ; fi 
     43 
    3944   cat << EOF 
    40 menuentry "Microsoft Windows ($cDisk)" { 
    41    insmod ntfs 
    42    set root(hd${dNum},$2) 
     45menuentry "Microsoft Windows ($disk)" { 
     46   search --no-floppy --fs-uuid --set=root $fs_uuid 
    4347   chainloader +1 
    4448} 
     
    4650} 
    4751 
    48 dFile="/tmp/.disk-probe.$$" 
    49 dNum="0" 
    50  
    5152# Start by looking for disks 
    52 for disk in `cd /dev/ && ls ada[0-9] da[0-9] 2>/dev/null` 
     53for disk in `cd /dev/ && ls ada[0-9]s[0-9] da[0-9]s[0-9] ada[0-9]p[0-9] da[0-9]p[0-9] 2>/dev/null` 
    5354do 
    54    if [ -e "$dFile" ] ; then rm $dFile; fi 
    55    gpart show $disk 2>/dev/null >${dFile} 
    56    pType="" 
    57    while read dLine 
    58    do 
    59      echo "$dLine" | grep -q '=>'  
    60      if [ $? -eq 0 ] ; then 
    61         pType=`echo $dLine | awk '{print $5}'` 
    62         continue 
    63      fi 
    64      fsType=`echo $dLine | awk '{print $4}'` 
    65      fsPart=`echo $dLine | awk '{print $3}'` 
    66      case $fsType in 
    67           ntfs) check_ntfs_part "$disk" "$fsPart" "$pType" ;; 
    68              *) ;; # Unknown / unsupported FS - Add more here! 
    69      esac 
    70  
    71    done < $dFile 
    72  
    73    # Increment our disk counter 
    74    dNum="`expr $dNum + 1`" 
     55    
     56   # Start checking for NTFS 
     57   fs_type=`grub-probe --device /dev/${disk} --target=fs 2>/dev/null` 
     58   case $fs_type in 
     59      ntfs) check_ntfs_part "$disk" ;; 
     60        *) ;; # Unknown for now, add more! 
     61   esac  
    7562done 
    76  
    77 rm $dFile 
Note: See TracChangeset for help on using the changeset viewer.