40

Does anyone have a Terminal command-line recipe for making a new bootable USB flash drive for one of the new MacBook Air's? Is there a way to dd copy the USB boot device that comes in the box and make the new copy bootable? I'd like to make a new backup copy of the USB rescue device for my MBA, preferably on a much larger flash drive with room for a backup of some of my working directories.

Added:

And is it possible to make, not just a rescue drive, but a bootable USB drive that will boot a fully updated version of the OS (say 10.6.8 or later)? If so how on a MacBook Air 11, and how big a USB stick will this require?

5
  • Which Air do you have? The larger one has an SD card slot, which can also be used as a boot drive.
    – Dori
    Jan 29, 2011 at 10:18
  • 1
    @Dori : MBA 11, smaller one with no SD slot.
    – hotpaw2
    Jan 29, 2011 at 18:22
  • 1
    Are you looking to move the OSX installer to a drive or just have a second bootable device. If the latter, simply format the USB drive and install OSX onto the drive. Update the software periodically and you are done. Moving the installer to the USB takes a little more effort.
    – bmike
    Jun 27, 2011 at 0:10
  • This was related to another question, but the process remains the same. Also, note, this was for Mavericks. Just replace the OS name with the one you are currently downloading apple.stackexchange.com/a/153173/97821
    – Dewald Els
    Mar 14, 2016 at 12:36
  • I concur with bmike: you don't need the command line just to install a bootable OS on an external USB: just download the OS installer app, launch it, and select the external USB. The createinstallmedia instructions are for creating a USB stick that can install the OS onto another disk.
    – benwiggy
    Sep 29, 2020 at 8:46

5 Answers 5

31
+50

If Apple's supported method of using the createinstallmedia tool doesn't work, you can try other options below:

With OS X El Capitan, Yosemite, or Mavericks, you can use a USB flash drive or other removable media as a startup disk from which to install OS X.


Really - try the above if you can, but as an alternative, here is a simple recipe for making a USB version of the OS X installer + associated tools. (Migration Assistant, Disk Utility, Network Utility, Terminal (that auto mounts your internal drive as needed), Firmware Utility and Password Reset Utility.

1) Use Disk Utility backup/restore to image whatever Snow Leopard DVD you prefer onto a HFS+ formatted GUID USB drive. I usually first create a IMG of the DVD, but it should work in one shot. Watch for restore errors - you may need the Disk Utility menu command Images -> Scan images for restore... before restoring an IMG to the USB drive.

