Installation: No Disc found. Formatting back to OS

Discussion in 'macOS' started by Jeppadee, Apr 21, 2011.

  1. Jeppadee macrumors newbie

    Joined:
    Apr 21, 2011
    #1
    Hi everyone

    I have recently tried to install windows XP on my mac. What i think happened, was that i THOUGHT i was using bootcamp, but in fact it tried to install XP as the main operation system. In any case, i was stuck in the XP setup blue screen, without being able to complete the installation, get back to OS or even get the XP installer disc out. After spamming the Disc removal key, i finally got the disc out, but when i restarted the mac, a flashing folder showed up. I found out this was because the computer could not find a operating system to boot by. I plugged in the installation disc and tried to repair the disc but it could not. I finally gave up and tried to reinstall the whole thing, but it could not find the harddisc.

    What i am asuming happened is: I must have said yes, when the XP setup asked me if i wanted to format the disc. This (ofcause) ment i could no longer run OS on the disc. I realise all my school work, notes and files are gone, what i want now is just my computer back with OS. How do i format the disc back so that i can reinstall OS on it? Please help, and yes i know it was very stupid to format the disc in the first place.
     
  2. Detrius macrumors 68000

    Joined:
    Sep 10, 2008
    Location:
    Asheville, NC
    #2
    Actually, if all you did is format the drive (and you didn't install), it may very well be possible to get all of your data back. You'll need another OS to boot from, but if you manually recreate the partition table, it's likely that the windows format did not quite reach where the HFS+ directory structure is stored and only overwrote the partition table itself and parts of the EFI partition.

    Once you're booted from a good OS, you can rewrite the partition table from Terminal. This will have the benefit that your existing volume won't need to be reformatted. You may need a utility like Disk Warrior to clean up the directory structure afterward.

    First, you'll need to figure out the disk number of the hard drive. If you're booted from the machine (rather than a different machine, using the drive as an external), it's going to be /dev/disk0. The following will rewrite the partition table to near-default (possibly a little bigger primary volume):

    Code:
    sudo dd if=/dev/zero of=/dev/disk0 bs=512 count=10 conv=sync,noerror
    sudo gpt destroy /dev/disk0
    sudo gpt create /dev/disk0
    sudo gpt add -i1 -b40 -s409600 -tC12A7328-F81F-11D2-BA4B-00A0C93EC93B /dev/disk0
    sudo gpt add -i2 -b409640 -t48465300-0000-11AA-AA11-00306543ECAC /dev/disk0
    
    Then use Disk Utility (or preferably Disk Warrior) to repair the directory structure.


    If you don't want to do all that or can't, you can use Disk Utility to format the drive from the Mac OS X Install disk. I've seen situations where that still wouldn't work, so you may have to do the first two commands anyway.
     
  3. Jeppadee thread starter macrumors newbie

    Joined:
    Apr 21, 2011
    #3
    Thanks alot, thats a relief :D

    I'll take it to the technician at my school when my easter break is over, his got some mean Mac Mojo going so he can probably fix it :)
     
  4. Detrius macrumors 68000

    Joined:
    Sep 10, 2008
    Location:
    Asheville, NC
  5. mcchiu, Nov 5, 2015
    Last edited: Nov 5, 2015

    mcchiu macrumors newbie

    mcchiu

    Joined:
    Nov 5, 2015
    #5
    HI Detrius ? are u still here?
    I am having a problem that all of my partitions in my external hard drive are all gone now. I have fellow your code above there, however I only able to retrieve the first partition, is there any possible way that i can retieve other partitions as well? My harddisk is a 2TB , and the size other of the partition is under the fellow: 200GB , 50GB and 1750GB
    the attachment is the orginal partition layout i find it out using test disk
     

    Attached Files:

  6. Detrius, Nov 8, 2015
    Last edited: Nov 9, 2015

    Detrius macrumors 68000

    Joined:
    Sep 10, 2008
    Location:
    Asheville, NC
    #6
    It's excellent that you have the precise start blocks and lengths, thanks to testdisk, which is actually a tool I had used a long time ago, back when this was still my job. The directions I had originally given were for a drive partitioned as a single volume, and they were based on Apple's default partition structure way back then. I don't knoww if it's still the same (no reason for it not to be), but since you have the precise layout, thanks to testdisk, you can manually recreate the partition table. The directions will be similar, but the last line is where you'll start making changes. The information about the above commands is available in the man page for the "got" command, but here's the stuff you need to know (going off the top of my head):

    -i sets the volume number. You'll increment this by one for each volume you add.
    -b is the start sector, which you'll find in your table. You'll notice that my values matched up with the first two entries in your table.
    -s is the size of the volumes in sectors. I didn't specify a size for the second volume, meaning it should extend to the rest of the disk, which if I remember correctly is always a hair too large, but it gets the job done in a generic way on single-volume drives. Instead, you'll specify the value in your table for each volume you create, and then you won't have volume size errors left over for Disk Warrior to fix.
    -t is the type of volume. The value I specified for the second volume represents HFS, so you'll use this for the second volume and beyond. Additional values are available for reference in the gpt man page.

    Using this information, you can create a series of "gpt add" commands to recreate the volumes on your disk.

    Hope this helps!
     

Share This Page