Jump to content

OpenCore - Trouble making the Installer on Linux


flexmcmurphy
 Share

6 posts in this topic

Recommended Posts

Hello,

 

I am following the OpenCore Installer guide to build a Hackintosh. I am trying to use Linux to make a USB drive installer for Mac OS Catalina. I wonder can anyone help me?

 

In Method 2 (in case 1 didn't work) when I run this command:

dmg2img -p <the partition number> -i BaseSystem.dmg -o <your 3GB+ partition>

i.e:

dmg2img -p 4 -i BaseSystem.dmg -o /dev/sdb2

 

Am I supposed to be able to mount that hfs partition? Because when I try:

modprobe hfsplus

sudo mount -t hfsplus -o loop /dev/sdb2 /mnt

 

I get an error saying it won't mount and then if I run the hfs file system check command in linux I get some error as well.

In contrast if I use the Boot Disk Utility tool from Windows OS to create that hfs partition using the same BaseSystem.dmg file then I CAN mount that partition in Linux.

 

So I am worried that whatever is happening in my Linux making that hfs partition from the same BaseSystem.dmg it will result in my USB installer just not working.

 

Lastly, I also had trouble extracting the 4.hfs System Image file from BaseSystem.dmg. I think the OpenCore installer instructions were updated or something and now this can be done with the dmg2img command but I still want to know if it is possible to extract just the 4.hfs System Image file from BaseSystem.dmg using the 7z command. Something like:

 

7z e -txar *.pkg *.dmg; 7z e *.dmg */Base/

 

Because when ever I run variations on that 7z command I always just get the entire files and folders extracted out of BaseSystem.dmg instead of just the 4.hfs file.

 

Can anyone help with these problems?

 

Thank you,

 

Flex

Link to comment
Share on other sites

It's probably easiest if you just create one Fat32 partition and shove the BaseSystem.dmg and chunklist into "com.apple.recovery.boot". As far as I know, you shouldn't be able to mount that partition unless you have an HFS+ driver. I don't think Linux comes with one though. I can take a look later at the linux instructions but the first method is generally the easiest if you can do it.

  • Like 1
Link to comment
Share on other sites

Thanks 1Revenger1

 

But my Ubuntu mate can mount hfs partitions... I installed the hfsprogs and hfsutils packages.

 

I'm actually trying to go a different approach to what you mentioned. I'm following this YouTube video in which the guy is also using OpenCore but makes a full MacOS installer package so the steps are a bit different. He does it all in Windows and uses a program called: Boot Disk Utility to format a USB drive with a fat32 and hfs+ partition and then also uses that program to extract and write BaseSystem.dmg to the second hfs+ partition. I was trying to replicate that process in Linux but don't know how to.

 

Following that video closely it looks like Boot Disk Utility uses 7z to extract 4.hfs from BaseSystem.dmg but I don't know what 7z options and parameters I need to use to do that in Linux. But I was able to mount the Boot Disk Utility created hfs partition in Linux by simply inserting the USB into my Ubuntu mate and the partitions appeared in Caja. Linux can read/write to hfs but unfortunately cannot extend a hfs/hfs+ partition.

 

So in short I prefer to use his method that's more complicated than copying BaseSystem.dmg and chunklist into "com.apple.recovery.boot" because this way I end up with a full installer I can re-use when it inevitably doesn't work then I don't have to keep re-downloading 8GB files all over again!

 

So I think my main issue is how to use Linux to extract the 4.hfs (disk image) from BaseSystem.dmg and write it to a USB key such that it will mount in Linux. When I used the dmg2img command in the OpenCore Instructions I cannot then mount that partition in Linux. I need it to mount in Linux because I then need to add the additional install files into it to make a full installer. In case you are feeling generous with your time I also posted a long question about this on askubuntu describing what I have tried.

 

Cheers,

 

Flex

Link to comment
Share on other sites

The author of the Boot Disk Utility tool kindly explained to me the 7z command that he uses to extract just the Disk Image (4.hfs) from BaseSystem.dmg

 

Here it is:

7z e -w -tdmg -otmp -y -- BaseSystem.dmg *.hfs

 

From testing, the -w (include a temporary working directory) can be omitted.

The -tdmg tells 7z the archive Type and is essential.

 

I would never have figured this out by myself !

 

I still don't know how to use linux tools to write that 4.hfs to a USB key that will then mount in Linux.

Instead I get this error:

Quote

wrong fs type, bad option, bad superblock on /dev/sdc2, missing codepage or helper program, or other error.

And in dmesg I get these errors:
 

Quote

 

hfsplus: invalid secondary volume header

hfsplus: unable to find HFS+ superblock

 

 

I wish I could figure this out and have a workflow that does the job of creating, entirely in Linux, a full package macOS installer.

 

Any help much appreciated.

 

Flex

Link to comment
Share on other sites

On 5/27/2021 at 8:26 PM, flexmcmurphy said:

The author of the Boot Disk Utility tool kindly explained to me the 7z command that he uses to extract just the Disk Image (4.hfs) from BaseSystem.dmg

 

Here it is:


7z e -w -tdmg -otmp -y -- BaseSystem.dmg *.hfs

 

From testing, the -w (include a temporary working directory) can be omitted.

The -tdmg tells 7z the archive Type and is essential.

 

I would never have figured this out by myself !

 

I still don't know how to use linux tools to write that 4.hfs to a USB key that will then mount in Linux.

Instead I get this error:

And in dmesg I get these errors:
 

 

I wish I could figure this out and have a workflow that does the job of creating, entirely in Linux, a full package macOS installer.

 

Any help much appreciated.

 

Flex

Do you have a friend or a local ISP kiosk with a late model mac to use createinstallmedia?

 

Your easiest non-mac path would be to obtain or create an ISO version of the installer and burn it to a USB stick.  Supply or modify the EFI for your hardware.

 

For linux:

https://www.uubyte.com/convert-dmg-to-iso-free.html

 

For Ubuntu:

Step 1 : Lanuch Terminal app and update the system via this command (sudo apt-get update)

Step 2: After the package installed sucessfully, then input this command to install the package (sudo apt-get install dmg2img)

Step 3: Finally input this command to convert DMG to ISO (dmg2img demo.dmg demo.iso)

Replace the example files with the real file names. You must also run Terminal in the same directory location as your DMG file.

 

You could also try this with windows and post if it works for you.

https://www.poweriso.com/tutorials/convert-dmg-to-iso.htm

Edited by HenryV
add info
  • Like 1
Link to comment
Share on other sites

@HenryV Thanks for your help.

 

I figured out a way to write that 4.hfs to a USB key that will then mount in Linux..

 

You need to partition a USB key with a 200MB EFI Fat32 partition and the rest a hfs+ partition.

I did it like this in a bash script:

 
createPartitions(){


dev_block="/dev/sdb"
echo "Creating Partitions on "$dev_block"..."
sfdisk $dev_block -uS <<-EOF
start=63, size=409600, type=ef, bootable
start=411648, type=af
EOF

}

 

 

Assuming your USB key is at /dev/sdb... Then format the first partition as FAT32

mkfs.fat -n "BDU" -F 32 /dev/sdb1

 

And the second partition as hfs+

# sudo mkfs.hfsplus -v "macOS Base System" /dev/sdb2

 

Mount 4.hfs in Linux

# sudo mount -t hfsplus -o loop 4.hfs /mnt/4hfs

 

Mount the hfs+ partition of the USB key in Linux

# sudo mount -t hfsplus /dev/sdb2 /mnt/usbp2

 

Copy the contents of 4.hfs to the created and formatted hfs+ partition on the usb key

This will take a few minutes for the copy to complete.

# sudo rsync -avxHEWz --numeric-ids --info=progress2 /mnt/4hfs/ /mnt/usbp2

 

Cheers,

 

Flex

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...