Today I needed to securely wipe an old laptop in preparation for computer recycling. The Mac Book Pro was running 10.6, so it had no built-in recovery partition. I did have another Mac running 10.11 and a spare SD Card laying around. So I decided to build a bootable recovery SD Card. It takes just a few minutes to do.


First, get a sense of what you’re working with by using diskutil list. Below, disk0 and disk1 are the CoreStorage volumes that make up the logical volume disk2. Finally, disk3 is the target SD Card, which has a FAT partition scheme, since it’s used in my camera. The things to note here are the identifiers for “Recovery HD” and the target device.

% diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *121.3 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage Macintosh HD            121.0 GB   disk0s2
   3:                 Apple_Boot Boot OS X               134.2 MB   disk0s3
/dev/disk1 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk1
   1:                        EFI EFI                     209.7 MB   disk1s1
   2:          Apple_CoreStorage Macintosh HD            999.3 GB   disk1s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk1s3
/dev/disk2 (internal, virtual):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS iMac                   +1.1 TB     disk2
                                 Logical Volume on disk0s2, disk1s2
                                 Unlocked Encrypted Fusion Drive
/dev/disk3 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *32.0 GB    disk3
   1:             Windows_FAT_32                         32.0 GB    disk3s1

The first real step is to unmount the target volume and format it as HFS+, so that it can be used as a Mac drive.

% diskutil unmount /dev/disk3
% diskutil erasedisk jhfs+ Make_Recovery disk3
Started erase on disk3
Unmounting disk
Creating the partition map
Waiting for the disks to reappear
Formatting disk3s2 as Mac OS Extended (Journaled) with name Make_Recovery
Initialized /dev/rdisk3s2 as a 30 GB case-insensitive HFS Plus volume with a 8192k journal
Mounting disk
Finished erase on disk3

The format operation mounted the newly minted disk, so unmount it.

% diskutil unmountdisk /dev/disk3

Now it’s time to locate the bootable recovery material that will be the source for the SD Card image. This is located on the hidden “Recovery HD” partition of your Mac. Mount it, using the identifier located above.

% diskutil mount /dev/disk1s3
Volume Recovery HD on /dev/disk1s3 mounted

% ls -l /Volumes/Recovery\ HD/
total 991328
-rw-r--r--@ 1 root  admin       1984 Sep 17 04:17 BaseSystem.chunklist
-rw-r--r--@ 1 root  wheel  485094905 Sep 17 02:49 BaseSystem.dmg
-rw-r--r--  1 root  wheel       3213 Aug 25 19:07 PlatformSupport.plist
-r--r--r--  1 root  wheel        477 Sep 17 01:39 SystemVersion.plist
-rw-r--r--  1 root  wheel     604728 Oct  3 16:37 boot.efi
-rw-r--r--  1 root  wheel        365 Oct  3 16:37
-rw-r--r--  1 root  wheel   21837607 Sep 17 01:37 prelinkedkernel

The BaseSystem.dmg is the recovery image. Use the asr(8) command to copy it to the SD Card, erasing its contents.

% sudo asr restore --source /Volumes/Recovery\ HD/ --target /dev/disk3s2 --erase
        Validating target...done
        Validating source...done
        Erase contents of /dev/disk3s2 ()? [ny]: y
        Repartitioning target device...done
        Retrieving scan information...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

Next, make it bootable by using asr to change the volume type.

% sudo asr adjust --target /dev/disk3s2 --settype Apple_Boot
Fsck /dev/disk3s2 ....10....20....30....40....50....60....70....80....90....100
Adjust completed successfully

Finally, unount the Recovery HD.

% diskutil unmount /dev/disk1s3
Volume Recovery HD on disk1s3 unmounted

You now have a bootable recovery drive. You can hold down Option during a reboot to select it as the boot volume on a Mac.