Oh, drat! Sorry to say you most likely lost it all.
This is the exact reason NO one should just follow any random video on the Web. To explain what I am saying, there is a high probability you used diskutil improperly with the wrong disk identifier (your Startup Disk rather than the intended target) and as root, which most likely overwrote Mac OS X with Raspbian without mercy. What is odd about that, however, is that Recovery does work.
For future reference, let me give you a better way to write Apple supported images. Open Disk Utility and click your flash drive. Go to the Restore tab and drag the image in the source box. In Yosemite and later, go to Edit > Restore and browse for the image you intend to restore instead. Restore. But, our problem is this won't work for Raspbian, as it's a Gnu/Linux flavor, not the standard Apple dmg. So we will need Terminal.
But first, a few notes: Whatever you decide to do things using Terminal, be very careful (especially as root, and that goes for all UNIX (and *nix-like systems!) The sad part is that the guy in the video was close, but didn't do a god job of clarifying the inherent danger in blindly writing an image with all powers. ALWAYS back up first before running a dangerous command.
Now, as for the method. If you're new to all this, I would avoid playing in diskutil. Instead, use mount with no arguments to find your disk identifier. You'll note your hard disk also has an identifier, which for example could be /dev/disk0. If you know the name of your flash drive, that's even better as we can filter that right out and ensure we have the right one. So, if your flash drive or card's name is example, we can run mount | grep example to filter what we want. So, now, if it's disk3, you'll see /dev/disk3s1 and example all nicely listed and filtered out, being automounted for us under Volumes.
Once you are absolutely certain what the identifier (or ending number) is for your flash drive, go ahead and type if= and drag the image, so it pastes the path into the Terminal from the Finder. Now apply our previous finding and add of= (output file). Again, if mount or Disk Utility gave you /dev/disk3s1 for example as the flash drive, /dev/disk3 is what we need (we want the root of the drive, not the ending s# which stand for partitions in this scenario). But, this could be different on your system (check first!). In our example here, the completed command might look something like this: dd if=/Users/me/Downloads/2015-11-21-raspbian-jessie-lite.img of=/dev/disk3. Or, let's give an alternate example where it was disk5 and we went to the right directory (like, say, Downloads), we could then autocomplete with tab, add the if, and do this: dd if=2015-11-21-raspbian-jessie-lite.img of=/dev/disk5
But in either case, back up first. Be careful. Do great.
Now, the pressing and more challenging question is how to get your data back. You already discovered your startup disk is gone. First, try restoring from a Time Machine backup (assuming you wisely had this set up). If not, try writing a Linux Mint image (I would say Fedora, but dracut sometimes hangs on live USB in my experience since R19) using a Mac with the example above, or another UNIX (or like) system (though there will be some differences; you will probably see /dev/sd# or mmcblk# for some cards on modern Gnu/Linux flavors, for instance). Or, download win32imagewriter for Windows XP SP2 or later and use that with Administrator rights (again, watch for the drive identifier first; in this case, the letter!) Assuming you have Mint booted, run parted (if it is not available, connect to a network, sudo apt-get update && sudo apt-get install parted -y. What we are hoping for is that the table is still somewhat intact. Do sudo -s to elevate then run parted -s -l. You should see /dev/sda or whatever your hard drive is.
If you have a valid GPT table and you don't get any warnings about that, continue. If not, skip this paragraph. In the case of sda, I'd do parted /dev/sda. Now, from what you observed earlier, look for the end of any preceding partitions (most likely where EFI sat). Now, assuming a default El Capitan setup, or anything past Lion, this should be 209.7 MB. The start should therefore round close to that point (if the GPT isn't too awful corrupted, parted should warn you if your query does not match and try to readjust). For the end point, where does Recovery start (usually volume 3?) For instance, on my 160 GB disk, it is after 42.6 Gb. This is our end point. With an insane amount of luck, try putting a start and end for rescue, such as rescue 210M 42.6GB and see what happens. If this failed, even with an adjustment, you could try fdisk. The problem, though, is that this is generally for undoing changes before a reboot that are still fresh; this is only a long shot.
If you didn't back up anything, you're not entirely out of luck just yet. From a NetBoot, FireWire, USB 3, or Lightning external startup disk (I.e. that has OS X on it), you can still use recovery tools such as Recuva for Mac, Prosoft DataRescue, or DiskWarrior to try to salvage whatever you can. Raspbian most likely overwrote some of those files good, but if you have the extra time and cash, it'll be worth it.
If all else fails, or if the table is corrupt, your best bet would be to forget about Recovery (since its on the same disk) and reinstall entirely. Ideally, you'll need to either own or borrow another Mac for this next step. Download 10.11, close the Install OS X pop up window that appears, and use createinstallmedia from inside the OS X installer application bundle/package per the instructions from Apple (there is a guide for this). Power down your Mac, hold Option, and boot from the disk. You'll then need to go to Disk Utility and create a new Intel or GUID partition table (GPT). Create a new partition for your data and the OS; OS X should do the rest when it installs. Close Disk Utility and install as usual. Restore whatever you had backed up.
In any case, I'm hoping all this is unnecessary and that you had Time Machine, iCloud, or another backup system working for you. Good luck with it all. Careful with root commands in the future. Hope this helps!
From the results you posted, I can see the GUID for the Recovery partition is wrong. This is partition number 3 in the tables. The correct value in the GPT would be 426F6F74-0000-11AA-AA11-00306543ECAC. The fdisk
command also shows the value to be wrong in the MBR table. Here, the correct value should be AB
. If you can not boot to your Recovery partition after repairing these tables, then I would assume the contents of the partition is corrupted.
As far as I know, there is no utility in OS X for this type of repair. (Technically, you could use the dd
command, but no sane person would attempt using dd
to fix this problem.) I would recommend downloading and installing the gdisk
command from here. To install, you may have to modify the setting on the "Security & Privacy" pane of the "System Preferences".
To use the gdisk
command, you will need to disable System Integrity Protection (SIP). Normally, this can be done while in Recovery mode. Since you can not boot to Recovery mode, you can use a product called "rEFInd". Many Linux users already have this product installed on their Mac computer. If you do not, you can create a USB flash drive version which can be used to disable/enable SIP. The instructions are given here.
Note: Since you have Debian Linux already installed, you may be able to execute gdisk
from this operating system. Since I do not have this operating system installed, I am not going to pursue this further. You can obtain more information from this site. Also, gdisk
may be available by booting from an external Emergency Disk. If available under Linux or from an Emergency Disk, you will not have to disable SIP.
Once gdisk
is installed and SIP is disabled, you will need to make three changes. These changes involve modifying both the GUID Partition Table (GPT) and the Master Boot Record (MBR) partition table. The changes are listed below.
- Change the type GUID for partition 3 in the GPT from
48465300-0000-11AA-AA11-00306543ECAC to
426F6F74-0000-11AA-AA11-00306543ECAC. Note:
gdisk
uses a value of
AB00
to represent the value 426F6F74-0000-11AA-AA11-00306543ECAC.
- Make sure the attribute for partition 3 is
0002000000000000
. In
the example below, I assume the current value for the attribute is
0000000000000000
. If not, make the appropriate corrections.
- Change the id for partition 3 in the MBR table from
AF
to AB
.
In the example below, I create and mounted a sparse image as /dev/disk1
. I then used this image as input to the gdisk
command. This was done to simulate the conditions on your computer. You will be making changes to your /dev/disk0
.
Steelhead:~ davidanderson$ sudo gdisk /dev/disk1
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: hybrid
BSD: not present
APM: not present
GPT: present
Found valid GPT with hybrid MBR; using GPT.
Command (? for help): t
Partition number (1-5): 3
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-5): 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): r
Recovery/transformation command (? for help): h
WARNING! Hybrid MBRs are flaky and dangerous! If you decide not to use one,
just hit the Enter key at the below prompt and your MBR partition table will
be untouched.
Type from one to three GPT partition numbers, separated by spaces, to be
added to the hybrid MBR, in sequence: 2 3 4
Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): y
Creating entry for GPT partition #2 (MBR partition #2)
Enter an MBR hex code (default AF): af
Set the bootable flag? (Y/N): y
Creating entry for GPT partition #3 (MBR partition #3)
Enter an MBR hex code (default AB): ab
Set the bootable flag? (Y/N): n
Creating entry for GPT partition #4 (MBR partition #4)
Enter an MBR hex code (default 83): 83
Set the bootable flag? (Y/N): n
Recovery/transformation 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/disk1.
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:~ davidanderson$
At this point, I would restart your Mac.
Best Answer
This is exactly the type of convoluted situation that calls for having a 3rd party software cloning utility in your toolset. If you need to transfer Apps, system settings & one or more user profiles to the replacement SSD then using a cloning tool would be ideal. It would enable you to clone just the boot partition to the SSD after which you would need to reinstall the OS from an internet restore session so as to get a functional local restore partition on the SSD as well. This can be done without harming the data that already exists on the drive.
If you want to reuse the original drive for backups as an example, then once you can successfully boot from the SSD you can reconnect the old drive & use Disk Utility to repartition it so you have access to its entire storage volume.