Skip to content

Instantly share code, notes, and snippets.

@pjobson
Last active May 2, 2024 10:35
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjobson/33e131b448b91911d2c805d44080215c to your computer and use it in GitHub Desktop.
Save pjobson/33e131b448b91911d2c805d44080215c to your computer and use it in GitHub Desktop.
How to Create a Bootable OS X USB Stick Pre-Yosemite

Pre-Yosemite USB Stick Creation

Yosemite and later used a built in program called createinstallmedia to automagically make a USB stick. It is possible to create a bootable USB stick without this program.

You'll need an 8GB USB stick and either the Install Mac OS X Lion.app or InstallESD.dmg or BaseInstall.dmg.

Open Terminal, you'll need it in most of this tutorial.

We're going to need to start by getting to the actual installation disk image.

Step 1a - Install Mac OS X Lion.app

Mine is in Applications, but you can put it anywhere for this.

In Terminal:

cd "/Applications/Install Mac OS X Lion.app"
find . -name "*.dmg"

Should output something like: ./Contents/SharedSupport/InstallESD.dmg

In Terminal:

open ./Contents/SharedSupport/InstallESD.dmg

Step 1b - BaseInstall.dmg

Open your BaseInstall.dmg file.

In Terminal:

ls -la /Volumes

From here you should see something like OS X Install ESD or something like that, cd into that path.

cd "/Volumes/OS X Install ESD"
find . -name "*.dmg"

It should show something like: ./BaseSystem.dmg

In Terminal:

open ./BaseSystem.dmg

Step 1c - InstallESD.dmg

If you just have an InstallESD.dmg or BaseSystem.dmg file, you should just open them.

open ./InstallESD.dmg
# or
open ./BaseSystem.dmg

Look in Volumes you should see something like OS X Base System, remember whatever it shows.

ls -la /Volumes

Step 2 - Find Your Install Disk

diskutil list virtual | grep "OS X Base System"

Should display something like:

   2:                  Apple_HFS OS X Base System        1.3 GB     disk3s2

Take note of the disk, for example mine is /dev/disk3s2.

Step 3 - Preparing Your USB Stick

Insert your USB Stick.

In Terminal:

diskutil list external

Should display something like something else may appear depending on your stick.

/dev/disk4 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *16.0 GB    disk4
   1:                        EFI EFI                     209.7 MB   disk4s1
   2:                  Apple_HFS Untitled                15.7 GB    disk4s2

Take note of the disk, in my case /dev/disk4.

Partition it.

diskutil partitionDisk disk4 GPT HFS+ USBSTICK 100%

Should output something like this:

Started partitioning on disk4
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk4s2 as Mac OS Extended with name USBSTICK
Initialized /dev/rdisk4s2 as a 15 GB case-insensitive HFS Plus volume
Mounting disk
Finished partitioning on disk4
/dev/disk4 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *16.0 GB    disk4
   1:                        EFI EFI                     209.7 MB   disk4s1
   2:                  Apple_HFS USBSTICK                15.7 GB    disk4s2

Here you want to take note of the Initialized line, specifically your disk, mine is /dev/rdisk4s2.

Step 4 - Restore from the DMG File

WARNING IF YOU PUT THE WRONG DISKS IN HERE YOU CAN WIPE YOUR MACHINE

The source should be the disk from Step 2, the target should be the disk from Step 3

sudo asr restore --source /dev/disk3s2 --target /dev/rdisk4s2 --erase --noprompt

This should prompt you for your login password and display:

Password:
  Validating target...done
  Validating source...done
  Validating sizes...done
  Restoring  ....10....20....30....40....50....60....70....80....90....100
  Verifying  ....10....20....30....40....50....60....70....80....90....100
  Restored target device is /dev/disk4s2.
  Remounting target volume...done

Step 5 - Make Bootable

In Volumes now you should have your USB stick and original installer and possibly other mounts.

I do a force unmount here, this will not unmount your system disk(s).

diskutil unmount force *

Remove and re-insert your USB Stick now.

ls /Volumes

Should show OS X Base System or OS X Install ESD.

sudo bless --verbose --mount "/Volumes/OS X Base System" --setBoot

Should output something like:

