Voodooprojects

Chameleon => Bug Reports => Topic started by: kizwan on November 04, 2010, 03:14:08 PM

Title: boot0hfs on GPT disk
Post by: kizwan on November 04, 2010, 03:14:08 PM
Installed boot0hfs on GPT disk like this:-
fdisk440 -u -f /usr/standalone/i386/boot0hfs -y /dev/disk0

The bootloader stuck at:-
Code: [Select]
boot0: test
boot0: done
boot1: error

diskutil list:-
Code: [Select]
/dev/disk0
    #:                       TYPE NAME                    SIZE       IDENTIFIER
    0:      GUID_partition_scheme                        *160.0 GB   disk0
    1:                        EFI                         209.7 MB   disk0s1
    2:                  Apple_HFS OSX                     79.7 GB    disk0s2
    3:       Microsoft Basic Data                         79.8 GB    disk0s3
I tried to file a bug report over here (http://forge.voodooprojects.org/p/chameleon/issues/), but I can't register or log in.
Title: Re: boot0hfs on GPT disk
Post by: kizwan on November 06, 2010, 06:50:53 AM
Sorry, I forgot to mention that I did execute both commands:-
Code: [Select]
fdisk440 -u -f /usr/standalone/i386/boot0hfs -y /dev/disk0
dd if=/usr/standalone/i386/boot1h of=/dev/rdisk0s1

and it stuck here:-
Code: [Select]
boot0: test
boot0: done
boot1: error

If I execute these commands:-
Code: [Select]
fdisk440 -u -f /usr/standalone/i386/boot0 -y /dev/disk0
dd if=/usr/standalone/i386/boot1h of=/dev/rdisk0s1
I'm able to boot but since I set it up to dual-boot with windows 7,
I use boot0hfs instead because I want the windows partition set to
active partition (hibernate issue).

When I use boot0hfs, whether I set the EFI partition or windows
partition as active partition, it still stuck & won't continue
to boot.

I'm using Chameleon 2 RC5 rev. 629 (Trunk 619).
Title: Re: boot0hfs on GPT disk
Post by: Blackosx on November 09, 2010, 03:12:25 PM
Hi kizwan, sorry for any delay in a response here but I have been busy learning shell scripting (with still plenty to learn).

But on topic here, I have done some testing and can't reproduce your issue. I have set up a disk as yours using the latest Chameleon RC5 and using boot0hfs.
Code: [Select]
    #:                       TYPE NAME                    SIZE       IDENTIFIER
    0:      GUID_partition_scheme                        *160.0 GB   disk0
    1:                        EFI                         209.7 MB   disk0s1
    2:                  Apple_HFS OSX                     79.7 GB    disk0s2
    3:       Microsoft Basic Data                         79.8 GB    disk0s3

and I can happy boot OS X and Windows 7 from Chameleon.

I wonder what is causing it to fail at your end?
Title: Re: boot0hfs on GPT disk
Post by: kizwan on November 09, 2010, 03:46:58 PM
That is strange. I already tried a lot of time installing boot0hfs on my GPT disk. I always execute both command (fdisk440 & dd). Every time I got the same problem.

1) Which fdisk application did you use? Built-in fdisk (came with OSX) or fdisk440?
2) Do I need to follow the steps, first fdisk & second dd? Or it doesn't matter whichever executed first?

Thank you for your time.
Title: Re: boot0hfs on GPT disk
Post by: Blackosx on November 09, 2010, 04:01:08 PM
using fdisk440: (the following assumes I've already cd'd to the correct directory)
Code: [Select]
fdisk440 -f boot0hfs -u -y /dev/rdisk0
dd if=boot1h of=/dev/rdisk0s1
I don't think it matters which order you do the steps in, but I have always written stage 0 first.
Title: Re: boot0hfs on GPT disk
Post by: kizwan on November 09, 2010, 04:18:13 PM
This is very funny.  :lol: I tried again just now. Still same error. No problem with boot0 though. Can you post your boot, boot0hfs, boot1h & fdisk440? Thank you.
Title: Re: boot0hfs on GPT disk
Post by: Blackosx on November 09, 2010, 04:25:45 PM
I don't have them here with me, but the files I used were from the latest Chameleon trunk.
I'll re-do it this evening and post the actual files I use.
Title: Re: boot0hfs on GPT disk
Post by: Blackosx on November 09, 2010, 11:35:56 PM
hmmmm.. interesting!
I have re-checked my previous testing and you're right and it doesn't work. I tried the following on an HFS format EFI system partition:

