The following steps can be used to create a USB installer for Sierra.
If you have not already downloaded then InstallOS.dmg
file for Sierra, then use instructions on the Apple website "How to download macOS" to download this file.
Use the Disk Utility to erase a 16 GB or larger flash drive. If the Disk Utility window has a View
pulldown menu, make sure Show All Devices
is selected. Highlight the flash drive, then click on the Erase
button. Use the setting shown in the image below.
Next, click on the Erase
button. When finished erasing, click on the Done
button.
Use the Finder application to open InstallOS.dmg
.
Enter the commands given below. A folder named Sierra
will be created in the /tmp
folder to hold temporary files.
Note: The easiest way to enter the commands is to copy from this document and paste in the Terminal window.
rm -rf /tmp/Sierra
pkgutil --expand /Volumes/Install\ macOS/InstallOS.pkg /tmp/Sierra
diskutil eject Install\ macOS
cd /tmp/Sierra
hdiutil attach InstallOS.pkg/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/esd
sudo asr restore -source /Volumes/esd/BaseSystem.dmg -target /Volumes/MyVolume -noprompt -noverify -erase
After entering the last command given above, you may get a message similar to the one given below.
asr: Couldn't personalize volume /Volumes/OS X Base System
Some versions of macOS will produce this message while other versions do not. I suspect this is an fatal message because an exit status of 1 was returned.
Inspection has determined that the part of the command that failed is unimportant.
Therefore, I was able to ignore this error. However, the error can also be avoided by applying the following steps given in the section below titled Alternative to Using the asr
Command.
To finish creating the bootable USB flash drive Sierra installer, enter the commands given below.
diskutil rename OS\ X\ Base\ System Install\ Sierra
rm /Volumes/Install\ Sierra/System/Installation/Packages
cp -rp /Volumes/esd/Packages /Volumes/Install\ Sierra/System/Installation
cp -rp /Volumes/esd/BaseSystem.chunklist /Volumes/Install\ Sierra/
cp -rp /Volumes/esd/BaseSystem.dmg /Volumes/Install\ Sierra/
hdiutil detach /Volumes/esd
sudo bless --folder /Volumes/Install\ Sierra/System/Library/CoreServices --label Install\ Sierra
cp /Volumes/Install\ Sierra/Install\ macOS\ Sierra.app/Contents/Resources/InstallAssistant.icns /Volumes/Install\ Sierra/.VolumeIcon.icns
cd "$HOME"
rm -r /tmp/Sierra
diskutil eject Install\ Sierra
Remove the flash drive. You are done.
asr
CommandThe command given below may generate a error message and/or hang depending on the version of macOS and perhaps the model Mac you are using.
sudo asr restore -source /Volumes/esd/BaseSystem.dmg -target /Volumes/MyVolume -noprompt -noverify -erase
You can avoid entering the above command by following the steps given below.
If the volume on the USB flash drive is no longer labeled MyVolume
, then use the Disk Utility to erase the flash drive. Highlight the flash drive, then click on the Erase
button. Use the setting shown in the image below.
Next, click on the Erase
button. When finished erasing, click on the Done
button.
Enter the following command to create a sparse flash drive image.
hdiutil create -type SPARSE -size 10g -layout MBRSPUD -fs HFS+J -volname MyImage -attach /tmp/Sierra/MyImage
Basically, you want to restore to volume MyImage
from the hidden file BaseSystem.dmg
. The hidden file BaseSystem.dmg
is shown in the Finder window image shown below. The drive OS X Install ESD
can be found in the hidden volume Volumes
in the root folder.
There are various ways to view hidden files. These ways depend on the version of OS X or macOS you are using. You may have to search the web for a way that works for you.
Highlight the MyImage
volume shown in the Disk Utility main window. Click on the Restore
button, then the Image
button. Select the BaseSystem.dmg
file, as shown below. Next, click on the Restore
button.
After a successful restore, you should see the image shown below. You can click on the Done
button and quit the Disk Utility.
Also, you should get the following popup.
Enter the following commands to clone to the flash drive.
Note: The
dd
command takes a long time to complete. See this answer to track the progress of thedd
command. The bytes to be transferred is approximately 10 GB.
getdsk() { local "x=$(diskutil info "$2" | grep Part\ of\ Whole)"; eval $1'="/dev/r${x##* }"'; }
getdsk DSK1 OS\ X\ Base\ System
getdsk DSK2 MyVolume
diskutil unmountdisk $DSK1
diskutil unmountdisk $DSK2
sudo dd if=$DSK1 of=$DSK2 bs=1m
diskutil eject $DSK1
diskutil unmountdisk $DSK2
diskutil mountdisk $DSK2
Note: Since the original will be immediately ejected and eventually deleted, I did not bother to use the
hfs.util
command to change the UUID of the clone.
You can now proceed with the rest of the steps.