EFI found at IODeviceTree:/efi
Mount point for /Volumes/OS X Base System is /Volumes/OS X Base System
Mount point is '/Volumes/OS X Base System'
No BootX creation requested
No boot.efi creation requested
found ioreg "FirmwareFeaturesMask"; featureMaskValue=0xFF1FFF7F
found ioreg "FirmwareFeatures"; featureFlagsValue=0xFD0FF57E
isPreBootEnvironmentUEFIWindowsBootCapable=1
given BSD is not a DVD disc medium
isDVDWithElToritoWithUEFIBootableOS=0
Checking if disk is complex (if it is associated with booter partitions)
GPT detected
No auxiliary booter partition required
System partition found
Preferred system partition found: disk0s1
Returning booter information dictionary:
<CFBasicHash 0x7f972fc00bf0 [0x7fff961488e0]>{type = mutable dict, count = 3,
entries =>
  0 : <CFString 0x10f593be0 [0x7fff961488e0]>{contents = "System Partitions"} = (
    disk0s1,
    disk2s1
)
  1 : <CFString 0x10f5943c0 [0x7fff961488e0]>{contents = "Data Partitions"} = (
    disk2s2
)
  2 : <CFString 0x10f5943e0 [0x7fff961488e0]>{contents = "Auxiliary Partitions"} = (
)
}

Path to mountpoint given: /Volumes/OS X Base System
IOMedia disk2s2 has UUID BF39EB72-D849-4437-B537-7267585E90FF
Setting EFI NVRAM:
  efi-boot-device='<array><dict><key>IOMatch</key><dict><key>IOProviderClass</key><string>IOMedia</string><key>IOPropertyMatch</key><dict><key>UUID</key><string>BF39EB72-D849-4437-B537-7267585E90FF</string></dict></dict><key>BLLastBSDName</key><string>disk2s2</string></dict></array>'
Setting EFI NVRAM:
  IONVRAM-DELETE-PROPERTY='efi-boot-file'
Setting EFI NVRAM:
  IONVRAM-DELETE-PROPERTY='efi-boot-mkext'
Setting EFI NVRAM:
  IONVRAM-DELETE-PROPERTY='efi-boot-kernelcache'
Old boot-args:
  Got token:
  Preserving:
New boot-args unchanged, skipping update.

You should be able to Eject your stick and boot from it now.

@acarlstein
Copy link

Regrettably, this solution only works if you can find the .app in the apple store.
Currently, version such as Yosemite, can only being downloaded as a .dmg which contains a .pkg file inside.

@Buggem
Copy link

Buggem commented Jan 29, 2024

Regrettably, this solution only works if you can find the .app in the apple store. Currently, version such as Yosemite, can only being downloaded as a .dmg which contains a .pkg file inside.

@acarlstein
It actually works just fine.
Here is the path to InstallESD.dmg (I downloaded the dmg from Apple's support website)

Lion.dmg > InstallMacOSX.pkg (right click show package contents or if not an option change filename to .xar and double click) > InstallMacOSX.pkg (right click show package contents this time, no need for .xar) > InstallESD.dmg.

Double click InstallESD.dmg, a disk should appear on your desktop and inside you should find the .app installer with BaseInstall.dmg

@hillpath
Copy link

I've done everything the same, but I'm getting the following error on the last command. What should I do?

sudo bless --verbose --mount "/Volumes/Mac OS X Base System" --setBoot
Password:
Mount point for /Volumes/Mac OS X Base System is /Volumes/Mac OS X Base System
Mount point is '/Volumes/Mac OS X Base System'
This is not an APFS Data-Volume-Parameter-Driven Pre-SSV to SSV case
found ioreg "FirmwareFeaturesMask"; featureMaskValue=0xFFFFFFFF
found ioreg "FirmwareFeatures"; featureFlagsValue=0xFFB3F066
isPreBootEnvironmentUEFIWindowsBootCapable=1
given BSD is not a DVD disc medium
isDVDWithElToritoWithUEFIBootableOS=0
Checking if disk is complex (if it is associated with booter partitions)
GPT detected
No auxiliary booter partition required
System partition found
Preferred system partition found: disk0s1
Returning booter information dictionary:
{
"Auxiliary Partitions" = (
);
"Data Partitions" = (
disk4s2
);
"System Partitions" = (
disk0s1,
disk4s1
);
}
Path to mountpoint given: /Volumes/Mac OS X Base System
IOMedia disk4s2 has UUID F0D9B1CA-F9CA-418B-B0D5-5A930B4F4B32
Setting EFI NVRAM:
efi-boot-device='IOMatchIOProviderClassIOMediaIOPropertyMatchUUIDF0D9B1CA-F9CA-418B-B0D5-5A930B4F4B32BLLastBSDNamedisk4s2'
Could not set boot device property: 0xe00002e2

@pjobson
Copy link
Author

pjobson commented Apr 29, 2024

I can't really offer any additional help on this, I wrote it in 2019 and have since moved to Linux. Sorry.

@Buggem
Copy link

Buggem commented May 2, 2024

Don't use bless

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