I wasn't sure about posting this thread here, or on the apple community. However, as I am using a PC running Ubuntu, I am posting this here.
My macbook pro (mid-2015) is out of service. I need to reinstall OS X on it. Note that I can't access the recovery partition; it has been wiped out too.
I have the InstallESD.dmg file, that I found online; I checked the hash value.
I would like to know how to make a bootable USB device with that file. Note that I have a USB key with a MBR partition. I am not sure, but it should be using GUID to be recognized by my macbook pro?
What I tried:
Convert the
.dmgfile to a.isofile, usingdmg2img:$ dmg2img -v -i Downloads/InstallESD.dmg -o Downloads/ElCapitan.isoCopy the
ElCapitan.isofile on my USB key:$ dd if=Downloads/ElCapitan.iso of=/dev/sdb bs=16M && syncPlug the USB key and boot.
Result: nothing happens, the USB key doesn't appear.
34 Answers
There's a ready script that automates this whole process. Manually it's as mentioned in MacWorld, but using the Linux tools:
InstallESD.dmg is an image of a GPT disk with HFS+ partition which contains installer files, but is not bootable itself.
Working as a root, convert InstallESD.dmg into raw image format and mount it using kpartx:
dmg2img InstallESD.dmg InstallESD.img
kpartx -a InstallESD.img
mount /dev/mapper/loop0p2 /mnt/installesdInstallESD.dmg contains another disk image, BaseSystem.dmg, which is a bootable installer disk. But writing it directly to the USB drive does not work, because that would create a partition with almost no free space and still lacking some important files.
Extract base system image BaseSystem.dmg, convert into raw and mount too:
dmg2img /mnt/installesd/BaseSystem.dmg BaseSystem.img
kpartx -a BaseSystem.img
mount /dev/mapper/loop1p1 /mnt/basesystemFormat the USB flash drive as HFS+:
sgdisk -o /dev/sdb
sgdisk -n 1:0:0 -t 1:AF00 -c 1:"disk image" -A 1:set:2 /dev/sdb
mkfs.hfsplus -v "OS X Base System" /dev/sdb1
mount /dev/sdb1 /mnt/usbstickCopy missing installer files (beware of ending /):
rsync -aAEHW --info=progress2 /mnt/basesystem/ /mnt/usbstick/
rm -f /mnt/usbstick/System/Installation/Packages
rsync -aAEHW -P /mnt/installesd/Packages /mnt/usbstick/System/Installation/
rsync -aAEHW -P /mnt/installesd/BaseSystem.dmg /mnt/usbstick/
rsync -aAEHW -P /mnt/installesd/BaseSystem.chunklist /mnt/usbstick/
syncIt is possible to copy with other tools (tar, cpio), just supply parameters preserving the most of file metadata. rsync supports also -X parameter, supposed to copy HFS+ extended attributes, but in practice it fails with the error "Operation not supported".
If you can't start up from OS X Recovery (Option-R), try holding down (Option-Command-R) to start up from OS X Internet Recovery.
Your mac(mid-2015) should initiate recovery over the Internet.
Read more at
This works! I used it for making a usb from El Capitan installer, using the InstallESD.dmg that you find inside the InsallMacOSX.dmg. There is no need to try using the script, as it works with the list of commands on the read me file. so This:
mkdir -p /mnt/OSX_InstallESD /mnt/OSX_BaseSystem /mnt/usbstick # convert installer disk image to raw format dmg2img "Install OS X .app/Contents/SharedSupport/InstallESD.dmg" InstallESD.img kpartx -a InstallESD.img mount /dev/mapper/loop0p2 /mnt/OSX_InstallESD # convert base system disk image to raw format dmg2img /mnt/OSX_InstallESD/BaseSystem.dmg BaseSystem.img kpartx -a BaseSystem.img mount /dev/mapper/loop1p1 /mnt/OSX_BaseSystem # partition the USB flash drive, /dev/sdX sgdisk -o /dev/sdX sgdisk -n 1:0:0 -t 1:AF00 -c 1:"disk image" -A 1:set:2 /dev/sdX mkfs.hfsplus -v "OS X Base System" /dev/sdX1 mount /dev/sdX1 /mnt/usbstick # copy installer files rsync -aAEHW /mnt/OSX_BaseSystem/ /mnt/usbstick/ rm -f /mnt/usbstick/System/Installation/Packages rsync -aAEHW /mnt/OSX_InstallESD/Packages /mnt/usbstick/System/Installation/ rsync -aAEHW /mnt/OSX_InstallESD/BaseSystem.chunklist /mnt/usbstick/ rsync -aAEHW /mnt/OSX_InstallESD/BaseSystem.dmg /mnt/usbstick/ sync
Only things that need to take into account are: Run all the commands it as root! so use "sudo su" kpartx you need to add -v (verbose) to see which loop is created so :kpartx -av InstallESD.img on my machines there was already 12 loops every now and then use "df" just to see which partitions and names you have in your system. The only need you need to change on the lines are. The "loop0p2" and the loop1p1 and the dev/sdX according to your usb mount.
At some point you need to umount the usbdrive if "mount point busy" message.
under i just paste my terminal history that gave me a working usb drive. thanks all of the above for pointing into the right direction! starts with "sudo su" i already extracted from the installer the file InstallESD and is sitting in the working directory
38 dmg2img InstallESD.dmg InstallESD.img 39 kpartx -av InstallESD.img 40 mount /dev/mapper/loop14p2 /mnt/OSX_InstallESD 41 dmg2img /mnt/OSX_InstallESD/BaseSystem.dmg BaseSystem.img 42 kpartx -av BaseSystem.img 43 mount /dev/mapper/loop15p1 /mnt/OSX_BaseSystem 44 df 45 history 46 sgdisk -o /dev/sdb 47 sgdisk -og /dev/sdb 48 man partprobe #got a message that the partition was not going to be visible untill I use partprobe or reboot 49 partprobe -s 50 sgdisk -n 1:0:0 -t 1:AF00 -c 1:"disk image" -A 1:set:2 /dev/sdb 51 partprobe -s 52 man kpartx 53 kpartx -u 54 kpartx -ul 55 mkfs.hfsplus -v "OS X Base System" /dev/sdb1 56 mount /dev/sdb1 /mnt/usbstick 57 df 58 umount /dev/sdb 59 mount /dev/sdb1 /mnt/usbstick 60 rsync -aAEHW /mnt/OSX_BaseSystem/ /mnt/usbstick/ 61 rm -f /mnt/usbstick/System/Installation/Packages 62 rsync -aAEHW /mnt/OSX_InstallESD/Packages /mnt/usbstick/System/Installation/ 63 rsync -aAEHW /mnt/OSX_InstallESD/BaseSystem.chunklist /mnt/usbstick/ 64 rsync -aAEHW /mnt/OSX_InstallESD/BaseSystem.dmg /mnt/usbstick/ 65 sync1
After hours of trial and error, I was finally able to install OSX 10.11 "El Capitan" on my used iMac (mid 2009)! I tried to use the internet installer that came with it, but it would not work without signing into the original owner's AppleID (even though I specifically went into iTunes to "De-Authorize this computer" before wiping the original installation)
Instead, I downloaded the "El Capitan" installer .dmg file from Apple's support page:
However, this contains a file called "InstallMacOSX.dmg", rather than "InstallESD.dmg". So, I needed to first convert this file into an image: dmg2img InstallMacOSX.dmg InstallMacOSX.img Then mount the image: In Linux Mint, I used right-click --> "Open With Other Application..." --> "Disk Image Mounter" (but there are plenty of other ways to do this) Inside, there was a large file called "InstallMacOSX.pkg", which I could extract using p7zip, or (in Linux Mint): right-click --> "Open With Other Application" --> Archive Manager" Inside THERE could be found the InstallESD.dmg!
However, the sha1 hash did match any of the values at: 6198647687 bytes, openssl sha1 InstallESD.dmg --> 732f873cbcf38d9e544e659d2429bd4444416cda I am pretty sure the file is legit (since I downloaded it directly from Apple Support), so I edited the "mkosxinstallusb.sh" script and added it to the approved list --> see the line starting with "supported_checksums="...", and just added it to the end before the last closing quote) Also, make sure your USB thumb drive is completely empty before you start the script. In my case, I actually plugged it into the mac and formatted it with Disk Utility to "OS X Extended (Journaled)" (GUID Partition table) before I started. (I had tried it once before with a partially occupied USB drive, and it ran out of space before it could finish). I am not sure how much difference it made to format it with Disk Utility, but that is what worked for me! I then ran "sudo bash mkosxinstallusb.sh /dev/sdX "InstallESD.dmg", and the script took care of the rest. Finally, I could boot up the Mac while holding "option/alt" and my USB drive appeared as a bootable device! 17 minutes later I can startup OSX!
I may go ahead and re-download the installer and create a new bootable USB using "createinstallmedia", just in case there was a problem with the image I used, but at least now I can boot up the computer!