Skip to content

Instantly share code, notes, and snippets.

@Diegus83
Last active February 9, 2024 14:16
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Diegus83/e493a30ac4d1c57e327fa181ce77294e to your computer and use it in GitHub Desktop.
Save Diegus83/e493a30ac4d1c57e327fa181ce77294e to your computer and use it in GitHub Desktop.
Makes one Bootable USB Lion installer from Apple's provided PKG (2021)
# This is not intended to be guide, I just wrote it as a reminder to myself of the steps necessary.
# If you find it useful, that's great, but keep in mind the paths and device ID's will need
# to be adjusted to your case. And you may need sudo if you are not doing this while booted from recovery like I did.
Get the InstallMacOSX.dmg from https://support.apple.com/kb/DL2077?locale=en_US
Mount the image
hdiutil mount InstallMacOSX.dmg
cd /Volumes/Install\ Mac\ OS\ X
Copy to a tmp location
mktemp -d
/var/folders/v6/s_rd76bx78j5mpjxl1b0yn5m0000gn/T/tmp.plAsi6ls
cp InstallMacOSX.pkg /var/folders/v6/s_rd76bx78j5mpjxl1b0yn5m0000gn/T/tmp.plAsi6ls/
cd /var/folders/v6/s_rd76bx78j5mpjxl1b0yn5m0000gn/T/tmp.plAsi6ls/
Change extension to xar
mv InstallMacOSX.pkg InstallMacOSX.xar
Unarchive
xar -xf InstallMacOSX.xar
Get the install media from the extracted package
mv InstallMacOSX.pkg/InstallESD.dmg .
Restore the install media to a USB drive (in this case /dev/disk4)
asr restore --source InstallESD.dmg --target /dev/disk4 --erase
@reinisb
Copy link

reinisb commented Nov 27, 2021

mv InstallMacOSX.dmg InstallMacOSX.xar

This should be: mv InstallMacOSX.pkg InstallMacOSX.xar

asr restore --source InstallESD.dmg --target /dev/disk4 --erase

I needed to run this as sudo. Also, if it fails with error "Could not restore - Resource busy" then make sure that you have selected the correct target - in my case it was /dev/disk4s2

@Diegus83
Copy link
Author

Thanks for catching that typo with the extension. I didn't wrote this as a guide, it's just a reminder to myself because it took me some time to figure out the steps.

I did this from the recovery partition so sudo wasn't necessary, and the device id will of course be different in each case. In your case seems like you where using a partition and not a whole drive (hence the s2). I was using a USB thumb drive so using the whole device worked fine.

@yukonriver
Copy link

I am getting a checksum error when I try to restore. I am not sure what the problem might be. Is there another step that I need to execute?

sudo /usr/sbin/asr restore --source InstallESD.dmg --target /dev/disk2s2 --erase

Restoring  ....10....20....30....40....50....60....70....80....90....100
Verifying  ....10....20....30....40....50....60....70....80....90....100

Checksum failed.
Expected 7425D663
but got 84E748B9
Could not restore - error -206

@yukonriver
Copy link

problem resolved. used internet restore method.

@fanweixiao
Copy link

@Diegus83 I encountered Could not find any scan information. The source image needs to be imagescanned before it can be restored. problem while run command on macOS ventura. After some research, I found I can add -noverify parameter to asr for skipping this error.

asr restore --source InstallESD.dmg --target /dev/disk4 --erase -noverify

@zhukovgreen
Copy link

zhukovgreen commented Feb 8, 2024

@Diegus83 I encountered Could not find any scan information. The source image needs to be imagescanned before it can be restored. problem while run command on macOS ventura. After some research, I found I can add -noverify parameter to asr for skipping this error.

asr restore --source InstallESD.dmg --target /dev/disk4 --erase -noverify

This helped. Just added sudo:

❯ sudo asr restore --source InstallESD.dmg --target /dev/disk4s1 --erase --noverify

@fanweixiao
Copy link

Thanks @zhukovgreen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment