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?

有帮助吗?

解决方案

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.

其他提示

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

 

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

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

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!

许可以下: CC-BY-SA归因
不隶属于 apple.stackexchange
scroll top