overdue-scratch

Author Topic: boot0hfs on GPT disk  (Read 18161 times)

0 Members and 1 Guest are viewing this topic.

kizwan

  • Observer
  • Posts: 20
boot0hfs on GPT disk
« 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.
« Last Edit: November 04, 2010, 04:33:16 PM by kizwan »

kizwan

  • Observer
  • Posts: 20
Re: boot0hfs on GPT disk
« Reply #1 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).
« Last Edit: November 06, 2010, 06:58:05 AM by kizwan »

Blackosx

  • Forum Moderator
  • Posts: 1150
Re: boot0hfs on GPT disk
« Reply #2 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?
« Last Edit: November 09, 2010, 03:14:52 PM by Blackosx »
10.10.5 / 10.11 GM1 | Asus Maximum IV Gene-Z | i7-2600 3.40GHz | 4GB | Radeon 5770 1GB

kizwan

  • Observer
  • Posts: 20
Re: boot0hfs on GPT disk
« Reply #3 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.

Blackosx

  • Forum Moderator
  • Posts: 1150
Re: boot0hfs on GPT disk
« Reply #4 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.
10.10.5 / 10.11 GM1 | Asus Maximum IV Gene-Z | i7-2600 3.40GHz | 4GB | Radeon 5770 1GB

kizwan

  • Observer
  • Posts: 20
Re: boot0hfs on GPT disk
« Reply #5 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.

Blackosx

  • Forum Moderator
  • Posts: 1150
Re: boot0hfs on GPT disk
« Reply #6 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.
10.10.5 / 10.11 GM1 | Asus Maximum IV Gene-Z | i7-2600 3.40GHz | 4GB | Radeon 5770 1GB

Blackosx

  • Forum Moderator
  • Posts: 1150
Re: boot0hfs on GPT disk
« Reply #7 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 :)
« Last Edit: November 10, 2010, 12:01:25 PM by Blackosx »
10.10.5 / 10.11 GM1 | Asus Maximum IV Gene-Z | i7-2600 3.40GHz | 4GB | Radeon 5770 1GB

kizwan

  • Observer
  • Posts: 20
Re: boot0hfs on GPT disk
« Reply #8 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.

Blackosx

  • Forum Moderator
  • Posts: 1150
Re: boot0hfs on GPT disk
« Reply #9 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).
« Last Edit: November 10, 2010, 04:51:46 PM by Blackosx »
10.10.5 / 10.11 GM1 | Asus Maximum IV Gene-Z | i7-2600 3.40GHz | 4GB | Radeon 5770 1GB

kizwan

  • Observer
  • Posts: 20
Re: boot0hfs on GPT disk
« Reply #10 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.)

Blackosx

  • Forum Moderator
  • Posts: 1150
Re: boot0hfs on GPT disk
« Reply #11 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
« Last Edit: November 10, 2010, 08:20:39 PM by Blackosx »
10.10.5 / 10.11 GM1 | Asus Maximum IV Gene-Z | i7-2600 3.40GHz | 4GB | Radeon 5770 1GB

kizwan

  • Observer
  • Posts: 20
Re: boot0hfs on GPT disk
« Reply #12 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.

Blackosx

  • Forum Moderator
  • Posts: 1150
Re: boot0hfs on GPT disk
« Reply #13 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?
10.10.5 / 10.11 GM1 | Asus Maximum IV Gene-Z | i7-2600 3.40GHz | 4GB | Radeon 5770 1GB

kizwan

  • Observer
  • Posts: 20
Re: boot0hfs on GPT disk
« Reply #14 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.