IMac main partition disappeared after deleting a different partition

bootbootcampdisk-utilityhard drivepartition

So, I created a 20GB partition in my iMac to install Ubuntu. That worked fine, but then it turned out I needed a bit more space for the software I wanted to install, so I turned the computer off and rebooted on the main partition (Mac HD, I believe). I then deleted the 20 Gb partition, and I'm sure that's the one I deleted because I triple checked it's size, just in case. Something weird happened right away, the Mac HD partition was now being recognized as an external drive. I didn't think too much of it though, as I was more worried about the fact that those 20GB of space apparently weren't available. I then decided to restart the computer, maybe that would fix the issue. Well, the Linux partition was still there but the Mac HD option was gone -.-

Both regular and Safe boot take me to a grub command line, as well as booting the Linux partition, so it seems I actually erased it. Running diagnostics (Command-R and D keys on startup) tells me everything is fine. I also tried reseting the PRAM, to no effect.

I started the Ubuntu installation process, just to see if it would work, and when choosing where to install it there's an empty 20GB "partition" of free space, which I imagine corresponds to the partition I created and then erased, as well as 230GB partition, of which an 'unknown' amount is used.

Is there any hope of recovering the disk? I don't have a complete backup of the system, only a semi-recent backup of important work. I can live with losing some stuff, but I'd rather try to salvage it if possible, it will be quite a nuisance reinstalling all the software I use on a regular basis. If there's a way, how would I go about it? Also, if you have any idea of what might have caused this, I'd love to know.

Thanks in advance!

EDIT:
Since no one has answered I decided to give a blind try at this, let's hope I didn't screw up.

Interestingly, while the first time i used diskutilthe main partition was disk2, it now seems to be disk14. I haven't done anyhing else at this point, is this normal behaviour?

diskutil list

/dev/disk0 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        +2.1 GB     disk0
   1:                  Apple_HFS OS X Base System        2.0 GB     disk0s1
/dev/disk1 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               +5.2 MB     disk1
/dev/disk2 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               +524.3 KB   disk2
/dev/disk3 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               +524.3 KB   disk3
/dev/disk4 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               +524.3 KB   disk4
/dev/disk5 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               +524.3 KB   disk5
/dev/disk6 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               +524.3 KB   disk6
/dev/disk7 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               +6.3 MB     disk7
/dev/disk8 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               +2.1 MB     disk8
/dev/disk9 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               +1.0 MB     disk9
/dev/disk10 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               +524.3 KB   disk10
/dev/disk11 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               +524.3 KB   disk11
/dev/disk12 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               +1.0 MB     disk12
/dev/disk13 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               +6.3 MB     disk13
/dev/disk14 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk14
   1:                        EFI EFI                     209.7 MB   disk14s1
   2: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF               230.8 GB   disk14s2

gpt -r show disk14

      start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2         32         Pri GPT table
         34          6         
         40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
     409640  450721136      2  GPT part - FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF
  451130776   39103943         
  490234719         32         Sec GPT table
  490234751          1         Sec GPT header

I haven't got a clue what to look for, but I'm assuming that, since I see non-zeros, this is a CoreStorage partition. Is this correct?

dd if=/dev/disk14s2 count=3 | vis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0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0-

I'm still reticent to proceed, but I'll wait a bit to see if someone is able to respond…

EDIT2:
I proceeded with the assumption that I was looking at a CoreStorage partition. When verifying the disk, this was the error message I got:

diskutil verifyVolume disk14s2

Error starting file system verification for disk14s2: The given disk has a storage system (such as AppleRAID) which is not supported for this operation (-69718)

diskutil verifyDisk disk14

Problems were found with the partition map which might prevent booting
Error: -69808: Some information was unavailable during an internal lookup

Should I continue with diskutil repairDisk disk14 or does this error mean something else should be atempted?

EDIT3: According to David Anderson, I was actually looking at a APFS container partition. Following the steps he provided I got this:

gpt -r show disk14

      start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2         32         Pri GPT table
         34          6         
         40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
     409640  450721136      2  GPT part - 7C3457EF-0000-11AA-AA11-00306543ECAC
  451130776   39103943         
  490234719         32         Sec GPT table
  490234751          1         Sec GPT header

Disk verification seems to be good now, but verifying the volume still returns an error, albeit a different one.

diskutil verifyDisk disk14

The partition map appears to be OK

diskutil verifyVolume disk14s2

Error starting file system verification for disk14s2: Unrecognized file system (-69846)

Should I try repairing now?

Best Answer

Based on klanomath's answer to the question OS volume shows as type 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF', you should proceed as follows.

  • Boot to Internet Recovery Mode (or a third party drive).

  • Open Terminal in the menubar Utilities > Terminal

  • Get an overview with diskutil list.

  • Assuming the disk identifier for the internal drive is still disk14, then enter the following commands. Otherwise, make the appropriate substitutions for the disk identifier.

     diskutil umountDisk disk14
     gpt remove -i 2 /dev/disk14
     gpt add -i 2 -b 409640 -s 450721136 -t 7C3457EF-0000-11AA-AA11-00306543ECAC /dev/disk14
    

Additional comments on some of your questions.

  • What you thought was a CoreStorage partition is actually a Apple File System (APFS) container partition.
  • The identifiers (such as disk0 or disk0s2), used by commands such as diskutil and gpt, are assigned as needed. In other words, there is not permanent identifier assigned to a disk, partition, container, etc. You may need to view the output from diskutil list to see the current identifier assignment.