Restore .dmg containing multiple partitions to bootable USB flash drive

I have a .dmg file which was created from a disk consisting of two partitions. When I mount the dmg both partitions pop up, so I know the imaging worked properly. One partition is HFS+ and the other is FAT32.

So far, I've been unable to find a way to restore the dmg to a flash drive where both partitions are accounted for. I've tried using hdiutil, dd, asr, and rain dancing, none of which will restore the image properly with both partitions present.

I'm sure I'm misconfiguring something along the way, and I'm hoping some of you ninjas out there can direct me accordingly.

I'm working on a Mac.

Thanks!

Did you try partitioning the flash drive first?

My question may not be helpful, but I have four macs, and a number of flash drives I use for a variety of reasons, and one of my flash drives is partitioned both FAT32 and HFS+ as I recall.

Sorry if my reply is not helpful.

Thanks for your reply.

I'm able to accomplish the task using several steps, but I'm hoping there's a way to get everything done in a single command. Is this even possible?

Without knowing what you're doing it is very hard to suggest ways to do it in fewer steps! My crystal ball just isn't working that clearly this morning.

What steps did you perform to complete your task? (Please don't include a series of steps that includes rain dancing... From experience, we have found rain dancing produces random results. And, water and electronics don't mix well together.)

Hi, Don. Thanks for getting back to me.

I have a drive which I use to install macOS 10.14 containing an HFS+ volume and a FAT32, custom EFI volume. I have an image of that installer drive which I'd like to restore onto a USB drive. I was able to accomplish a partial restore by using Disk Utility on my Mac to format and partition the USB drive. I then manually restored the HFS+ volume from the disk image, but received an error when trying to restore the FAT32 volume saying the volume couldn't be repartitioned. And that's as far as I've been able to get.

Using dd only restores the HFS+ volume and seems to ignore the FAT32 volume.

I'd like to use the command line to do a byte-for-byte restore of the image to the disk to accomplish my goal in one step, but I haven't been successful in finding such a method.

Let me know if you need more information. Thanks!

Bump. Any thoughts, Don? Thanks.

Pls show e.g. your dd commands (to and fro).

To make the image, I used:

sudo dd if=/dev/INSTALLERDRIVE of=/IMAGE_FILENAME

This seemed to work. When I mount the image on my Mac, two volumes appear correctly.
Then to attempt to restore the image to a USB flash drive, I used:

sudo dd if=/image_filename of=/dev/USBFLASHDRIVE

This only restores the first volume and ignores the second.
Any thoughts?

If the right amount of data is being written, the data should be there.

Presumably, you had two slices on the hard drive that contained the two file systems that you copied (with dd ) from the device that covers the entire disk containing both of those slices. What were the actual device names of the two slices on the hard drive and what actual device name did you use for /dev/INSTALLERDRIVE ?

How did you format the USB flash drive to create compatible slices on the flash drive matching the hard drive slices? What actual device name did you use for /dev/USBFLASHDRIVE when you used dd to load the flash drive?

After the copy, exactly what mount commands did you use to mount the two filesystems that you tried to load onto the flash drive?

You are correct. The device names were install_osx and EFI , and the device I believe was /dev/disk1

I didn't format the USB drive because I was hoping to not have to prep a drive before restoring it. Is this possible? I know I can restore the two volumes with two separate commands but would rather just have it completely clone the drive in one fell swoop.

I didn't use command line to mount the image. I used the built-in Disk Utility mounting feature in Mac OS by double-clicking the image. After double-clicking, the two volumes are present and mount correctly.

OK. So if after double-clicking both volumes are present and mount correctly, what did you mean by:

???

After creating the image from the original disk using the dd command, double-clicking the image mounts both volumes. But only when I try to restore the image to a fresh USB drive using dd does it not restore both volumes. The only volume that's restored is install_osx

Am I misunderstanding something?

If the dd from the hard drive successfully copied both slices to the destination file and you then successfully copied that file to your flash drive, one might guess that the partition table on your flash drive was expecting the partition where your second filesystem was mounted to be at a different place on the flash drive than where dd placed it.

That is why I asked how you partitioned your flash drive. If at least the first partitions on the partitions on both the source and destination drives are not the same size, the position of the 2nd partition on the flash drive will not be located where mount will see it as the root of that filesystem.

On the other hand, if you copy the filesystems separately, each filesystem will be copied onto the flash drive at the locations that fit the partition table for that flash drive and everything is likely to work (just as you are seeing in your experiments).

Thank you for your reply. Apologies for taking so long to get back to you.

I don't remember exactly what my commands to create the image were. However, when I mount the image with my Mac it shows up as two different volumes which is how the original disk was formatted.

Here is the code I use to write the image to my uninitialized flash drive.

sudo dd if=/Volumes/Drobo/Installers/macOS\ installs/installmojave.dmg of=/dev/disk5

The result from dd :

11813828+1 records in
11813828+1 records out
6048680362 bytes transferred in 4055.983771 secs (1491298 bytes/sec)

Though running this dd command takes over an hour, the disk still ends up uninitialized. When I give it a formatted disk, it only writes the first volume in the disk image and not the second.

Any thoughts?

Where exactly does your if=/dev/INSTALLERDRIVE in post #8 point to?

Setting dd 's blocksize to, say, 1MB or two in lieu of the default 512 byte would drastically reduce the transfer time.

It's an uninitialized USB flash drive.

Okay I'll give that a try.