E-Maculation
https://www.emaculation.com/forum/

QEMU: boot fail
https://www.emaculation.com/forum/viewtopic.php?f=34&t=10167
Page 1 of 1

Author:  wontonsoup [ Tue May 14, 2019 3:41 am ]
Post subject:  QEMU: boot fail

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:
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 `[url]image[/url]')

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.

Author:  Cat_7 [ Tue May 14, 2019 5:42 am ]
Post subject:  Re: QEMU: boot fail

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

Author:  wontonsoup [ Tue May 14, 2019 7:03 am ]
Post subject:  Re: QEMU: boot fail

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

Author:  UbuntuXP [ Wed May 15, 2019 5:09 am ]
Post subject:  Re: QEMU: boot fail

If patching OVMF doesn't work, you might try and get an HFS+ driver loaded on the EFI System Partition.

Author:  wontonsoup [ Wed May 15, 2019 5:40 am ]
Post subject:  Re: QEMU: boot fail

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:
Shell>> load ntfsplus_x64.efi
Shell>> map -r

However, the file is not found...

Code:
Shell>> dir
ls: current directory not specified.


I guess I would have to first specify the driver exists in the `qemu...` instructions. How?

Author:  UbuntuXP [ Wed May 15, 2019 2:30 pm ]
Post subject:  Re: QEMU: boot fail

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.

Author:  mabam [ Wed May 15, 2019 6:59 pm ]
Post subject:  Re: QEMU: boot fail

wontonsoup wrote:
I found an HFS+ EFI driver here: https://efi.akeo.ie/. [...]
Code:
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".

Author:  wontonsoup [ Fri May 17, 2019 3:00 am ]
Post subject:  Re: QEMU: boot fail

Not sure what you mean by first partition:

Code:
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:
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?

Author:  wontonsoup [ Fri May 17, 2019 3:10 am ]
Post subject:  Re: QEMU: boot fail

PS: no luck with alternative method:

Code:
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

Author:  UbuntuXP [ Fri May 17, 2019 11:57 pm ]
Post subject:  Re: QEMU: boot fail

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).

Author:  wontonsoup [ Sat May 18, 2019 1:57 am ]
Post subject:  Re: QEMU: boot fail

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:
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:
host# qemu-img create -f qcow2 mac_hdd.img 20G


There is too much for me to guess to hope to get anywhere.

Author:  adespoton [ Sat May 18, 2019 5:07 pm ]
Post subject:  Re: QEMU: boot fail

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.

Author:  wontonsoup [ Sun May 19, 2019 3:45 am ]
Post subject:  Re: QEMU: boot fail

Thank you for the advice.

Quote:
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.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/