- Apple computer
- USB drive with ≥ 8GB capacity
- Copy of macOS installer from the App Store
Copy/paste this into Terminal
bash <(curl -Ls url.efmeeks.net/osx-usb-bash)
| #!/bin/bash | |
| # Create macOS USB Installer | |
| # url.efmeeks.net/osx-usb | |
| clear | |
| cat << eof | |
| ╭──────────────────────────────────────╮ | |
| │ To quit, press CTRL+C at any time. │ | |
| ╰──────────────────────────────────────╯ | |
| eof | |
| pass() { | |
| echo "$1 = ok" | |
| } | |
| fail() { | |
| echo "$1 = fail" | |
| fail=1 | |
| } | |
| getinstaller() { | |
| installer='' | |
| while [ -z "$installer" ]; do | |
| echo "Drag and drop the macOS installer here, then press ENTER" | |
| sleep 1 | |
| open /Applications | |
| read installer | |
| done | |
| } | |
| getvolume() { | |
| volume='' | |
| while [ -z "$volume" ]; do | |
| echo "Drag and drop your USB volume here, then press ENTER" | |
| sleep 1 | |
| open /Volumes | |
| read volume | |
| done | |
| } | |
| validate() { | |
| [ -d "$installer" ] && pass path || fail path | |
| [ -x "$installer/Contents/Resources/createinstallmedia" ] && pass createinstallmedia || fail createinstallmedia | |
| } | |
| makeusb() { | |
| cat << eof | |
| ╭─────────────────────────────────────────╮ | |
| │ Writing the bootable image to USB │ | |
| │ will take a considerable amount of time │ | |
| │ (especially USB 2.0) │ | |
| ╰─────────────────────────────────────────╯ | |
| eof | |
| cim="$(find "$installer" -type f -name "createinstallmedia")" | |
| echo "Note: when prompted for your password, the prompt will remain blank as you type. This is normal." | |
| sudo "$cim" --volume "$volume" --applicationpath "$installer" | |
| echo "Done" | |
| echo "Ejecting disk" | |
| sudo diskutil ejectdisk "$volume" | |
| } | |
| # let's do it... | |
| getinstaller | |
| validate | |
| [[ $fail == 1 ]] && exit | |
| getvolume | |
| makeusb | |
| cat << eof | |
| ╭──────────────────────────────────────────╮ | |
| │ Now you can plug the USB drive into the │ | |
| │ target machine, reboot, and hold ⌘R │ | |
| │ then select the Installer as boot source │ | |
| ╰──────────────────────────────────────────╯ | |
| eof |