QEMU: boot fail

About Qemu-system-ppc, a PPC Mac emulator for Windows, macOS and Linux that can run Mac OS 9.0 up to Mac OS X 10.5

Moderators: Cat_7, Ronald P. Regensburg

Post Reply
wontonsoup
Space Cadet
Posts: 7
Joined: Thu May 09, 2019 6:28 am

QEMU: boot fail

Post by wontonsoup »

I'm trying to run Mac OS X on Linux/QEMU (for computer training's sake).

I have followed these instructions. Brief recap:

* Install edk2 on the host, and build the patched OVMF firmware blob, which is described as "enabling UEFI (the successor of BIOS) support for Virtual Machines"

* Create an OS X bootable image on the original machine. For this, I followed these instructions that are tailored to El Capitan. I made sure the copy on the host passes the md5 checksum.

* Create an empty hard drive image on host and boot using the iso file via QEMU:

Code: Select all

host# qemu-img create -f qcow2 mac_hdd.img 64G

qemu-system-x86_64 -machine q35,accel=kvm -bios ~/OVMF.fd -m 4096 \
      -cpu Penryn -smp 4,cores=2 \
      -usb -device usb-kbd -device usb-tablet \
      -device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" \
      -netdev user,id=usr0 -device e1000-82545em,netdev=usr0,id=vnet0 \
      -device ide-drive,bus=ide.0,drive=MacDVD \
      -drive id=MacDVD,if=none,snapshot=on,file=/media/er/Vol1/Software/X/ElCapitan/ElCapitan.iso \
      -device ide-drive,bus=ide.2,drive=MacHDD \
      -drive id=MacHDD,if=none,file=/home/er/host/mac_hdd.img \
      -monitor stdio -serial file:log 
The `-serial' option was added based on this post.

This takes me to an UEFI shell. I exit it. That takes me to a BIOS like menu. In the boot manager I selected the one listed as 'Mac', then Continue. This takes me to a screen that says Start PXE over Ipv4, and then back to the BIOs like menu. Here's the log file.

Based on this post, I opened the Boot Maintenance Manager hoping to Boot from file, but there are no files listed.

Any troubleshooting tips?

Screenshots:

(`[img]image[/img]' does not show in the preview so I have replaced it by `image')

https://postimg.cc/z3cthqxn
https://postimg.cc/DSVxCBk0
https://postimg.cc/crfRJW21
https://postimg.cc/nX0Qshkx
https://postimg.cc/n94XnFz6
https://postimg.cc/Yh8SRymf

PS: I did run one of the recommended script on the original machine to determine the OSK key.
User avatar
Cat_7
Expert User
Posts: 6145
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: QEMU: boot fail

Post by Cat_7 »

Hi,

The forum deals with qemu emulating the ppc based macs, not intel based macs. However, I see you want to boot over the network (Start PXE over Ipv4). The MAC:xx.xx.xx.xx you see is the MAC address of a network card. This seems not to be want you want.
So try booting from one of the qemu disks.

Best,
Cat_7
wontonsoup
Space Cadet
Posts: 7
Joined: Thu May 09, 2019 6:28 am

Re: QEMU: boot fail

Post by wontonsoup »

Thanks.

I selected successively HD QM00001 and QM00002 in the boot manager, followed by Esc, followed by Continue. What I then get is ">>Start PXE over IPv4", and then back to the shell.

I have tinkered with Boot Manager Maintenance, by changing Next Boot Value, I don't think that's useful as the boot process iterates through each.

Shell screen shot
Default boot order
User avatar
UbuntuXP
Tinkerer
Posts: 68
Joined: Sat Feb 08, 2014 8:15 pm

Re: QEMU: boot fail

Post by UbuntuXP »

If patching OVMF doesn't work, you might try and get an HFS+ driver loaded on the EFI System Partition.
"Unix was not designed to stop you from doing stupid things, because that would also stop you from doing clever things."

Doug Gwyn
wontonsoup
Space Cadet
Posts: 7
Joined: Thu May 09, 2019 6:28 am

Re: QEMU: boot fail

Post by wontonsoup »

UbuntuXP wrote:If patching OVMF doesn't work, you might try and get an HFS+ driver loaded on the EFI System Partition.
I found an HFS+ EFI driver here: https://efi.akeo.ie/. Proceeding gropingly, I copied the file to where there *img resides and based on their instructions, from the UEFI Shell:

Code: Select all

Shell>> load ntfsplus_x64.efi
Shell>> map -r
However, the file is not found...

Code: Select all

Shell>> dir
ls: current directory not specified.
I guess I would have to first specify the driver exists in the `qemu...` instructions. How?
User avatar
UbuntuXP
Tinkerer
Posts: 68
Joined: Sat Feb 08, 2014 8:15 pm

Re: QEMU: boot fail

Post by UbuntuXP »

Wait, you copied the HFS+ driver into the same folder as your disk image? You actually need to copy it into the first partition of your disk image to use it. This partition is known as the EFI System Partition, or ESP, and is formatted FAT32 at about 200-300 megabytes with partition code EF00.
"Unix was not designed to stop you from doing stupid things, because that would also stop you from doing clever things."

Doug Gwyn
User avatar
mabam
Master Emulator
Posts: 497
Joined: Wed Apr 10, 2013 9:32 am

Re: QEMU: boot fail

Post by mabam »

wontonsoup wrote:I found an HFS+ EFI driver here: https://efi.akeo.ie/. [...]