Code: [Select]
fdisk440 -f boot0hfs -u -y /dev/rdisk0
dd if=boot1h of=/dev/rdisk0s1

and I saw exactly what you reported:

Code: [Select]
boot0: test
boot0: done
boot1: error

However, I knew I had it working and that was why I was so confident with my earlier posts, but I guess I had done so much testing over the weekend I had lost track of which method I had used. Sorry for any confusion. 

So I thought how did I get it working before? - Here's how, using the latest RC5 files from the Chameleon trunk and fdisk440, on a FAT format EFI system partition of disk using a GPT.

It involves using the steps from the shell scripts in the package installer which I believe are by mackerintel (someone please correct me if I'm wrong with that).

Write boot0hfs - as you have been doing
Code: [Select]
fdisk440 -u -f boot0hfs -y /dev/rdisk0
Write boot1f32 - as the original Chameleon package installer script
Code: [Select]
dd if=/dev/rdisk0s1 count=1 bs=512 of=/tmp/origbs
cp boot1f32 /tmp/newbs
dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc
dd of=/dev/rdisk0s1 count=1 bs=512 if=/tmp/newbs

Then you can mount the EFI system partition as normal and add the boot file and /Extra folder.

Looking at the disk sectors from before and after the steps in the script, I think (if I read it correctly) that it comes down to maintaining bytes 0x03h to 0x59h of the original bootsector, where as using dd if=boot1h of=/dev/rdisk0s1 just replaces the whole bootsector effectively invalidating the bootsector.

Hope that helps :)
Title: Re: boot0hfs on GPT disk
Post by: kizwan on November 10, 2010, 03:35:47 PM
I tried to change the EFI partition filesystem from HFS to FAT & reinstall bootloader as described above but it still don't want to boot. After a lot of trial & error, the EFI partition no longer like normal EFI partition.  :lol: I mistakenly use diskutil eraseVolume command to erase/format the EFI volume which causing it to automatically mounted whenever I boot into OSX. In the process to "restore" the EFI partition without formatting the whole disk, Windows 7 no longer bootable & also mistakenly erased the OSX partition.  :lol: I already tried to fix windows boot using Windows installer disk but still failed. Look like I have to erase the whole disk & start all over again. Except all of these unfortunate event, now I know how to recover EFI partition without erasing the whole disk. Fortunately this notebook is only test machine & don't have critical files.  ;D

I'll report back after I finished reformating & reinstalling (Windows & OSX) later. This is still strange though because this is pure GPT disk.
Title: Re: boot0hfs on GPT disk
Post by: Blackosx on November 10, 2010, 04:50:14 PM
I tried to change the EFI partition filesystem from HFS to FAT & reinstall bootloader as described above but it still don't want to boot. After a lot of trial & error, the EFI partition no longer like normal EFI partition.
Sometimes it's best to just format the EFI system partition and start a fresh.

I mistakenly use diskutil eraseVolume command to erase/format the EFI volume which causing it to automatically mounted whenever I boot into OSX.
Oh no!

I see you had the right idea to format the EFI system partition, but unfortunately that command was for using with OS X 10.5 Leopard. I guess this is a bit late now, but to format the EFI system partition on a disk with GPT from within Snow Leopard, use one of the following commands, replacing X with the disk number.

FAT: newfs_msdos -F 32 -v EFI /dev/rdiskXs1
HFS: newfs_hfs -v EFI /dev/rdiskXs1

In the process to "restore" the EFI partition without formatting the whole disk, Windows 7 no longer bootable & also mistakenly erased the OSX partition.  :lol: I already tried to fix windows boot using Windows installer disk but still failed.
Not sure what could have happened there? The Windows code on the disk's MBR shouldn't have been touched, and I'm surprised the Windows CD couldn't help. But to top it off with mistakenly erasing your OS X partition.... I wouldn't be surprised if you're not spitting feathers?

Look like I have to erase the whole disk & start all over again. Fortunately this notebook is only test machine & don't have critical files.  ;D
I've been there myself an more than one occasion.. but I guess we wouldn't attempt these things on a critical machine without backing up files first..  ;)

Except all of these unfortunate event, now I know how to recover EFI partition without erasing the whole disk.
Yeah, I guess there's always a positive to be found in every failure.  :P

I'll report back after I finished reformating & reinstalling (Windows & OSX) later. This is still strange though because this is pure GPT disk.
Okay.. well if you decide to try this again, I'll be here to help (if possible).
Title: Re: boot0hfs on GPT disk
Post by: kizwan on November 10, 2010, 06:19:58 PM
1) Re-format disk - GUID/GPT - 2 partitions
2) Install OSX
3) Setup EFI partition:-
Code: [Select]
newfs_hfs -v EFI /dev/rdisk0s14) Mount EFI partition
5) Untar all files & folders (Extensions, Boot.plist, etc) to EFI partition.
6) Unmount EFI partition
7) Re-format 2nd partition to FAT32 - for Windows 7
8) Install Windows 7
9) Boot to OSX using external boot disk (USB)
10) Install Chameleon 2 RC5 r629:-
Code: [Select]
fdisk440 -u -f /usr/standalone/i386/boot0hfs -y /dev/disk0
dd if=/dev/rdisk0s1 count=1 bs=512 of=/tmp/origbs
cp /usr/standalone/i386/boot1h /tmp/newbs
dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc
dd of=/dev/rdisk0s1 count=1 bs=512 if=/tmp/newbs
Result, stuck at:-
Code: [Select]
boot0: test
boot0: GPT
boot0: test
boot0: done

What is this for?
Code: [Select]
dd if=/dev/rdisk0s1 count=1 bs=512 of=/tmp/origbsLook like an upgrade if I'm not mistaken but upgrade from what? Do I need to install something first on disk0s1?

diskutil list:-
Code: [Select]
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *160.0 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS OSX                     80.0 GB    disk0s2
   3:       Microsoft Basic Data                         79.5 GB    disk0s3

fdisk /dev/rdisk0:-
Code: [Select]
Disk: /dev/rdisk0 geometry: 19457/255/63 [312581808 sectors]
Signature: 0xAA55
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: EE 1023 254  63 - 1023 254  63 [         1 -     409639] <Unknown ID>
 2: AF 1023 254  63 - 1023 254  63 [    409640 -  156290904] HFS+       
*3: 07 1023 254  63 - 1023 254  63 [ 156962688 -  155356936] HPFS/QNX/AUX
 4: 00    0   0   0 -    0   0   0 [         0 -          0] unused     

Thank you for your help.  ;D (This is not urgent to me though. Take your time.)
Title: Re: boot0hfs on GPT disk
Post by: Blackosx on November 10, 2010, 08:16:38 PM
Result, stuck at:-
Code: [Select]
boot0: test
boot0: GPT
boot0: test
boot0: done
That's because you have chosen to use an HFS formatted EFI system partition and write boot1h to the partition's bootsector. The instructions I listed above were for a FAT format EFI system partition using boot1f32. If you re-format your EFI system partition to FAT and follow the above commands with boot1f32, it should work.

We no longer need to use HFS format for the EFI system partition as by default it's FAT so why not keep it that way?

What is this for?
Code: [Select]
dd if=/dev/rdisk0s1 count=1 bs=512 of=/tmp/origbs
This command copies the 512bytes of the original GPT Header before making any changes.

It's needed because after writing the stage 1 loader to the temporary GPT header we're building in the 2nd line, the third line:
Code: [Select]
dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunccopies the necessary bytes from the original GPTHeader back to the new one we're writing to.

