Update (Oct 23, 2010): readers posted a lot of valuable comments to this article. Make sure you read them at the bottom of this page.
Some time ago I wrote an article about recreating a Lion recovery partition. The way described in hat article was very technical, complicated and risky.
While any way of adjusting partitions is risky, I found a safer way to recreate recovery partition after my Mac crashed again (looks like its life time is coming to an end). Here is how I did it the second time.
Reboot to your main installation after installing.
Get the information on the Macintosh HD and Recovery HD partitions:
While we resize, we can also create a new partition:
When performing these steps, you must remeber that you do it on your own risk. Neither Apple, nor I will be able to help you if you screw it up. If unsure, ask somebody more accomplished or simply reinstall Lion normally.
Some time ago I wrote an article about recreating a Lion recovery partition. The way described in hat article was very technical, complicated and risky.
While any way of adjusting partitions is risky, I found a safer way to recreate recovery partition after my Mac crashed again (looks like its life time is coming to an end). Here is how I did it the second time.
Install Lion
Install Lion on the USB drive or USB stick. If you use stick, make sure you got a good one. I got a very cheap one from Disk2Go and it took 4 hours to install Lion instead of normal 29 minutes.Reboot to your main installation after installing.
Find partition information
Firsts, change to the root user:Applico:~$ su - Password: Applico:~#List all your disks:
Applico:~# diskutil list /dev/disk0 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *128.0 GB disk0 1: EFI 209.7 MB disk0s1 2: Apple_HFS Macintosh HD 127.7 GB disk0s2 /dev/disk1 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *32.3 GB disk1 1: EFI 209.7 MB disk1s1 2: Apple_HFS OSX 31.4 GB disk1s2 3: Apple_Boot Recovery HD 650.0 MB disk1s3From here we know that we have two disks: a hard disk (disk0) and a USB disk (disk1).
Get the information on the Macintosh HD and Recovery HD partitions:
Applico~:# diskutil info /dev/disk0s2
Device Identifier: disk0s2
Device Node: /dev/disk0s2
Part of Whole: disk0
Device / Media Name: Macintosh HD
Volume Name: Macintosh HD
Escaped with Unicode: Macintosh%FF%FE%20HD
Mounted: Yes
Mount Point: /
Escaped with Unicode: /
File System Personality: Journaled HFS+
Type (Bundle): hfs
Name (User Visible): Mac OS Extended (Journaled)
Journal: Journal size 16384 KB at offset 0x3ba000
Owners: Enabled
Partition Type: Apple_HFS
OS Can Be Installed: Yes
Media Type: Generic
Protocol: SATA
SMART Status: Verified
Volume UUID: 5C784582-B984-3B4A-85FE-245E9056CD5F
Total Size: 127.7 GB (127691702272 Bytes) (exactly 249397856 512-Byte-Blocks)
Volume Free Space: 28.2 GB (28211933184 Bytes) (exactly 55101432 512-Byte-Blocks)
Device Block Size: 512 Bytes
Read-Only Media: No
Read-Only Volume: No
Ejectable: No
Whole: No
Internal: Yes
Solid State: Yes
Applico:~# diskutil info /dev/disk1s3
Device Identifier: disk1s3
Device Node: /dev/disk1s3
Part of Whole: disk1
Device / Media Name: Recovery HD
Volume Name: Recovery HD
Escaped with Unicode: Recovery%FF%FE%20HD
Mounted: No
File System Personality: Journaled HFS+
Type (Bundle): hfs
Name (User Visible): Mac OS Extended (Journaled)
Journal: Unknown (not mounted)
Owners: Disabled
Partition Type: Apple_Boot
OS Can Be Installed: No
Media Type: Generic
Protocol: USB
SMART Status: Not Supported
Volume UUID: 69F1FA77-EB09-3D79-BBD7-6101644A108B
Total Size: 650.0 MB (650002432 Bytes) (exactly 1269536 512-Byte-Blocks)
Volume Free Space: 0 B (0 Bytes) (exactly 0 512-Byte-Blocks)
Device Block Size: 512 Bytes
Read-Only Media: No
Read-Only Volume: Not applicable (not mounted)
Ejectable: Yes
Whole: No
Internal: No
You need to note total sizes of both partitions.Resize your main partition
Now we are going to resize our main partition. For that we calculate its new total size. To be safe I decied to substract 700 megabytes instead of 650. So the desired size is calculated like 127691702272-700*1024*1024=127040651264.While we resize, we can also create a new partition:
Applico:~# diskutil resizeVolume /dev/disk0s2 127040651264B jhfs+ "Recovery HD" 650002432B Started partitioning on disk0s2 Macintosh HD Verifying the disk Checking file system Performing live verification 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 Macintosh HD appears to be OK Resizing Waiting for the disks to reappear Formatting disk0s3 as Mac OS Extended (Journaled) with name Recovery HD Initialized /dev/rdisk0s3 as a 621 MB HFS Plus volume with a 8192k journal Mounting disk Finished partitioning on disk0s2 Macintosh HD /dev/disk0 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *128.0 GB disk0 1: EFI 209.7 MB disk0s1 2: Apple_HFS Macintosh HD 127.0 GB disk0s2 3: Apple_HFS Recovery HD 651.1 MB disk0s3Note that recovery partition size is not right. When adding partitions, diskutil made it larger than we asked. Fix it:
Applico:~# diskutil resizeVolume disk0s3 650002432B
Started partitioning on disk0s3 Recovery HD
Verifying the disk
Checking 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 Recovery HD appears to be OK
Resizing
Finished partitioning on disk0s3 Recovery HD
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *128.0 GB disk0
1: EFI 209.7 MB disk0s1
2: Apple_HFS Macintosh HD 127.0 GB disk0s2
3: Apple_HFS Recovery HD 650.0 MB disk0s3
This step is important. If you do not get the right size, you are going to screw your recovery partition.Copy recovery partition content
Now copy recovery partition content:Applico:~# dd if=/dev/disk1s3 of=/dev/disk0s3
1269536+0 records in
1269536+0 records out
650002432 bytes transferred in 185.538679 secs (3503326 bytes/sec)
Make sure you use regular disks (/dev/diskX), not raw disks (/dev/rdiskX). Raw disks always results in kernel panic in my case. Be careful with of argument. If you override a wrong place, you are screwed up. Double check where you copy!Adjust partition type
That was the most risky part in the previous article. Now I found the easier way to do it:Applico:~# asr adjust --target /dev/disk0s3 -settype "Apple_Boot"
Fsck /dev/disk0s3 ....10....20....30....40....50....60....70....80....90....100
Adjust completed successfully
Check it:Applico:~ root# diskutil list
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *128.0 GB disk0
1: EFI 209.7 MB disk0s1
2: Apple_HFS Macintosh HD 127.0 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *32.3 GB disk1
1: EFI 209.7 MB disk1s1
2: Apple_HFS OSX 31.4 GB disk1s2
3: Apple_Boot Recovery HD 650.0 MB disk1s3
Everything seems to be in order.Recheck your start up disk
Using diskutil may remove startup disk mark from your main disk. Go to the System Preferences (click Apple logo for that) and select “Startup Disk” item. Make sure that your Mac's hard drive is listed as startup disk.Test recovery partition
Now you can reboot and hold Alt/Option key. The recovery partition should be appear as a boot option. You should be able to boot with it.Conclusion
This way is much easier than the way I described before but it also took me some time to figure out all commands. The summary you see here should be error free. But if you find some errors or have anything to add, let me know and I will happily update the article.When performing these steps, you must remeber that you do it on your own risk. Neither Apple, nor I will be able to help you if you screw it up. If unsure, ask somebody more accomplished or simply reinstall Lion normally.
Thank you for interesting recipe.
ReplyDeleteI reinstalled the system to restore Recovery HD.
Thanks for this
ReplyDeleteI spent best part of today getting the old method to work had loads of resource busy errors. But i got it working using the old method in the end then i found this article. :)
LIfe saver. Thanks for sharing this!
ReplyDeleteI believe the reason that "When adding partitions, diskutil made it larger than we asked" is because the math is incorrect.
ReplyDelete127691702272-(700*1024*1024)=
127691702272-(734003200)=
126957699072
and you had calculated it to 127040651264.
Although it may still make the recovery partition too big...the
ReplyDeletediskutil resizeVolume disk0s3 650002432B
step is still necessary.
And I forgot to say -- thanks so much!
The first time through, after doing the asr step, the new recovery partition got munged and diskutil list showed a GUID that was all Fs. Deleting the munged recovery partition and going through all the steps again worked fine.
All in all, using your method, I was able to create the recovery partition and enable File Vault.
Worked like a charm !!!! you are brilliant !
ReplyDeleteThe "Media Name" of the Recovery HD partition is _very_ important. If it's not set to "Recovery HD", some of Apple's tools will think the partition is damaged and refuse to work with it. Example: Recovery Disk Assistant.
ReplyDeleteI wrote a post about it on my blog, it involves changing the label (media name) using either GPT or parted: http://blog.fgsfd.se/post/12130647640/restoring-the-recovery-hd-in-mac-os-x-lion-perfectly
Thank you for your valuable information on this subject.
Worked perfectly even with the existence of a boot camp partition.
ReplyDeleteThx
This worked PERFECTLY. Thank you so much for taking the time to write this up.
ReplyDeleteanyone else reading this, change the block size to 1MB for the dd command:
ReplyDeletedd if=/dev/disk1s3 of=/dev/disk0s3 bs=1m
and that operation will complete probably 8x faster (you will max out the read speed of your USB disk).
This is the info I am getting on recovery HD:
ReplyDeleteswoonmembp:~ swoonme$ diskutil info /dev/disk0s3
Device Identifier: disk0s3
Device Node: /dev/disk0s3
Part of Whole: disk0
Device / Media Name: Recovery HD
Volume Name: Not applicable (no file system)
Mounted: Not applicable (no file system)
File System: None
Partition Type: Apple_Boot
OS Can Be Installed: No
Media Type: Generic
Protocol: SATA
SMART Status: Verified
Volume UUID: D32DA566-7A5B-3D59-841E-A7E322126537
I do not have a name for it, so I can't locate it. I tried 'su -' first, but it will not let me type my password. Do I need to 'su -' to see the Recovery HD name? All I want to do is add some programs into that partition so I can run them to prep my mac my way: Onyx, DiskWarrior, Drive Genius.
Any ideas?
Many thanks.
Hello i've problem at this point :
ReplyDeleteasr adjust --target /dev/disk0s3 -settype "Apple_Boot"
What i obtain is this :
asr: Volume adjustment failed: Permission denied
Any suggestions please ?
Thanks
Riccardo