0

I recently installed a new SSD on my old MacBook Pro - replacing the HDD. It's running El Capitan. After installing the new drive, I booted from my SuperDuper clone, formatted the new internal SSD to be Mac OS X Journaled, and restored the files from the backup to the new SSD using SuperDuper.

However - I just realized that the new SSD does not have a recovery partition. Is there a way to create a recovery partition without doing a full OS X El Capitan reinstall?

  • BTW I know that there have been some questions about this in the past (e.g. apple.stackexchange.com/questions/19145/…) but they seem to be for older versions of OS X. – Jason Jul 19 '16 at 6:28
  • I just used the Disk Utility to clone a bootable El Capitan partition. The Disk Utility also automatically cloned the Recovery Partition. I cloned to the same drive, but I assume this would work if using different drives. Also, I was not using Core Storage. – David Anderson Jul 19 '16 at 9:01
  • @David I just checked using 'diskutil list', and the recovery partition was not automatically created... – Jason Jul 19 '16 at 14:32
  • Actually, diskutil list will give you false output. You will need to restart the computer before running the command. Just to let you know, I did test using the Disk Utility application to copy (clone) a HFS+ formatted partition (48465300-0000-11AA-AA11-00306543ECAC) to a new drive. The following Recovery Partition (426F6F74-0000-11AA-AA11-00306543ECAC) is also copied automatically. – David Anderson Jul 20 '16 at 15:41
1

If you still have the Recovery partition, you can transfer the partition manually.

The example given below was generated using two sparse disk images and Yosemite (OS X 10.10.5). You may have to jump though hoops that I did not have to. Some of these hoops are:

  • El Capitan and later users may need to disable System Integrity Protection (SIP).
  • To enter some of the commands, you may need to boot from a USB device (flash drive, HDD or SSD) or use Internet Recovery.
  • Add or remove the command prefix sudo.
  • Use the cd command to navigate to the proper directory (folder).
  • Precede a command or file with the proper path.
  • Make the proper adjustments if the sector size is not 512 bytes.
  • Deal with addition complexities, if employing Core Storage.

Below is the procedure for copying a Recovery partition from /dev/disk1 to /dev/disk2. This procedure requires the use of a third parity command called gdisk. More information about this command can be found at the site "GPT fdisk Tutorial".

The initial contains of /dev/disk1 and /dev/disk2 are given below.

Steelhead:recover davidanderson$ sudo gpt -r show /dev/disk1
Password:
      start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2         32         Pri GPT table
         34          6         
         40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
     409640  197892752      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  198302392    1697608      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
  200000000          7         
  200000007         32         Sec GPT table
  200000039          1         Sec GPT header
