diff options
author | kmoore <kmoore@FreeBSD.org> | 2015-01-31 00:42:14 +0800 |
---|---|---|
committer | kmoore <kmoore@FreeBSD.org> | 2015-01-31 00:42:14 +0800 |
commit | 71370842147e1e94b2f58a29a9763fcfe2a40b53 (patch) | |
tree | 705590d88a56a21b687698f0beed5e22c048d845 /sysutils | |
parent | 064363bc3eae4dbaadec69cd681ebe46d701007e (diff) | |
download | freebsd-ports-gnome-71370842147e1e94b2f58a29a9763fcfe2a40b53.tar.gz freebsd-ports-gnome-71370842147e1e94b2f58a29a9763fcfe2a40b53.tar.zst freebsd-ports-gnome-71370842147e1e94b2f58a29a9763fcfe2a40b53.zip |
- Add support to probe for and add chainloaded disks to the grub menus
- Bump PORTREV
Diffstat (limited to 'sysutils')
-rw-r--r-- | sysutils/grub2-pcbsd/Makefile | 2 | ||||
-rw-r--r-- | sysutils/grub2-pcbsd/files/10_ktrueos.in | 3 | ||||
-rw-r--r-- | sysutils/grub2-pcbsd/files/30_os-prober.in | 93 |
3 files changed, 84 insertions, 14 deletions
diff --git a/sysutils/grub2-pcbsd/Makefile b/sysutils/grub2-pcbsd/Makefile index 9525cda01392..01ee7963a45c 100644 --- a/sysutils/grub2-pcbsd/Makefile +++ b/sysutils/grub2-pcbsd/Makefile @@ -3,7 +3,7 @@ PORTNAME= grub2-pcbsd PORTVERSION= 2.02p -PORTREVISION= 21 +PORTREVISION= 22 CATEGORIES= sysutils MASTER_SITES= http://www.pcbsd.org/~kris/software/ \ ftp://ftp.pcbsd.org/pub/software/ diff --git a/sysutils/grub2-pcbsd/files/10_ktrueos.in b/sysutils/grub2-pcbsd/files/10_ktrueos.in index 8c70e824ec20..8f275d1f9be7 100644 --- a/sysutils/grub2-pcbsd/files/10_ktrueos.in +++ b/sysutils/grub2-pcbsd/files/10_ktrueos.in @@ -176,9 +176,6 @@ display_loaderopts() if [ "$haveGELI" = "true" ] ; then echo " set kFreeBSD.kern.geom.eli.passphrase=\"\$pass\"" fi - - # GRUB does NOT support gptid labels yet - echo " set kFreeBSD.kern.geom.label.gptid.enable=\"0\"" } detect_beadm() diff --git a/sysutils/grub2-pcbsd/files/30_os-prober.in b/sysutils/grub2-pcbsd/files/30_os-prober.in index 289756156931..70ec39d9128f 100644 --- a/sysutils/grub2-pcbsd/files/30_os-prober.in +++ b/sysutils/grub2-pcbsd/files/30_os-prober.in @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright 2013 iXsystems (Kris Moore) +# Copyright 2015 iXsystems (Kris Moore) # All rights reserved # # Redistribution and use in source and binary forms, with or without @@ -48,14 +48,87 @@ menuentry "Microsoft Windows ($disk)" { EOF } -# Start by looking for disks -for 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` +print_uefichain() { + cat << EOF +menuentry "Chainload Disk (hd${hdnum} - $1)" { + set root=('hd${hdnum},${rootpre}1') + chainloader $1 +} + +EOF +} + +# Look for file-systems on the zpool disk +for disk in `zpool status | grep ONLINE | grep -v "state:" | awk '{print $1}'` do - - # Start checking for NTFS - fs_type=`grub-probe --device /dev/${disk} --target=fs 2>/dev/null` - case $fs_type in - ntfs) check_ntfs_part "$disk" ;; - *) ;; # Unknown for now, add more! - esac + disk="`echo $disk | sed 's|.eli||g'`" + if [ ! -e "/dev/$disk" ] ; then continue ; fi + + # Get the parent disk name + parentdisk=`grub-probe --target=disk --device /dev/$disk` + parentdisk="`echo $parentdisk | sed 's|/dev/||g'`" + if [ ! -e "/dev/$parentdisk" ] ; then continue ; fi + + for ldisk in `cd /dev/ && ls ${parentdisk}s[0-9] ${parentdisk}p[0-99] 2>/dev/null` + do + fs_type=`grub-probe --device /dev/${ldisk} --target=fs 2>/dev/null` + case $fs_type in + ntfs) check_ntfs_part "$ldisk" ;; # Start checking for NTFS + *) ;; # Unknown for now, add more! + esac + done +done + +# Look for other disks to chainload +hdnum=0 +for disk in `cd /dev/ && ls ada[0-9] da[0-9] 2>/dev/null` +do + # Skip disks apart of zpool + zpool status | grep ONLINE | grep -v "state:" | grep -q "$disk" + if [ $? -eq 0 ] ; then + hdnum=`expr $hdnum + 1` + continue + fi + + # Check if the first partition on this disk is EFI + if [ -e "/dev/${disk}s1" ] ; then + fp="/dev/${disk}s1" + rootpre="" + else + fp="/dev/${disk}p1" + rootpre="gpt" + fi + + # Add UEFI chainloader + if [ "`grub-probe --device -t fs $fp`" = "fat" ] ; then + + # Lets mount the FAT partition and look for UEFI boots + uefimnt="/tmp/.grub-uefi.$$" + if [ ! -d "$uefimnt" ] ; then mkdir $uefimnt; fi + mount_msdosfs $fp $uefimnt + if [ $? -eq 0 ] ; then + if [ -e "${uefimnt}/EFI/Boot/bootx64.efi" ] ; then + print_uefichain "/EFI/Boot/bootx64.efi" + fi + cd $uefimnt + for i in `find . | grep \.efi$ | grep -v "./EFI/Boot/bootx64.efi"` + do + i="`echo $i | sed 's|\./|/|g'`" + print_uefichain "$i" + done + cd /dev + umount $uefimnt + rmdir $uefimnt + fi + + else + # Add BIOS chainloader + cat << EOF +menuentry "Chainload Disk (hd${hdnum})" { + set root=(hd${hdnum}) + chainloader +1 +} +EOF + fi + hdnum=`expr $hdnum + 1` done |