Code: Select all

Shell>> load ntfsplus_x64.efi
Shell>> map -r
However, the file is not found...
UbuntuXP wrote:You actually need to copy it into the first partition of your disk image to use it.
Also, according to the link you provided, the file is called "hfsplus_x64.efi".
wontonsoup
Space Cadet
Posts: 7
Joined: Thu May 09, 2019 6:28 am

Re: QEMU: boot fail

Post by wontonsoup »

Not sure what you mean by first partition:

Code: Select all

host # fdisk -l mac_hdd.img
Disk mac_hdd.img: 192 KiB, 196608 bytes, 384 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
I guess I would first have to mount `mac_hdd.img' in order to copy the driver. Correct?

Following this instruction. I did:

Code: Select all

host # mkdir -p /mnt/disk
host # mount -o loop,offset=32256 mac_hdd.img /mnt/disk
mount: /mnt/disk: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
host # mount -o loop mac_hdd.img /mnt/disk
mount: /mnt/disk: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
What to do?
Last edited by wontonsoup on Fri May 17, 2019 3:12 am, edited 2 times in total.
wontonsoup
Space Cadet
Posts: 7
Joined: Thu May 09, 2019 6:28 am

Re: QEMU: boot fail

Post by wontonsoup »

PS: no luck with alternative method:

Code: Select all

host # modprobe nbd max_part=16
host # qemu-nbd -c /dev/nbd0 mac_hdd.img
host # partprobe /dev/nbd0
host # mount /dev/nbd0p1 /mnt/disk
mount: /mnt/disk: special device /dev/nbd0p1 does not exist.
host # partprobe -s
/dev/sda: msdos partitions 1 2 <5>
/dev/sdb: msdos partitions 1 3 2
/dev/nbd0: msdos partitions
User avatar
UbuntuXP
Tinkerer
Posts: 68
Joined: Sat Feb 08, 2014 8:15 pm

Re: QEMU: boot fail

Post by UbuntuXP »

Have you made any partitions yet? If not, then you'll need to make a partition table with GPT using gdisk and all the partitions you'll need (walkthrough here if you need it).
"Unix was not designed to stop you from doing stupid things, because that would also stop you from doing clever things."

Doug Gwyn
wontonsoup
Space Cadet
Posts: 7
Joined: Thu May 09, 2019 6:28 am

Re: QEMU: boot fail

Post by wontonsoup »

I haven't done anything that I haven't published, so no I haven't done any partition yet.

I would have thought the boot process would take care of creating partitions. That's what the post that claims to run OS X on a qemu guest let's you believe, and so I don't see why an hfs+ driver is needed. In any case, I'm too novice to figure out how to properly create a partition. I tried with `parted`, which seems a more obvious choice than `gdisk`, but I'm not sure what would be the right options and it failed anyway.

Code: Select all

host # parted mac_hdd.img
GNU Parted 3.2
Using /home/er/host/mac_hdd.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Error: /home/er/host/mac_hdd.img: unrecognised disk label
Model:  (file)                                                            
Disk /home/er/host/mac_hdd.img: 197kB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags: 
(parted) mklabel loop
(parted) mkpart primary 0 -1
parted: invalid token: primary
File system type?  [ext2]? no
parted: invalid token: no
File system type?  [ext2]? ^C                                             
Error: Expecting a file system type.
(parted) mkpart primary hfs+ 0 -1                                              
parted: invalid token: primary
File system type?  [ext2]? ^C                                             
Error: Expecting a file system type.
(parted) ^Z                                                               
[1]+  Stopped                 parted mac_hdd.img
(parted) print                                                            
Model:  (file)
Disk /home/er/host/mac_hdd.img: 197kB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags: 

Number  Start  End    Size   File system  Flags
 1      0.00B  197kB  197kB
I'm puzzled as to why it prints 197kb. Reminder (I changed from 64G to 20G):

Code: Select all

host# qemu-img create -f qcow2 mac_hdd.img 20G
There is too much for me to guess to hope to get anywhere.
User avatar
adespoton
Forum All-Star
Posts: 4227
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: QEMU: boot fail

Post by adespoton »

Hi wontonsoup,

Considering the difficulties you're having getting all this to work, it would probably make more sense to take this discussion to a forum that handles qemu-x86 issues, instead of on this site where we deal with qemu-ppc.

It looks like there's a number of sites discussing similar issues when I do a google search for qemu-system-x86_64.

You probably want something like this:
https://www.contrib.andrew.cmu.edu/%7Esomlo/OSXKVM/

Note that under Linux, you'll need virtio and kvm installed to get things working properly, even with the patched edk2 and OVMF firmware blob.

Also: that site links an OVMF blob that's verified to work.

I also believe you never stated which version of OS X you were trying to install? In my experience, building a bootable disk image changes for each OS version after Mavericks. I've got a list of instructions tucked away somewhere based on the version.

With Mojave, I've resorted to using a custom booter, because the standard UEFI has problems recognizing the boot file. But I'm doing this on macOS, where there's already APFS and HFS+ support.
wontonsoup
Space Cadet
Posts: 7
Joined: Thu May 09, 2019 6:28 am

Re: QEMU: boot fail

Post by wontonsoup »

Thank you for the advice.
I also believe you never stated which version of OS X you were trying to install?
I did say "bootable image .... taylored to ElCapitan". The instructions I follow says "capable of supporting OS X (up to Sierra) ", which comes after.
Post Reply