Mac recovery partion: revisited
as found here
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 disk1s3
From 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 disk0s3
Note 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.