Steelhead:recover davidanderson$ sudo gpt -r show /dev/disk2
      start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2         32         Pri GPT table
         34          6         
         40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
     409640   99328216      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
   99737856     262151         
  100000007         32         Sec GPT table
  100000039          1         Sec GPT header
  1. Image the entire source partition. This partition is very small and normally is not mounted. Simply copy the partition to a file.

    Steelhead:recover davidanderson$ sudo dd if=/dev/disk1s3 of=recovery.binary bs=40960
    21220+1 records in
    21220+1 records out
    869175296 bytes transferred in 44.563133 secs (19504358 bytes/sec)
    Steelhead:recover davidanderson$ ls -l
    total 1697608
    -rw-r--r--  1 root  staff  869175296 Jul 20 11:53 recovery.binary
    
  2. Make room of for the new Recovery partition.

    Steelhead:recover davidanderson$ diskutil resizevolume /dev/disk2s2 limits
    For device disk2s2 MacintoshHD:
            Current size:  50.9 GB (50856046592 Bytes)
            Minimum size:  5.5 GB (5524418560 Bytes)
            Maximum size:  50.9 GB (50856046592 Bytes)
    Steelhead:recover davidanderson$ diskutil resizevolume /dev/disk2s2 45G
    Started partitioning on disk2s2 MacintoshHD
    Verifying the disk
    Verifying file system
    Checking Journaled HFS Plus volume
    Checking extents overflow file
    Checking catalog file
    Checking multi-linked files
    Checking catalog hierarchy
    Checking extended attributes file
    Checking volume bitmap
    Checking volume information
    The volume MacintoshHD appears to be OK
    File system check exit code is 0
    Resizing
    Finished partitioning on disk2s2 MacintoshHD
    /dev/disk2
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *51.2 GB    disk2
       1:                        EFI EFI                     209.7 MB   disk2s1
       2:                  Apple_HFS MacintoshHD             45.0 GB    disk2s2
    
  3. Create the new Recovery partition on /dev/disk2. The new partition has to be exactly the same size as the existing Recover partition.

    Steelhead:recover davidanderson$ sudo gdisk /dev/disk2
    Password:
    GPT fdisk (gdisk) version 1.0.1
    
    Warning: Devices opened with shared lock will not have their
    partition table automatically reloaded!
    Partition table scan:
      MBR: protective
      BSD: not present
      APM: not present
      GPT: present
    
    Found valid GPT with protective MBR; using GPT.
    
    Command (? for help): n
    Partition number (3-128, default 3): 
    First sector (34-100000006, default = 88300264) or {+-}size{KMGTP}: 
    Last sector (88300264-100000006, default = 100000006) or {+-}size{KMGTP}: +1697608
    Current type is 'Apple HFS/HFS+'
    Hex code or GUID (L to show codes, Enter = AF00): AB00
    Changed type of partition to 'Recovery HD'
    
    Command (? for help): x
    
    Expert command (? for help): a
    Partition number (1-3): 3
    Known attributes are:
    0: system partition
    1: hide from EFI
    2: legacy BIOS bootable
    60: read-only
    62: hidden
    63: do not automount
    
    Attribute value is 0000000000000000. Set fields are:
      No fields set
    
    Toggle which attribute field (0-63, 64 or <Enter> to exit): 49
    Have enabled the 'Undefined bit #49' attribute.
    Attribute value is 0002000000000000. Set fields are:
    49 (Undefined bit #49)
    
    Toggle which attribute field (0-63, 64 or <Enter> to exit): 
    
    Expert command (? for help): w
    
    Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
    PARTITIONS!!
    
    Do you want to proceed? (Y/N): y
    OK; writing new GUID partition table (GPT) to /dev/disk2.
    Warning: Devices opened with shared lock will not have their
    partition table automatically reloaded!
    Warning: The kernel may continue to use old or deleted partitions.
    You should reboot or remove the drive.
    The operation has completed successfully.
    Steelhead:recover davidanderson$ sudo gpt -r show /dev/disk2
          start       size  index  contents
              0          1         PMBR
              1          1         Pri GPT header
              2         32         Pri GPT table
             34          6         
             40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
         409640   87890624      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
       88300264    1697608      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
       89997872   10002135         
      100000007         32         Sec GPT table
      100000039          1         Sec GPT header
    
  4. Eject and reattach /dev/disk2. If you can not do this, then restart the Mac.

    Steelhead:recover davidanderson$ diskutil eject /dev/disk2
    Disk /dev/disk2 ejected
    
  5. Copy the saved image to the new Recovery partition. Since this is an exact copy, use the hfs.util command to generate a new UUID key for the HFS file system.

    When using El Capitan (OS X 10.11), the full path to the hfs.util command is System/Library/Filesystems/hfs.fs/Contents/Resources/hfs.util.

    Steelhead:recover davidanderson$ sudo dd if=recovery.binary of=/dev/disk2s3 bs=40960
    Password:
    21220+1 records in
    21220+1 records out
    869175296 bytes transferred in 52.127608 secs (16673992 bytes/sec)
    Steelhead:recover davidanderson$ /System/Library/Filesystems/hfs.fs/hfs.util -k disk2s3; echo
    78A8438E-2299-3AF0-AD9E-3AC225B0554A
    Steelhead:recover davidanderson$ /System/Library/Filesystems/hfs.fs/hfs.util -s disk2s3
    Steelhead:recover davidanderson$ /System/Library/Filesystems/hfs.fs/hfs.util -k disk2s3; echo
    0F4F5893-D9E1-3512-9B2B-2AEA0DE9FDE3
    
  6. Eject and reattach /dev/disk2. If you can not do this, then restart the Mac.

    Steelhead:recover davidanderson$ diskutil eject /dev/disk2
    Disk /dev/disk2 ejected
    
  7. Attempt to recover any leftover free space.

    Below a is first attempt. The diskutil resizevolume /dev/disk2s2 R command fails.

    Note also that diskutil resizevolume /dev/disk2s2 limits command reports the wrong maximum size.

    Steelhead:recover davidanderson$ diskutil resizevolume /dev/disk2s2 R
    Started partitioning on disk2s2 MacintoshHD
    Verifying the disk
    Verifying file system
    Checking Journaled HFS Plus volume
    Checking extents overflow file
    Checking catalog file
    Checking multi-linked files
    Checking catalog hierarchy
    Checking extended attributes file
    Checking volume bitmap
    Checking volume information
    The volume MacintoshHD appears to be OK
    File system check exit code is 0
    Resizing
    Error: -69742: The requested size change for the target disk or a related disk is too small;
    please try a different disk or partition, or make a larger change
    Steelhead:recover davidanderson$ diskutil resizevolume /dev/disk2s2 limits
    For device disk2s2 MacintoshHD:
            Current size:  45.0 GB (44999999488 Bytes)
            Minimum size:  5.5 GB (5524459520 Bytes)
            Maximum size:  45.0 GB (44999999488 Bytes)
    

    Try again, but this time compute how large partition /dev/disk2s2 should be.

    Steelhead:recover davidanderson$ sudo gpt -r show /dev/disk2
    Password:
          start       size  index  contents
              0          1         PMBR
              1          1         Pri GPT header
              2         32         Pri GPT table
             34          6         
             40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
         409640   87890624      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
       88300264    1697608      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
       89997872   10002135         
      100000007         32         Sec GPT table
      100000039          1         Sec GPT header
    Steelhead:recover davidanderson$ expr 10002135 \* 512 / 100000000 + 450 
    501
    Steelhead:recover davidanderson$ diskutil resizevolume /dev/disk2s2 50.1G
    Started partitioning on disk2s2 MacintoshHD
    Verifying the disk
    Verifying file system
    Checking Journaled HFS Plus volume
    Checking extents overflow file
    Checking catalog file
    Checking multi-linked files
    Checking catalog hierarchy
    Checking extended attributes file
    Checking volume bitmap
    Checking volume information
    The volume MacintoshHD appears to be OK
    File system check exit code is 0
    Resizing
    Waiting for the disks to reappear
    Finished partitioning on disk2s2 MacintoshHD
    /dev/disk2
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *51.2 GB    disk2
       1:                        EFI EFI                     209.7 MB   disk2s1
       2:                  Apple_HFS MacintoshHD             50.1 GB    disk2s2
       3:                 Apple_Boot recovery                869.2 MB   disk2s3
    Steelhead:recover davidanderson$ sudo gpt -r show /dev/disk2
    Password:
          start       size  index  contents
              0          1         PMBR
              1          1         Pri GPT header
              2         32         Pri GPT table
             34          6         
             40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
         409640   97851560      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
       98261200    1697608      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
       99958808      41199         
      100000007         32         Sec GPT table
      100000039          1         Sec GPT header
    

    This attempt succeeded. In practice, you never recover all the free space. Note that the new Recovery partition /dev/disk2s3 was relocated automatically.

  • David, thanks for the detailed answer. In the end I found (see my own answer) that the easiest solution was just to reinstall OS X, which was straightforward and non-destructive. – Jason Jul 21 '16 at 16:23
0

I found that simply reinstalling OS X was the way to go. It was really straightforward, and didn't even take that long. Just searched the App Store for the El Capitan installer, and it installed over the current installation - notably, without erasing or messing with any of my user files held in the home folder. This recreated the recovery partition, and also made sure that all of the drivers etc. were properly installed. So far working great, and didn't have to deal with arcane terminal commands which, while I can handle it, would leave me worried that the recovery partition wouldn't work properly when I need it to.

You must log in to answer this question.

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