Is the Recovery Partition not a REAL partition?

Discussion in 'Mac OS X Lion (10.7)' started by netnothing, Aug 9, 2011.

  1. netnothing macrumors 68040

    netnothing

    Joined:
    Mar 13, 2007
    Location:
    NH
    #1
    Ok, so playing around I installed Lion on a clean formatted external disk to do some testing.

    One thing I'm trying to figure out now is doing a backup boot clone and the potential way to restore. Obviously, cloners like CCC and Super Duper will clone my boot drive fine....but it won't clone the Recovery Partition.

    So, for me I clone my boot drive to an external disk. If my main SSD should ever fail....I can always throw this disk in my Mac Pro. However, in the long run, I'd just be getting a new SSD to clone it back. Now if I were to just clone it back, I wouldn't get the Recovery Partition.

    So what I'm assuming is that to work this way in the future....if my drive was to fail, once I get a new SSD boot drive, I'd clean install Lion on that (thus creating the Recovery Partition), and then clone the backup back onto it.

    Sound correct?

    Now, what I tested was taking that clean Lion install, and erasing the Lion partition. What I noticed is that just doing an erase in Disk Utility, also kills the Recovery Partition. Why would erasing the Lion install kill the recovery partition? Is it not a real partition?

    -Kevin
     
  2. JRoDDz macrumors 68000

    JRoDDz

    Joined:
    Jul 2, 2009
    Location:
    NYC
    #2
    The recovery partition is hidden. It won't show up in disk utility. But I think if your erase the entire disk it will also erase that hidden recovery partition.
     
  3. netnothing thread starter macrumors 68040

    netnothing

    Joined:
    Mar 13, 2007
    Location:
    NH
    #3
    Correct. I know you don't see it. Guess I should have been clear.....to view it's there I'm using diskutil list from terminal.

    I'm guessing however, that it's not a "real" partition. Because if it were a real partition, then me erasing the Lion install partition (from Disk Utility) should have no effect on the Recovery Partition.

    -Kevin
     
  4. JRoDDz macrumors 68000

    JRoDDz

    Joined:
    Jul 2, 2009
    Location:
    NYC
    #4
    According to this thread http://forums.macrumors.com/showthread.php?t=1168017&highlight=how+remove+recovery+partition you have to remove the entire hard disk to remove the recovery partition.

    It is a real partition, but I don't think you can erase it unless you erase the entire "Macintosh HD". I had Lion installed and then went back to a Snow Leopard time machine backup to get rid of it, and low and behold the Lion recovery was still there when I booted up the machine while holding the "option" key. I had to erase the entire HD and then restore my time machine backup to get rid of the recovery partition.
     
  5. netnothing thread starter macrumors 68040

    netnothing

    Joined:
    Mar 13, 2007
    Location:
    NH
    #5
    Thanks for pointing out that thread. I replied to ask if anyone has an update since it's from June.

    I'm trying this again.....and will report back.

    When I erase my "Lion Test", I'm erasing the partition in Disk Utility....not the drive itself. So I don't know why it would be touching the Recovery Partition.

    -Kevin
     
  6. JRoDDz macrumors 68000

    JRoDDz

    Joined:
    Jul 2, 2009
    Location:
    NYC
    #6
    I may be wrong. But I don't think I am. If "Lion Test" is the name of your hard drive and you erase it in Disk Utility, you are in effect erasing both the recovery partition (which is hidden from view) and your regular Lion partition.

    Maybe someone else can shed some light on this?
     
  7. netnothing thread starter macrumors 68040

    netnothing

    Joined:
    Mar 13, 2007
    Location:
    NH
    #7
    I'll post some screens once the install is done.....but to answer your question, in Disk Utility, I'm clicking on the indented partition called "Lion Test" and erasing that.

    I'm not clicking on the overall drive, which is where the "Lion Test" partition is indented from.

    -Kevin
     
  8. f00f macrumors 65816

    f00f

    Joined:
    Feb 18, 2009
    Location:
    New Yawk
    #8
    From the diskutil manpage:

    As for the recovery partition being a "real" partition -- it indeed is. If you mount it (diskutil mount disk0s3) you'll see that the /Volumes/Recovery HD is an ordinary HFS+ volume. However in the GPT table it's flagged as "Apple_Boot" (UUID 426F6F74-0000-11AA-AA11-00306543ECAC) which renders the partition invisible to GUI programs like Disk Utility.. See also the manpage for gpt, (try sudo gpt -r show disk0 and also sudo gpt -r show -l disk0).
     
  9. netnothing thread starter macrumors 68040

    netnothing

    Joined:
    Mar 13, 2007
    Location:
    NH
    #9
    Ok, so I just took an external drive and plugged it into my NewerTech Voyager dock. Hooked this up to my MacBook running Lion.

    I created one partition on the drive called "Lion Test"
    I then installed Lion on the drive.

    After the install, when I boot back into my Macbook and run diskutil list I see this:

    Code:
    /dev/disk1
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *300.1 GB   disk1
       1:                        EFI                         209.7 MB   disk1s1
       2:                  Apple_HFS Lion Test               299.2 GB   disk1s2
       3:                 Apple_Boot Recovery HD             650.0 MB   disk1s3
    Ok cool....there's the Lion Test partition and the Recovery HD.

    Attached below is a screenshot of what this looks like in Disk Utility. Clearly, you cannot see the Recovery HD. However, shouldn't I be able to click on the "Lion Test" partition.....then click erase, and have Disk Utility only erase the "Lion Test"? Afterwards shouldn't I still be able to see the Recovery HD partition using diskutil list?

    -Kevin
     

    Attached Files:

  10. f00f macrumors 65816

    f00f

    Joined:
    Feb 18, 2009
    Location:
    New Yawk
    #10
    Negative.

    Doing an Erase in Disk Utility erases all partitions (all volumes) on the target disk and leaves you with one partition in whatever format you chose.
     
  11. netnothing thread starter macrumors 68040

    netnothing

    Joined:
    Mar 13, 2007
    Location:
    NH
    #11
    Ok, so I go into Disk Utility, and I highlight just the "Lion Test" partition and click erase. The screenshot attached shows that Disk Utility says it will erase this partition, not affecting any other partitions on the disk.

    However, after I do that and run diskutil list on the drive again, I get this:

    Code:
    /dev/disk1
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *300.1 GB   disk1
       1:                        EFI                         209.7 MB   disk1s1
       2:                  Apple_HFS Lion Test               299.2 GB   disk1s2

    No recovery partition.

    Why?

    -Kevin
     

    Attached Files:

  12. netnothing thread starter macrumors 68040

    netnothing

    Joined:
    Mar 13, 2007
    Location:
    NH
    #12
    That doesn't make any sense. If I create two partitons on this drive....and I put a bunch of stuff in both. If I then erase one of the partitions.....it doesn't erase anything in the other one.

    -Kevin
     
  13. JRoDDz macrumors 68000

    JRoDDz

    Joined:
    Jul 2, 2009
    Location:
    NYC
    #13
    You have to click where it says "NewerTech" and erase that. That should erase everything on that drive including the hidden recovery partition. If you click on "Lion Test" you are not erasing the hidden partition. Put it this way.. if the recovery partition were not hidden, it would just show up right underneath the "Lion Test" partition.
     
  14. f00f macrumors 65816

    f00f

    Joined:
    Feb 18, 2009
    Location:
    New Yawk
    #14
    Yes, and I stand corrected. I was going by the info about eraseDisk in the man page, when in fact you're effectively doing eraseVolume.

    Perhaps you found another bug? Or perhaps Disk Utility treats Apple_Boot partitions specially, given the fact that it cannot even see them? If it doesn't know a partition is there, why would it necessarily be preserved?

    You could, as a test, change the partition type of the recovery partition from Apple_Boot to Apple_HFS and try your Disk Utility test again.
     
  15. netnothing thread starter macrumors 68040

    netnothing

    Joined:
    Mar 13, 2007
    Location:
    NH
    #15
    That's not what I'm trying to do.

    I AM just clicking on "Lion Test" and erasing that volume. However, what is happening is it is also erasing the Recovery HD partition.....which is why I'm confused. If OS X treats it as a real partiton......why when erasing just the Lion Test, does it ALSO erase the Recovery HD?

    See, my goal in all this was testing for creating a full clone of my Lion boot drive. I was trying to see if I clean installed Lion on a drive, then erased just the Lion install part, whether I would be left with an empty partition AND the Recovery HD partition. I'm just tinkering.....to see what happens. Clearly though, it looks like OS X is killing the Recovery HD partition when I erase the Lion partition.

    -Kevin
     
  16. gentlefury macrumors 68030

    Joined:
    Jul 21, 2011
    Location:
    Los Angeles, CA
    #16
    Why do you want to delete it in the first place?
     
  17. netnothing thread starter macrumors 68040

    netnothing

    Joined:
    Mar 13, 2007
    Location:
    NH
    #17
    Because it's there? :D:p:eek:

    Seriously though....I was just playing around with cloning options and was curious to see if I erased the clean Lion install and cloned BACK onto this drive, whether the Recovery HD partition would still be there. What I'm finding is....it's not.

    -Kevin
     
  18. gentlefury macrumors 68030

    Joined:
    Jul 21, 2011
    Location:
    Los Angeles, CA
    #18
    Your better off using the lion recovery assistant:

    http://support.apple.com/kb/DL1433

    And create a USB recovery disk anyway. If your OS disk fails....thats where the recovery hd is located!! Which really makes no sense to me.
     
  19. netnothing thread starter macrumors 68040

    netnothing

    Joined:
    Mar 13, 2007
    Location:
    NH
    #19
    Just an FYI.....

    diskutil eraseVolume from the terminal will ALSO wipe the Recovery HD.

    I think OS X is tying the Lion partition to the Recovery HD partition and diskutil knows about it.

    In this latest case.....I had another partition on the drive and erasing the Lion one does not affect that partition.

    -Kevin
     
  20. f00f, Aug 9, 2011
    Last edited: Jun 4, 2013

    f00f macrumors 65816

    f00f

    Joined:
    Feb 18, 2009
    Location:
    New Yawk
    #20
    EDIT: It is unknown at this time whether the order of the partitions matters. The below tests were done with the Apple_Boot ("recovery") partition placed after the regular HFS+ partition in the GPT table, similar to how disk0 would be partitioned on a legit Lion installation.


    Here's a bit of research/evidence that ultimately comes these conclusions:

    1. Behavior of Disk Utility in regards to Apple_Boot partitions differs on SL and Lion
    2. When erasing a disk slice (e.g. Macintosh HD), SL Disk Utility leaves the Apple_Boot partition alone; Lion removes the Apple_Boot partition from the partition table but apparenlty leaves the data alone
    3. Lion's behavior should be considered a bug (I have not, yet, reported it)

    I did my testing with an 8GB USB stick with a GUID partition map that contained two slices: an HFS+ ("Apple_HFS") and an HFS+ flagged as "Apple_Boot" (the type of Lion's recovery partition). I used the gpt command-line utility for manipulating the partition map and appropriate newfs_hfs commands as well for formatting.

    For all images please click the thumbnails.

    ON SNOW LEOPARD

    Here's what diskutil list disk1 reported for the USB stick after initial partitioning and formatting and mounting (of course only disk1s2 was mounted since the Apple_Boot slices are ignored):
    [​IMG]

    Then I hit this with Disk Utility to erase the visible slice:
    [​IMG]

    The Apple_Boot partition wasn't touched, as seen by the output of diskutil list disk1:
    [​IMG]

    For the sake of reference, here's the partition table as reported by sudo gpt -r show disk1:
    [​IMG]


    ON LION

    I popped this thing into my MBA4,2. As expected, diskutil list disk1 reported the following:
    [​IMG]

    I hit it with Disk Utility to erase the visible slice (disk1s2):
    [​IMG]

    After that -- GASP! -- the "recovery" partition was gone:
    [​IMG]

    And the partition map, as reported by gpt:
    [​IMG]


    BACK ON SNOW LEOPARD

    I hopped back on my trusted and favored SL box. I re-added the "recovery" (Apple_Boot) partition using gpt. This step implies that, although the partition had been removed by Disk Utility on Lion, it wasn't erased! (see the output of diskutil list disk1):
    [​IMG]

    And, as expected, the "recovery" partition (Untitled 2) mounted just fine. (Note the first mountDisk verb ignores the recovery/Apple_Boot slice; it has to be explicitly mounted.):
    [​IMG]

    and, output of mount:
    [​IMG]
     
  21. netnothing thread starter macrumors 68040

    netnothing

    Joined:
    Mar 13, 2007
    Location:
    NH
    #21
    Wow....awesome testing. Thanks for doing that.

    So it looks like the partition is still there, just not shown within a Lion system.

    Interesting.

    -Kevin
     
  22. f00f macrumors 65816

    f00f

    Joined:
    Feb 18, 2009
    Location:
    New Yawk
    #22
    No problem. I was as curious as you, and a little distraction from legitimate work I should be doing is always good. ;)

    Yes, Lion apparently re-writes the drive's partition map when you erase your Lion Test slice using Disk Utility, leaving out the Recovery slice. When it re-writes the map, it uses the same geometry that the Lion Test slice had before the erase (i.e. the same start and size as reported by gpt). As we know the Recovery slice resides after the Lion Test slice; Disk Utility merely removes it from the partition map (effectively does a gpt remove) but it apparently doesn't do anything at all to the actual bytes of data aside from changing the partition table. So, after you do the erase procedure using Disk Utility -- and if you know the start and size parameters of the recovery slice (as shown by gpt) -- you could do a gpt add to put that recovery slice back in the partition map.
     

Share This Page