2) bless the USB drive by selecting it in Startup Disk or using the command line. (Note - the manual page for bless may be moved, but the command still works on Mojave to bless an alternate boot. You can’t set this to be the default boot with System Integrity Protection but for this use, bless should still work.

It's not that hard to make a bootable image and far more secure to DIY. It also avoids the need of downloading commercial software from the internet. Happy media shifting all!

If you simply want a bootable thumb drive, just install OSX onto that volume - turning off all the extras you may not need. You can have your USB on one side and the USB install disk on the other to make your bootable drive ensuring all the Air drivers are on your USB bootable drive (which is often an issue when using another install's image - sometimes the drivers are not all there on older builds of the OS)

The best trick I have when you don't have enough space on USB to create the final updated version is to stage the bootable image by install first to a 25G partition on an external hard drive.

You can finish installing with lots of free space on the HS, run all the updates newer than your installer (10.6.8 for example), make an admin account, install the tools and apps you need. At the end of the process, you then thin out the things you don't need. DaisyDisk or WhatSize will show you all the large files and libraries. You can safely get rid of a lot of iLife and the associated Application Support. WhatSize has many options to strip out unneeded files, localizations and PPC code. Once you have slimmed down the bootable image on the HD partition, use the trick below to get it on the USB drive. Leopard was a tight fit in 8G but Snow Leopard is lighter and doesn't need to diet as much.

Edit: Here are terminal commands for rolling your own installer like the (read-only) one that ships with current MacBook Air. I have a Snow Leopard DVD as /dev/disk5 and my USB is /dev/disk6. The man pages for diskutil and asr are helpful if you run into little gotchas or have different needs than a basic one partition drive.

$diskutil list
/dev/disk5
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     Apple_partition_scheme                        *7.8 GB     disk5
   1:        Apple_partition_map                         30.7 KB    disk5s1
   2:         Apple_Driver_ATAPI                         1.0 GB     disk5s2
   3:                  Apple_HFS Mac OS X Install DVD    6.7 GB     disk5s3
/dev/disk6
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                                                   *8.5 GB     disk6
$diskutil partitionDisk disk6 GPT HFS+ MacUSB 100%
Started partitioning on disk6
Unmounting disk
Creating partition map
Waiting for disks to reappear
Formatting disk6s2 as Mac OS Extended with name MacUSB
Finished partitioning on disk6
/dev/disk6
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *8.5 GB     disk6
   1:                        EFI                         209.7 MB   disk6s1
   2:                  Apple_HFS MacUSB                  8.2 GB     disk6s2
$sudo asr restore --source /dev/disk5s3 --target /dev/disk6s2 --erase
    Validating target...done
    Validating source...done
    Erase contents of /dev/disk6s2 (/Volumes/MacUSB)? [ny]: y
    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
    Remounting target volume...done
$sudo bless --mount /Volumes/Mac\ OS\ X\ Install\ DVD\ 1 --setBoot

Note: that the USB drive was renamed to be the same as the installer and the mount point in /Volumes has a space and a 1 tacked on the end.

Note: SIP ensures the —setBoot portion of the commands above will fail. Remove that portion and/or ignore any errors. You will need to select the USB another way than having bless perform a one step command. This is another reason to just use createinstallmedia from Apple to perform this.

5
  • 1
    The current MacBook Air comes with a USB restore device, not a DVD. Does this make a difference? Also, is there a recipe to create a USB drive that can boot to one's fully updated 10.6.8 (or soon 10.7.x) OS?
    – hotpaw2
    Jun 26, 2011 at 20:18
  • 1
    No - the DVD and USB are equivalent read only devices. To "bake in" updates to the installer packages, you have to be able to parse/edit installer packages and read/edit/correct the pre-install and post-install scripts. It's much faster (& safer) to just store the combo updater on the device and run that later or use DeployStudio to snap a version of the installed software for distribution. It's a great idea, just more work than you might guess in general. 10.7 all bets are off since it will use the app store to validate a purchase and wants to install over SL only as it's currently described
    – bmike
    Jun 27, 2011 at 0:27
  • Your bless link is broken.
    – Laurel
    Nov 6, 2018 at 23:56
  • Thanks @Laurel - Going to leave it until I find a better one (maybe archive.org) but I will add that SIP blocks the —setBoot portion
    – bmike
    Jan 13, 2019 at 18:36
  • On my 2017 Macbook Air running Mojave, typing man bless at the terminal console brings up bless(8).
    – BondedDust
    Sep 19, 2019 at 0:43
20

Before you're able to create a bootable OS X installer, you'll need to do the following first:

  1. Download the OS X Installer app from the Mac App Store.

  2. Mount the volume you want to convert into a bootable installer. This could be removable media such as a USB flash drive, or a secondary internal partition.

  3. You can then use the createinstallmedia tool to convert the volume from step two into a bootable installer based off the installer app from step one. To learn how to use createinstallmedia see How to create a bootable installer for macOS.

For example, assuming you have a volume mounted at /Volumes/MyVolume and the OS X installer app is at /Applications/Install\ OS\ X\ Mavericks.app you could erase /Volumes/MyVolume and convert it into a bootable installer with this command:

macOS Catalina

sudo /Applications/Install\ macOS\ Catalina.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume

macOS Mojave

sudo /Applications/Install\ macOS\ Mojave.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume

macOS High Sierra

sudo /Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume

macOS Sierra

sudo /Applications/Install\ macOS\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume --applicationpath /Applications/Install\ macOS\ Sierra.app

OS X El Capitan

sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume --applicationpath /Applications/Install\ OS\ X\ El\ Capitan.app

OS X Yosemite

sudo /Applications/Install\ OS\ X\ Yosemite.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume --applicationpath /Applications/Install\ OS\ X\ Yosemite.app

OS X Mavericks

sudo /Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume --applicationpath /Applications/Install\ OS\ X\ Mavericks.app

 

6

dd makes a byte-for-byte copy of a disk so wouldn't really fit what you're trying to do. For example, if you used dd to copy your current USB key to a new bigger USB key, the additional space on that new USB key would not be usable because dd copies the partition table, not just the data.

Why not just keep your backups on an external drive. Then you could boot off your rescue USB disk and have your data saved on another external drive.

EDIT

Here's a method of at least cloning your boot disk from discussions.apple.com which seems to have worked for several people

  1. Get an 8GB USB stick and format it for a boot disk (partition it with GUID option and (Mac OS X extended (journaled)).
  2. Insert the Apple USB stick also. There is a invisible file at the root you need to mount on the desktop called MacOSX.dmg. You can use a utility such as Onyx or use the terminal with the open command to mount it.
  3. Use carbon copy cloner to clone the mounted "Mac OS X Installer Image" to the new USB stick
  4. Unmount the "Mac OS X Installer Image"
  5. Use carbon copy cloner to then clone the Apple USB stick to the new USB stick. Select the delete exiting files. Steps 2 - 4 are necessary because if you just clone the Apple USB stick the new USB stick won't be bootable.
  6. After this finishes you will now have a bootable copy. You can then also use Disk Utility to create a disk image of the new copy.

Helpful hints:

To allow you to view hidden files, in terminal run this command: defaults write com.apple.Finder AppleShowAllFiles TRUE (hit Enter after each command)

then: killall Finder

Afterwards, to hide hidden files again, go back to Terminal :

defaults write com.apple.Finder AppleShowAllFiles FALSE

then: killall Finder

5
  • Carrying around the original rescue drive would be one more small device to lose. The copy is to be the backup of the original.
    – hotpaw2
    Jan 28, 2011 at 23:15
  • New content noted. How can all this be done from the command-line? What does the cloner do that a cp does not? Will a dd to a similar sized flash drive do the same?
    – hotpaw2
    Jan 28, 2011 at 23:37
  • @hotpaw2 - I don't know what would happen if you used cp to be honest but I'd expect dd would allow you to make an exact copy if you bought a USB key of the same size. the dd command should be dd if=/path/to/olddrive of=/path/to/newdrive bs=100M. This wouldn't allow you to store additional data on it though. Make sure you don't get if and of the wrong way round or you'll wipe your boot disk. Jan 28, 2011 at 23:43
  • Correction, I think that boot disk is read-only so you may not wipe it but it's still important to get if and of in the right order in case Feb 6, 2011 at 4:26
  • asr is a bit smarter about blessing a bootable volume and HFS than dd or cp and more likely to work with metadata, hfs compression and other nice things to have on limited storage space...
    – bmike
    Jun 27, 2011 at 15:34
0

Just restored my flash stick with windows utility as described here http://osxdaily.com/2011/07/04/format-the-macbook-air-usb-restore-key/

link for utility http://www.sendspace.com/file/xek3yk

don't try to do this through the Virtual Box, use native Win7

-3

OK, it is Very easy to do if you can get your hands on the myriad of "ISO" OS X installers that make their way onto the internet shortly after any release.. or create an image your Installer disk yourself.... and simply restore it onto a separate partition of your USB flash drive.. all in good ole' Disk Utility...

they key is... DO NOT insert the *.dmg or *.iso file into the SOURCE box. Instead, INSERT THE VOLUME from the mounted image onto the source box in Disk Utility "Restore".

The only reason to use DD is if you are doing some crazy custom ISO nonsense, trying to fit the installer onto a 4GB stick.. This is how I made a 4GB rescue drive that I still use to this day "Snow Leo 911", it rocks... but if you've got room to spare... just partition that baby up and you'll be good to go.

Here's a pretty good write up of a similar approach. Cheers!

4
  • 3
    Even if it were OK to repackage snow leopard and allow it to be downloaded by unlicensed people, I wouldn't trust someone that includes 40 paid software titles along with Snow Leopard in Snow Leo 911. It's not hard to image your legal copy of SL and bless the resulting image.
    – bmike
    Jun 26, 2011 at 19:50
  • 1
    how about voting on my answer to his question.... a short & simple solution to his initial problem.. and why the more complicated solution he had initially considered was now proabably unneccesary... until recetly such maneuvers were all-but-necessary in order to "home-bake" a minimal and portable set of troubleshooting tools - which generally (still) is something not available through strictly conventional "means"... i referenced experience with these same problems and solutions. aka reality. his question wasn't a RFP for paranoid diatribes re: preferred diagnostic tools..
    – alex gray
    Jun 26, 2011 at 20:58
  • 1
    @bmike oh i see see... you also aswered the question... after me... WITH MY ANSWER!! you're shady man.
    – alex gray
    Jun 26, 2011 at 21:02
  • 4
    Alex - If you look, I'm trying to show a recipe for making "cake" instead of downloading one that's already baked. If you feel that's shady (or by inference, me), you are welcome to that opinion. I do hope you stick around and participate since you obviously have some deep knowledge based on all of your answers here so far, and you might even be really nice in person. My skin is thick, so call me any names you want if you feel it helps you or the site. Editing away the meat of your answer wasn't something I would do, so I posted. I respect your voice even if I disagree with some of it.
    – bmike
    Jun 27, 2011 at 0:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .