This page is a wiki. Please login or create an account to begin editing.


10 posts / 0 new
Last post
Jatoba's picture
Offline
Joined: 2018 Apr 16
QEMU and DMGs?

Hi guys, so as I go through my Mac hardware abstinence, I started setting up QEMU with everything Mac I have, and that includes a bunch of backups I have, in DMG format. So I'd like to get QEMU to mount/use/boot from/access them. So far, specifying the DMGs' full paths with "format=raw" and with either "media=disk" or "media=cdrom" has not worked, both with "boot c" and "boot d".

I have read that QEMU has at least read-only support for DMGs, but when I try to boot off them, it fails and stays in OpenFirmware. And when I boot from somewhere else (but still specify DMGs to be also mounted), that "works", and my guest OS even detects the DMGs, and Disk Util in Mac OS X even reports their drive size, but no partitions or data or anything. Perhaps the problem is that those images are being mounted in the guest OS as drives, and not as images? Is there any way I can fix this?

Also worth noting, I can't "unpack" my DMGs in my host OS: there is no physical disk space to do so, and my backups and QEMU setup are in an external drive for that reason. But that drive is NTFS (because I'm on Windows 7), and although I have Mojave here, NTFS is read-only. I guess with a 3rd party tool (any free one?), I could "unpack" the DMGs there, but even in such a case, how would I proceed to insert contents into my QEMU IMG file from the host OS?

Until this is figured out, if it will be, I am, of course, using extremely unorthodox methods to get past this problem, although it will take 2 or so weeks of leaving my laptop on non-stop just to get past it, all because I haven't been able to mount those DMGs correctly under guest OS Mac OS X via QEMU's arguments.

TL;DR Can I use DMGs in QEMU? How?

Comments

Jatoba's picture
Offline
Joined: 2018 Apr 16

Also, relevant: https://qemu.weilnetz.de/doc/qemu-doc.html

I tried adding "readonly" to the -drive param specifying the DMG, but I get this message when trying to start up the emulator: "Initialization of device ide-hd failed: Block-node is readonly".

So then I tried playing around with the if=, bus= and unit= "subparameters", but no matter what combination of values I use for those, the emulator refuses to start, saying "machine type does not support if=x,bus=x,unit=x" (even when I leave out bus= and unit=).

Unorthodox methods are all I have left now.

For the record, here are my -drive args:
-drive file="full path\MacOSX10.4.11.img",format=raw,media=disk
-drive file="full path\myDMGfile.dmg",format=raw,media=disk,readonly

adespoton's picture
Offline
Joined: 2015 Feb 15

try using diskutil to convert your dmg into a cdr -- dmg is a container format, and one of the common contents of a dmg from that period is "compressed archive" -- which QEMU can't read.

Converting to a cdr means it'll now be usable in either raw format or as a CD image (cdr == iso).

Jatoba's picture
Offline
Joined: 2018 Apr 16

Yeah, I thought of converting them to CDR, but the problem is that I have no destination drive I can select: the DMGs occupy some 250 GB of space, which I don't have for this conversion, other than an NTFS drive I can't erase (because of other important files), and Mac OS X has read-only access to such drives. The DMGs are in that NTFS drive. With a 3rd party add-on, I could probably enable NTFS support in Mojave, and thus be able to convert them to CDR, though I don't know if there is any free version of such an add-on (and my QEMU usage isn't so serious that I'm willing to cash in on that).

But thanks for the suggestion, because it reinforces to me that I'm probably not missing some boot option, but rather it's the situation I'm stuck in. Knowing this gives me direction. Smile

MikeTomTom's picture
Online
Joined: 2009 Dec 7

If you have a Windows OS...
On Windows systems and NTFS volumes, I use the commandline tool "dmg2img"

Add it's name to Windows' PATH so you can access it from any directory.

The syntax is simple: dmg2img yourfile.dmg  yourfile.iso  [hit return & wait]

You can use either ".img" or ".iso" as the output filename suffix. The result is the same. You could even use ".cdr" if you're more comfortable with that term. I just prefer ".iso" as the output filename.

adespoton's picture
Offline
Joined: 2015 Feb 15

Probably worth noting that the resulting images will be *significantly* larger than the compressed originals; it might be worth running them through 7z for long-term storage.

Jatoba's picture
Offline
Joined: 2018 Apr 16

Sorry, I forgot to mention in my last post that none of my DMGs are compressed, so this didn't end up being an issue. (Though it's funny that, despite that, QEMU still couldn't use them directly.)

Jatoba's picture
Offline
Joined: 2018 Apr 16

@MTT Wow, many thanks! What a helpful, convenient tool! I can see this being useful in multiple ways.

After some 6 or so hours, I was able to convert the biggest DMG I wanted to use, about 170GB in size, into a 171GB ISO. It looked as if the tool was frozen and doing nothing during all that time, probably because of the sheer amount of files to write to the new image (hundreds of thousands of files) and perhaps also the image size, but then it "suddenly" concluded its task successfully and gave due feedback. (Of course, doing the entire operation on a spinning hard disk connected over USB 2.0 didn't exactly help with the speed.)

Just as a little side note, the converted image didn't get mounted in QEMU OS9 (although it detects the "drive", like before), but it got mounted in QEMU OSX (non-Server ver.) 10.4.11 successfully.

For the curious, the workaround I was using was to setup an FTP server in the host OS, make my external drive into a home directory, then connect to the directory with an FTP client with the guest OS, and then started transferring everything into a huge, blank IMG file created with QEMU, which I mounted as a drive. Particularly funny, because the FTP home directory, the QEMU directory and the QEMU image file I was using were all physically in the same drive.

I had also tried mounting the USB drive into the guest OS via QEMU boot arguments, but that didn't work out, even after going all the way out to get the USB drive product and vendor IDs via devcon.exe. So yeah.

MikeTomTom's picture
Online
Joined: 2009 Dec 7

YW, Jatoba. I tended to use it more for converting files that sometimes get uploaded to here as .dmg and they are for classic Mac OS's only. Plus when I'm not near a Mac box at the time Wink

I can't say that I've ever used it for super large .dmg containers like you have. So that's really great that it was successful for you.

Tho' I wonder if it's not mounting in OS9 is because it is larger than 120GB?

Jatoba's picture
Offline
Joined: 2018 Apr 16

In the past I created and mounted a 190GB image based on a partition in OS 9, so it can handle that stuff. The reason I had it in DMG, though, is because that way the unused space isn't accounted for (thus the 170GB result), while Disk Copy replicated the size of the source partition it was imaging (190GB) even when unnecessary.