47

I have 2 machines - a MacBook Pro and a desktop running Fedora, I have a USB drive and a OSX 10.8 dmg. The MacBook won't boot into OSX unfortunately, I'm trying to make a bootable mac usb to recover it.

Any insight? I've tried dmg2img but no success putting that image onto the usb drive.

Is there an easy way to do this?

Zen Savona
  • 573
  • 1
  • 4
  • 6

5 Answers5

64

Install dmg2img

sudo apt-get install dmg2img

Convert DMG image file to ISO file

dmg2img -v -i /path/to/image_file.dmg -o /path/to/image_file.iso

Copy ISO image to USB

sudo dd if=/path/to/image_file.iso of=/dev/sdb && sync

sdb is an example. In your case it might be different

Edit

You can do the conversion and actual writing in one pass, if you don't need the .iso afterwards: it will take half the time as converting to .iso and THEN writing to the USB device. Just do:

sudo dmg2img -v -i /path/to/image_file.dmg -o /dev/sdb

Again, sdb is an example. In your case it might be different.

bwDraco
  • 45,747
  • 43
  • 165
  • 205
lindows2008
  • 641
  • 1
  • 5
  • 2
  • How USB should be formatted? Partitionmap GUID/MBR? Formatting FAT/NTFS/HFS+? – IFightCode Apr 21 '16 at 13:20
  • 4
    @Enthusiast these instructions are writing a raw disk image to the device. Its formatting and data before the operation will be overwritten and therefore don't matter. – Sam Hanes Jun 29 '16 at 19:06
  • 5
    This does not create an ISO image, it is an HFS+ image like all the other tutorials that use this program. I still have not found a workable solution. – bparker Aug 10 '16 at 19:48
  • +1 for the direct burning to usb method – Anwar Sep 05 '19 at 17:01
  • I use this method to extract a disk image of a hfs+ partition from a file called BaseSystem.dmg which is part of a recovery image for macOS. I can then mount that .iso file using `sudo mount -t hfsplus -o loop BaseSystem.iso /mnt/macimage/` However if I then write that .iso file to a usb drive using dd as you describe above then that hfs+ partition in that usb drive will NOT mount. Instead I get error: `Wrong fs type, bad option, bad superblock on /dev/sdc2, missing codepage or helper program or other error` Why will it not mount when on the USB drive? Does `dd` mess up hfs+ disk images? – FlexMcMurphy May 25 '21 at 20:27
24

Have you tried "Acetoneiso"?

It'll convert the DMG to an ISO for you. After that, the easiest way I know of to make a bootable USB is using DD.

dd if=/path/to/osx.iso of=/dev/sdX && sync

Note: sdX is an example, you will have to check your flash drive address (usually sdb if you have only one hard disk). Do not add a partition # after that (such as sdb1). This method is a little hard on flash drives (I have killed one or two doing this relatively frequently, but once should be fine).

If you are unfamiliar, DD is a bit by bit copy and sync just verifies that all files have been written to the usb.

Nighto
  • 101
  • 2
nerdwaller
  • 17,054
  • 2
  • 44
  • 44
  • 4
    why you cannot directly do DD from the .dmg to the USB ? – Francesco Jan 06 '14 at 20:11
  • @Francesco - Do some research on the format differences between a `dmg` (non-standard) and `iso` (standard) – nerdwaller Jan 06 '14 at 20:19
  • 3
    Accordign to this guide: http://www.macbreaker.com/2014/01/install-osx-mavericks-on-pc-with-niresh.html this should work on Mac Osx: `sudo dd if="location of Niresh disk image" of=/dev/r"identifier" bs=1m` So why should not on linux ? – Francesco Jan 07 '14 at 09:22
  • 2
    @Francesco - Never said it doesn't. Please ask your own questions rather than piggy backing off other's and providing unrelated/chatty comments. You can also see if anyone is available in [chat](http://chat.stackexchange.com/). – nerdwaller Jan 07 '14 at 14:26
  • 5
    I just want to add detail to the answer ... why you should to convert the image if it is not required ? – Francesco Jan 07 '14 at 17:24
  • 2
    @Francesco - Again, look at the differences between `dmg` and `iso`. `iso` is a standard, `dmg` is often contains compressed items, where `iso`s do not. To avoid the few rare cases in which a `dmg` behaves as an `iso`, it's best to just convert it to a known valid format. If you write the common `dmgs` (that contain compression) to a USB, many things do not handle them correctly. So you aren't adding details, you're asking questions without researching it beyond a single case in which your point is true while ignoring the numerous cases in which it is false. – nerdwaller Jan 07 '14 at 17:39
  • You can as well just use `hdiutil convert EXAMPLE.dmg -format RdWr -o EXAMPLE.img`, according to this [answer](http://apple.stackexchange.com/a/176626). – kaiser Jan 12 '16 at 02:48
  • How USB should be formatted? Partitionmap GUID/MBR? Formatting FAT/NTFS/HFS+? – IFightCode Apr 21 '16 at 13:20
1

Try booting from Internet Recovery (Command + Alt + Shift + R) and opening the installer app from Terminal.

Open Terminal in recovery and:

cd /Volumes/NAME-OF-YOUR-USB-STICK/
cd The-Name-Of-Your-Installer.app/Contents/MacOS
./InstallAssistant

The installer should load.

1

If you can find another Mac, try the Disk Utility App.

You can "Restore" your 10.8 DMG to your USB drive. This will make your USB drive be bootable.

ChrisF
  • 41,278
  • 17
  • 101
  • 154
travis
  • 19
  • 1
0

usually, you just write the dmg image to the usb drive

on linux:

fdisk -l # find the USB drive, for example: sdb
dd if=image.dmg of=/dev/sdb bs=16M status=progress

on macos:

diskutil list # find the USB drive, for example: disk2
dd if=image.dmg of=/dev/disk2 bs=$((16 * 1024 * 1024))
milahu
  • 150
  • 9