To quote wiki: The Primary GPT Header contains the Unique Disk GUID, Location of the Primary Partition Table, No. of possible entries in the partition table, CRC32 checksums of itself and the Primary Partition Table, Location of the Secondary (or Backup) GPT Header
Title: Re: boot0hfs on GPT disk
Post by: kizwan on November 10, 2010, 08:32:13 PM
If you re-format your EFI system partition to FAT and follow the above commands with boot1f32, it should work.
Already tried that also. Same result.
Title: Re: boot0hfs on GPT disk
Post by: Blackosx on November 10, 2010, 08:41:50 PM
I've just done it here and it works for me.
the last message I see before Chameleon's GUI loads is
Code: [Select]
boot1f: initDo you see any message regarding boot1f?
Title: Re: boot0hfs on GPT disk
Post by: kizwan on November 11, 2010, 04:45:39 AM
Code: [Select]
boot1f: initDo you see any message regarding boot1f?
No, message regarding boot1f never appear when I tried with FAT32 EFI.
Title: Re: boot0hfs on GPT disk
Post by: kizwan on November 11, 2010, 06:14:42 AM
I tried it again with FAT32 EFI partition.
(continue from previous)
1) Remove the Windows 7 partition using Disk Utility
2) Resize the OSX partition to cover all spaces available
3) Install boot0
Code: [Select]
fdisk440 -u -f /usr/standalone/i386/boot0 -y /dev/disk04) Set EFI partition as active partition
(Reboot - found able to boot into OSX)
5) Change the EFI partition filesystem from HFS to FAT32 (when I said "change", I meant erase/format):-
Code: [Select]
newfs_msdos -F 32 -v EFI /dev/rdisk0s16) Restore the EFI contents
7) Reinstall disk loader & whatnot:-
Code: [Select]
fdisk440 -u -f /usr/standalone/i386/boot0hfs -y /dev/disk0
dd if=/dev/rdisk0s1 count=1 bs=512 of=/tmp/origbs
cp /usr/standalone/i386/boot1f32 /tmp/newbs
dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc
dd of=/dev/rdisk0s1 count=1 bs=512 if=/tmp/newbs
(Reboot - found able to boot into OSX)
8) Split the partition to two. 2nd partition for Windows 7.
9) Reinstall Windows 7.
10) Boot into OSX using external boot disk (USB)
11) Reinstall disk loader & whatnot:-
Code: [Select]
fdisk440 -u -f /usr/standalone/i386/boot0hfs -y /dev/disk0
dd if=/dev/rdisk0s1 count=1 bs=512 of=/tmp/origbs
cp /usr/standalone/i386/boot1f32 /tmp/newbs
dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc
dd of=/dev/rdisk0s1 count=1 bs=512 if=/tmp/newbs

Result:-
Finally, able to boot into Windows 7 & OSX with boot0hfs.

I don't know why it doesn't work when I tried earlier.

Wish list:-
Please, please, please add support for EFI partition with HFS filesystem. I don't like FAT32 since it produced a lot of "dot" (.) files.
Title: Re: boot0hfs on GPT disk
Post by: Blackosx on November 11, 2010, 01:49:26 PM
Hi kizwan

Nice! - Good to read you have it working, although not with HFS.  ;D

I would have thought the combination of boot0hfs and boot1h can be used with an HFS format EFI system partition but I just haven't looked any further in to it. If I find out how then I'll post here. Or maybe one of the devs can shed some light here?
Title: Re: boot0hfs on GPT disk
Post by: kizwan on November 12, 2010, 01:32:07 AM
Someone claims at "Chameleon Open Issue" that EFI partition with HFS+ filesystem is already supported by boot0hfs. If this is true, why I can't get it to work?  :lol:
Title: Re: boot0hfs on GPT disk
Post by: Blackosx on November 12, 2010, 11:29:05 AM
Good news that someone is working with it.  ;D
I haven't had any time to do any further testing, but hopefully you'll have the answer soon.
Title: Re: boot0hfs on GPT disk
Post by: kizwan on November 12, 2010, 01:07:55 PM
Actually, I think he is not from chameleon team. Apparently he replied there without reading/understand my report. He thought I was claiming chameleon doesn't support HFS+ filesystem. To cover his mistake, he did claimed the boot0hfs + EFI + GPT + Windows does working on his computer but without given any details.  ;D
Title: Re: boot0hfs on GPT disk
Post by: Blackosx on November 13, 2010, 10:03:34 AM
I found some more time for testing and this time with a hard drive which I formatted with zeros for a fresh start. Then tried with boot0hfs and boot1h combo using the EFI system partition in HFS format. This works just fine :)

Start with:
Code: [Select]
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS OSX_TEST                250.1 GB   disk0s2
   3:       Microsoft Basic Data WIN_TEST                249.7 GB   disk0s3

Steps used:
newfs_hfs  -v EFI /dev/rdisk0s1
fdisk440 -f boot0hfs -u -y /dev/rdisk0
dd if=boot1h of=/dev/rdisk0s1
mkdir /Volumes/EFI
mount_hfs /dev/disk0s1 /Volumes/EFI
cp boot /Volumes/EFI
drag my Extra folder to /Volumes/EFI
umount -f /Volumes/EFI/
rm -rf /Volumes/EFI

I didn't bother with checking or changing the active partition although it's probably sensible to do so.

Conclusion:
I didn't do anything different to when I first tested (http://forum.voodooprojects.org/index.php/topic,1671.msg8669.html#msg8669) here which worked before, but it doesn't explain why I also had failure here (http://forum.voodooprojects.org/index.php/topic,1671.msg8677.html#msg8677). All I can think of was formatting the disk helped this time and maybe before my disk contained some erroneous data?
Title: Re: boot0hfs on GPT disk
Post by: kizwan on November 13, 2010, 10:33:43 AM
Did you installed windows?
Title: Re: boot0hfs on GPT disk
Post by: Blackosx on November 13, 2010, 10:44:46 PM
Sorry for the delay, I've been out all day..

But no, I hadn't installed Windows, but since you asked I have gone ahead and installed Windows 7 to disk0s3 then booting in to an OSX install on a second HDD I ran
Code: [Select]
fdisk440 -f boot0hfs -u -y /dev/rdisk0and I can 100% confirm it works just fine. Windows is the active partition and sleeps as it should.
Title: Re: boot0hfs on GPT disk
Post by: kizwan on November 14, 2010, 06:04:41 AM
This is really weird. Seriously, I'm not making this up. I already format the HDD many time. I done it carefully so that I didn't miss anything. The only difference between you & me this time is that you:-
1) Install OSX
2) Install bootloader (boot0hfs & whatnot)
3) Install Windows
4) Install boot0hfs

While I:-
1) Install OSX
2) Install Windows
3) Install bootloader (boot0hfs & whatnot)

I use r629. Can you post your boot files here (boot, boot0hfs, boot1h, etc)?
Title: Re: boot0hfs on GPT disk
Post by: Blackosx on November 14, 2010, 09:06:53 AM
One thing worth mentioning is the steps I did were actually:

1) format HDD
2) install bootloader (boot0hfs, boot1h & boot) to disk0 from OSX on disk1.
3) Install Windows
4) install boot0hfs.

Note: disk0s2 is blank without OSX.

Here are the Chameleon files I am using.
Title: Re: boot0hfs on GPT disk
Post by: kizwan on November 14, 2010, 09:45:11 AM
Thank you for the Chameleon files. I'll tried it again with my Acer Aspire 9420.

I have another computer which is Acer Aspire 3680. The HDD is GUID/GPT disk & EFI partition is HFS+ filesystem. It have OSX 10.5.8 & Windows Vista. It use AnVAL bootloader based on RC4. Since I no longer use OSX on this computer, I already set Windows Vista partition as active partition long time ago. Today I test boot0hfs on this computer & it work.
1) Boot to OSX 10.5.8 on internal disk (disk0) with external boot disk (disk1)
2) Install boot0hfs:-
Code: [Select]
fdisk440 -f boot0hfs -u -y /dev/rdisk03) Copy boot file to EFI partition (/dev/disk0s1 - /Volumes/EFI)
4) Reboot & confirm it does work

Do you agree if I said that boo0hfs is a bit fragile when it come to HFS+ EFI partition? I think the problem happen when I tried to install partition loader (boot1h). Do I need to install regular disk loader (boot0) first before installing dual-boot loader (boot0hfs) on new setup?
Title: Re: boot0hfs on GPT disk
Post by: kizwan on November 14, 2010, 10:21:20 AM
@Blackosx,

Update on Acer Aspire 9420. boot0hfs now works with HFS+ EFI partition. I'm using Chameleon files you gave me earlier. I also can confirmed that boot file you gave is different compared to r629's boot file (using diff). I don't know whether it is the caused of the problem since I didn't investigate it further.

This how I installed the boot loader:-
Code: [Select]
mkdir /Volumes/EFI
mount_msdos /dev/disk0s1 /Volumes/EFI
tar -cjvf ~/Desktop/EFI.tar.bz2 /Volumes/EFI
umount /Volumes/EFI
newfs_hfs  -v EFI /dev/rdisk0s1
fdisk440 -f boot0hfs -u -y /dev/rdisk0
dd if=boot1h of=/dev/rdisk0s1
mkdir /Volumes/EFI
mount_hfs /dev/disk0s1 /Volumes/EFI
cd /
tar -jxvf ~/Desktop/EFI.tar.bz2
cp boot /Volumes/EFI
umount -f /Volumes/EFI/
rm -rf /Volumes/EFI

Now it works & I'm happy. May I know which branch or trunk these boot files came from? Never mind, I just check & the boot files is from r629 but I don't know why it is different with mine. Mine was taken from RC5 Installer package (test installer at insanelymac). Anyway, this just proved it does work.

 As I always be, thank you very much for your help.  ;D