APFS file system not detected, but fsck_apfs says otherwise

Recently, I've been trying to dual boot Linux alongside macOS with my 2014 Macbook Air. After formatting a 2gb usb stick to exFAT via a Debian live disk, I found my Macintosh HD to no longer be availabe as a boot option. The recovery partition isnt detected either, as command + r takes me straight to internet recovery. I've been in internet recovery doing some probing (via option + command + r).


My drive should have 3 partitions. An ext4 partition (not readable by macOS I believe) that is 115gb, an APFS partition that is supposed to be around about 120gb, and a final exFAT partition that fills the rest of my 251gb.


Only the exFAT partition showes up in recovery mode disk utility.


"diskutil list" outputs the following for my drive:

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF               117.6 GB   disk0s2
   3:       Microsoft Basic Data Share                   17.7 GB    disk0s3
   4:           Linux Filesystem                         115.5 GB   disk0s4


"diskutil mount disk0s2" fails to mount.


"diskutil verifyVolume" and "diskutil repairVolume" both fail due to an unrecognized filesystem (-69846).


"diskutil info disk0s2" outputs the following:

   Device Identifier:         disk0s2
   Device Node:               /dev/disk0s2
   Whole:                     No
   Part of Whole:             disk0

   Volume Name:               Not applicable (no file system)
   Mounted:                   Not applicable (no file system)
   File System:               None

   Partition Type:            FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF
   OS Can Be Installed:       No
   Media Type:                Generic
   Protocol:                  PCI
   SMART Status:              Verified
   Disk / Partition UUID:     8AC659AB-FB54-4FEB-AACD-943227E69497
   Partition Offset:          209735680 Bytes (409640 512-Byte-Device-Blocks)

   Disk Size:                 117.6 GB (117649367040 Bytes) (exactly 229783920 512-Byte-Units)
   Device Block Size:         512 Bytes

   Media OS Use Only:         No
   Media Read-Only:           No
   Volume Read-Only:          Not applicable (no file system)

   Device Location:           Internal
   Removable Media:           Fixed

   Solid State:               Yes
   Hardware AES Support:      No


And despite all of this, "fsck_apfs /dev/disk0s2" outputs the following (trunkated where it says "** Checking <things>", lmk if the whole thing would be helpful, it detected all of my volumes)

...
warning: container has been mounted by APFS version 1677.141.3.7.2, which is newer than 1677.141.1
warning: disabling overallocation repairs by default; use -o to override
...
container_iouc:45: cannot find container /dev/rdisk0s2
warning: Unable to read apfs keylocker ranges: No such file or directory
...
...
** The volume /dev/disk0s2 appears to be OK.


So from my unerstanding (which is minimal, I really don't know much but I've come this far and willing to learn) all of it should still be there. But how do I fix this?

Earlier Mac models

Posted on Mar 28, 2024 9:22 PM

Reply
Question marked as Top-ranking reply

Posted on Mar 29, 2024 12:56 PM

Okayyyy never mind. I figured it out. Finally. I guess this will stand as a lonesome thread for anyone else who might bump into this problem.


if you see FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF, that means that somehow the partition's type code got corrupted. To change it back so that it will be recognized, boot into another macOS instance or linux via live usb or something, and use gdisk to change it back. gdisk is available for both platforms.


For mac users and in my case, the initial command would look like

gdisk /dev/disk0

where you may or may not need "sudo" at the beginning.


For linux, it will look a little more something like this:

sudo gdisk /dev/sda


in both instances, you are targeting THE DRIVE, not the partition (silly me)


Then when in gdisk, enter "L" and then search a key phrase for the kind of file system the partition is supposed to be (in my case APFS) and write the 4 character code down.


Then enter "t" in gdisk, enter the number that corresponds to your partition, and then enter the 4 character code.


Then enter "w" to write the changes to your disk.


Then reboot, and your drive should be back!

2 replies
Question marked as Top-ranking reply

Mar 29, 2024 12:56 PM in response to chsiv

Okayyyy never mind. I figured it out. Finally. I guess this will stand as a lonesome thread for anyone else who might bump into this problem.


if you see FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF, that means that somehow the partition's type code got corrupted. To change it back so that it will be recognized, boot into another macOS instance or linux via live usb or something, and use gdisk to change it back. gdisk is available for both platforms.


For mac users and in my case, the initial command would look like

gdisk /dev/disk0

where you may or may not need "sudo" at the beginning.


For linux, it will look a little more something like this:

sudo gdisk /dev/sda


in both instances, you are targeting THE DRIVE, not the partition (silly me)


Then when in gdisk, enter "L" and then search a key phrase for the kind of file system the partition is supposed to be (in my case APFS) and write the 4 character code down.


Then enter "t" in gdisk, enter the number that corresponds to your partition, and then enter the 4 character code.


Then enter "w" to write the changes to your disk.


Then reboot, and your drive should be back!

Mar 29, 2024 8:08 AM in response to chsiv

Additionally, "gpt -r show disk0" returns:

      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  229783920      2  GPT part - FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF
  230193560       1640
  230195200   34523136      3  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
  264718336  225515520      4  GPT part - 0FC63DAF-8483-4722-8E79-3D69D8477DE4
  490233856        863
  490234719         32         Sec GPT table
  490234751          1         Sec GPT header


I have also tried 'asr adjust --target /dev/disk0s2 --settype "Apple_APFS"' but I just get an invalid argument error.


I booted into my linux partition and ran "sudo gdisk /dev/sda2" and got this output:

GPT fdisk (gdisk) version 1.0.8

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries in memory.

Command (? for help): q


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

APFS file system not detected, but fsck_apfs says otherwise

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.