#203 rEFIt falls back to Linux when selecting windows.


I have, after a tutorial, created partitions to run Mac, Ubuntu and Win7. So far so good, all three run. But when I select the Windows icon, i get dropped into GRUB - into Ubuntu's GRUB!

And since I added an own grub for windows...its kinda weird walking thought three bootloaders o.o .

How can I make rEFIt boot straight off my windows partition, insteath of falling back to GRUB?


  • Joe van Tunen

    Joe van Tunen - 2011-05-30

    When you select a Windows or Unix partition using rEFIt, it sets the boot flag in the MBR for that partition. The boot code in the MBR will then run the boot code in the VBR (first block of the selected partition).

    There is probably something wrong with your GRUB settings on the Windows partition or the MBR is hard coded to run GRUB on the Ubuntu partition. Did you use the Advanced option during installation of Ubuntu to make sure Ubuntu installed GRUB on the Ubuntu partition and not in the MBR?

    If the MBR doesn't contain standard boot code, you can use Windows to reset the boot code in the MBR. EasyBCD 2.0.2 can do this also plus a whole lot more http://neosmart.net/. Or you can clear the boot code of the MBR using the fdisk command in Mac OS X. I think in that case, rEFIt will write some standard linux boot code to the MBR. iPartition can also set the MBR boot code http://www.coriolis-systems.com/

    The following is a script you can run on the Mac to get info on all your disks and partitions. It will also dump the contents of the MBR and the first block of all the partitions so you can identify the boot code. Put the script in a file called dumpvols.sh and set the execute bit. Then run it using: ./dumpvols.sh 2>&1

    # Get Partition Info from all disks
    # Written by joevt

    if [ ! "$USER" = "root" ]; then
    echo WARNING: This script must be run as root.

    MBRHASHES=\ "Windows_XP=d88d4f2dbc2c662db7d7d60ebf9e3e00 "\ "Windows_Vista=12c9d7ff4914c88a7f9eadf9211b861b "\ "Windows_7=118eb70c44cb69284e5d8aa93096831e "\ "None_all_zeros=4ebc676ce4896613a3a9df6e2a1c77ae "\ ""\ "MSDOS_or_FreeDOS_on_FreeDOS=93dd2ee87a995e36cbab0c2d5c2f041a "\ ""\ "Windows_XP_On_BootCamp2_with_AHCI_patch=c3fb54174bc479899d4ef6e45308dc18 "\ "Windows_XP_On_BootCamp2=cb4dabdd862da0508083b05814e198b8 "\ "Windows_Vista_on_XP_with_AHCI_patch=4979e1b9d70738759280f6962c2ad298 "\ "Windows_7_on_XP=7db43c1425e9ff3077dd62b776a50419 "\ "Windows_7_with_AHCI_patch=a243d3475531b0f6f0d7199043c2eb5c "\ "Windows_7_on_XP_with_AHCI_patch=24977c27865adec9ac8298f1a8d214bf "\ ""\ "Apple_Partition_Map_Block0_Driver_Descriptor_Map_390721968_blocks_and_Tiger_OS_9_drivers=087f35e49a39d52a46e3a94882869f51 "\ ""

    #All VBR hashes use all the bytes starting from offset 0x60. It may be better to use a different range for each type of VBR...

    VBRHASHES=\ "None_all_zeros=acf496fff71230daa6985a701f83ce49 "\ "NTFS_Windows_XP_NTLDR=dd1728a59343b9fa9458d80657f68771 "\ "NTFS_Windows_Vista_BOOTMGR=d1c278b56eeea9536d0eb5898fe6a0b5 "\ "GRUB_from_Ubuntu=332469fa146db809f58d6392e2e0bdce "\ "GRUB2_from_Ubuntu=9c249066e1eb9c842d8acdfe6d23a2e3 "\ "FAT32_FRDOS4.1=98050815221ee147066f99f806c23203 "\ "FAT32_FRDOS4.1_or_MSWIN4.1_BOOTMGR=aec608de8ac709d91e6f3340b643ab4d "\ "FAT12_BSD_4.4_BOOTMGR=4cc92970d5a3350bc72d2b975e28b915 "\ "FAT16_Non_system_disk=2a3d0f51ad246f115aa7d37891788857 "\ "FAT32_Non_system_disk_or_EFI=34f2d1f3c3ecce5c00cae8f0b82c922b "\ "HFS_boot_block_0=28f5bc1563fbaedeb8dabbd4ef9eb4c2 "\ ""

    FindHash () {
    # $1: name of hashed contents
    # $2: list of known hashes
    # $3: the hash to search for
    for CURHASH in $2; do
    THEHASH=`expr "$CURHASH" : '[^=]*=\(.*\)'`
    THEOS=`expr "$CURHASH" : '^\([^=]*\)='`
    if [ "$3" = "$THEHASH" ]; then
    echo ""
    if [ $DIDFIND = 1 ]; then
    echo "$1: $THEOS"
    echo "$1: Unrecognized (hash=$3)"

    DRIVELIST=`diskutil list | sed -n -E "/^[ ]*0: [ ]{0,25}([A-Za-z_]+)[ ]*\*[0-9.]+ [TGMK]B[ ]+(disk[0-9]+)$/s//\1_\2/p;/^[ ]*0: [ ]{0,26} .* \*[0-9.]+ [TGMK]B[ ]+(disk[0-9]+)$/s//whole_\1/p"`
    DRIVE=`expr "$PARTDRIVE" : '.*_\([^_]*\)'`
    PTYPE=`expr "$PARTDRIVE" : '\(.*\)_[^_]*'`
    echo "==============================================================================="

    diskutiloutput="`diskutil list \"/dev/$DRIVE\"`"
    echo "$diskutiloutput"

    DEVLIST=`echo "$diskutiloutput" | sed -n -E "/^.* (disk[0-9]+(s[0-9]+)*)$/s//\1/p"`
    for THEDEV in $DEVLIST; do
    echo "---------------------------------------------"
    diskutil info $THEDEV

    if [ "$PTYPE" = "Apple_partition_scheme" ]; then
    pdisk -r -l "/dev/$DRIVE"
    pdisk -r -l -f "/dev/$DRIVE"

    # use the same bytes as MBR hash even though Block0 contents are totally different
    HASH=`dd if="/dev/$DRIVE" bs=1 count=446 2> /dev/null | xxd -p -l 440 | md5`
    FindHash "Block0 contents" "$MBRHASHES" "$HASH"
    dd if="/dev/$DRIVE" bs=1 count=512 2> /dev/null | xxd -c 16
    elif [ "$PTYPE" = "GUID_partition_scheme" -o "$PTYPE" = "FDisk_partition_scheme" ]; then
    gptoutput="`gpt -r show \"$DRIVE\" 2>&1`"
    gptoutput2="`gpt -r show -l \"$DRIVE\" 2>&1`"
    fdiskoutput="`fdisk \"/dev/r$DRIVE\"`"

    echo "$gptoutput"
    echo "$gptoutput2"
    echo "$fdiskoutput"

    HASH=`dd if="/dev/$DRIVE" bs=1 count=446 2> /dev/null | xxd -p -l 440 | md5`
    FindHash "MBR contents" "$MBRHASHES" "$HASH"
    dd if="/dev/$DRIVE" bs=1 count=512 2> /dev/null | xxd -c 16

    if [ "$PTYPE" = "FDisk_partition_scheme" ]; then
    PARTLIST=`echo "$fdiskoutput" | sed -n -E "/^[ \*]+([0-9])\: .*\[[ ]*([0-9]+) \-[ ]+([1-9][0-9]*)\].*$/s//\1_\2_\3/p"`
    PARTLIST=`echo "$gptoutput" | sed -n -E "/^[ ]+([0-9]+)[ ]+([0-9]+)[ ]+([0-9]+)[ ]+GPT part \-.*$/s//\3_\1_\2/p"`

    for THEPART in $PARTLIST; do
    PNUM=`expr "$THEPART" : '\([0-9]*\)_'`
    PSTART=`expr "$THEPART" : '[0-9]*_\([0-9]*\)_[0-9]*'`
    PLENGTH=`expr "$THEPART" : '[0-9]*_[0-9]*_\([0-9]*\)'`

    HASH=`dd if="/dev/$DRIVE" bs=1 skip=\`expr "$PSTART" "*" 512 "+" 96\` count=416 2> /dev/null | xxd -p -l 440 | md5`
    FindHash "$PARTTYPE $PNUM @ $PSTART: VBR contents" "$VBRHASHES" "$HASH"
    dd if="/dev/$DRIVE" bs=512 skip=$PSTART count=1 2> /dev/null | xxd -c 16
    elif [ "$PTYPE" = "whole" ]; then
    HASH=`dd if="/dev/$DRIVE" bs=1 count=416 2> /dev/null | xxd -p -l 440 | md5`
    FindHash "0 @ 0: VBR contents" "$VBRHASHES" "$HASH"
    dd if="/dev/$DRIVE" bs=512 count=1 2> /dev/null | xxd -c 16
    echo "Unknown partition scheme"
    echo "==============================================================================="
    bless --info
    bless --getBoot
    echo "==============================================================================="
    ioreg -S -w 0 -c IOMedia | sed -n -E "/^[ \|]+ \+\-o (.*) <class IOMedia>$/,/^[ \|]+ }$/p" | sed -n -E "/^[ \|]+ \+\-o (.*)/s//\1/p;/^[ \|]+ \| (.*)/s//\1/p;"
    echo "==============================================================================="
    ioreg -w 0 -n AppleEFINVRAM | sed -n -E "/^[ \|]+[ ]+(\".*)$/s//\1/p;"
    echo "==============================================================================="

  • Ingwie

    Ingwie - 2011-05-30

    I think I found the issue: I didn't even see the option to put GRUB into the same partition as Ubuntu O.O....

    How can I correct this afterwards?
    Or, where do I find it when installing it? (I think i screwed Unity when trying out something, so I think I gonna reinstall that. xD)

  • Ingwie

    Ingwie - 2011-05-30

    Thanks for all of the help! I now figured out the problem's source for myself:

    I had a wrong Boot Code!

    sudo fdisc -i -y /dev/disk0

    Now it works all fine again... Thought, there could be a boot-code-reset for rEFIt - it'd make alot of things easyer.

    Thanks again!


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks