Thursday, November 21, 2024

disk utility – Unable to mount/unlock encrypted APFS volume

I have an external disk that’s APFS-encrypted which suddenly won’t mount/unlock:

$ diskutil apfs unlockVolume /dev/disk7s1 -nomount
Passphrase:
Unlocking any cryptographic user on APFS Volume disk7s1
Passphrase incorrect or user does not exist

I also can’t modify the APFS container from Disk Utility to add any new volumes.
I thought maybe corruption had led to my password no longer unlocking the files, but I downloaded DiskDrill, supplied it with my password and let it scan for files and it actually found them!

I’m wondering if that means the partition table is messed up or something, because obviously the passphrase is still decrypting the files. I don’t have enough disk space on hand to recover these files and re-create the APFS volume right now – any help would be appreciated. I’ve tried to interpret these hex dumps using GPT header and table lookup information but I’m not making much progress.

Edit 1: I’ve added fsck_apfs output, and I think the issue is the space manager data in the container, not the volume itself. I would be happy to roll this container back to a different, healthier checkpoint but I’m not sure how.

Diskutil

$ diskutil list
[...]
/dev/disk6 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk6
   1:                        EFI EFI                     209.7 MB   disk6s1
   2:                 Apple_APFS Container disk7         1.0 TB     disk6s2

/dev/disk7 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +1.0 TB     disk7
                                 Physical Store disk6s2
   1:                APFS Volume Storage                 419.8 GB   disk7s1

GPT

$ sudo gpt -r show disk7
       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  1954135984      2  GPT part - 7C3457EF-0000-11AA-AA11-00306543ECAC
  1954545624           7         
  1954545631          32         Sec GPT table
  1954545663           1         Sec GPT header

GPT Header

$ sudo dd if=/dev/disk6 bs=512 count=1 skip=1 | hexdump -Cv

00000000  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00  |EFI PART....\...|
00000010  05 ac dd 9f 00 00 00 00  01 00 00 00 00 00 00 00  |................|
00000020  ff ff 7f 74 00 00 00 00  22 00 00 00 00 00 00 00  |...t....".......|
00000030  de ff 7f 74 00 00 00 00  86 e8 09 f7 47 a3 31 48  |...t........G.1H|
00000040  ab b1 17 2f 5e b4 24 6e  02 00 00 00 00 00 00 00  |.../^.$n........|
00000050  80 00 00 00 80 00 00 00  2b 1a b5 ae 00 00 00 00  |........+.......|
00000060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000080  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000090  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000100  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000110  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000120  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000130  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000140  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000150  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000160  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000170  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000180  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000190  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000200

GPT Table

$ sudo dd if=/dev/disk6 bs=512 count=1 skip=2 | hexdump -Cv

00000000  28 73 2a c1 1f f8 d2 11  ba 4b 00 a0 c9 3e c9 3b  |(s*......K...>.;|
00000010  27 f8 f8 1b af 49 81 44  99 e7 32 45 65 64 2b ee  |'....I.D..2Eed+.|
00000020  28 00 00 00 00 00 00 00  27 40 06 00 00 00 00 00  |(.......'@......|
00000030  00 00 00 00 00 00 00 00  45 00 46 00 49 00 20 00  |........E.F.I. .|
00000040  53 00 79 00 73 00 74 00  65 00 6d 00 20 00 50 00  |S.y.s.t.e.m. .P.|
00000050  61 00 72 00 74 00 69 00  74 00 69 00 6f 00 6e 00  |a.r.t.i.t.i.o.n.|
00000060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000080  ef 57 34 7c 00 00 aa 11  aa 11 00 30 65 43 ec ac  |.W4|.......0eC..|
00000090  c1 c6 8d 57 81 82 e9 4c  a3 7d fa d0 2f b7 bd 74  |...W...L.}../..t|
000000a0  28 40 06 00 00 00 00 00  d7 ff 7f 74 00 00 00 00  |(@.........t....|
000000b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000100  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000110  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000120  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000130  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000140  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000150  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000160  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000170  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000180  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000190  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000200

GPT Partition 1

$ sudo dd if=/dev/disk6 bs=512 count=1 skip=40 | hexdump -Cv

00000000  eb 58 90 42 53 44 20 20  34 2e 34 00 02 01 20 00  |.X.BSD  4.4... .|
00000010  02 00 00 00 00 f0 00 00  20 00 10 00 00 00 00 00  |........ .......|
00000020  00 40 06 00 4f 0c 00 00  00 00 00 00 02 00 00 00  |[email protected]...........|
00000030  01 00 06 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000040  00 00 29 ed 17 e3 67 45  46 49 20 20 20 20 20 20  |..)...gEFI      |
00000050  20 20 46 41 54 33 32 20  20 20 fa 31 c0 8e d0 bc  |  FAT32   .1....|
00000060  00 7c fb 8e d8 e8 00 00  5e 83 c6 19 bb 07 00 fc  |.|......^.......|
00000070  ac 84 c0 74 06 b4 0e cd  10 eb f5 30 e4 cd 16 cd  |...t.......0....|
00000080  19 0d 0a 4e 6f 6e 2d 73  79 73 74 65 6d 20 64 69  |...Non-system di|
00000090  73 6b 0d 0a 50 72 65 73  73 20 61 6e 79 20 6b 65  |sk..Press any ke|
000000a0  79 20 74 6f 20 72 65 62  6f 6f 74 0d 0a 00 00 00  |y to reboot.....|
000000b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000100  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000110  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000120  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000130  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000140  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000150  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000160  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000170  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000180  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000190  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200

GPT Partition 2

$ sudo dd if=/dev/disk6 bs=512 count=1 skip=409640 | hexdump -Cv

00000000  65 f1 69 6d 45 1d 32 73  01 00 00 00 00 00 00 00  |e.imE.2s........|
00000010  a8 94 00 00 00 00 00 00  01 00 00 80 00 00 00 00  |................|
00000020  4e 58 53 42 00 10 00 00  f6 37 8f 0e 00 00 00 00  |NXSB.....7......|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000040  02 00 00 00 00 00 00 00  a6 87 6e b0 9d 7a 46 9f  |..........n..zF.|
00000050  9f da 0f e9 af ae 73 d2  76 de 00 00 00 00 00 00  |......s.v.......|
00000060  a9 94 00 00 00 00 00 00  18 01 00 00 5c 6c 00 00  |............\l..|
00000070  01 00 00 00 00 00 00 00  19 01 00 00 00 00 00 00  |................|
00000080  0d 01 00 00 85 16 00 00  0b 01 00 00 02 00 00 00  |................|
00000090  79 16 00 00 0c 00 00 00  00 04 00 00 00 00 00 00  |y...............|
000000a0  f7 a5 11 00 00 00 00 00  01 04 00 00 00 00 00 00  |................|
000000b0  00 00 00 00 64 00 00 00  02 04 00 00 00 00 00 00  |....d...........|
000000c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000100  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000110  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000120  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000130  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000140  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000150  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000160  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000170  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000180  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000190  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000200

fsck_apfs output

$ sudo fsck_apfs -F -n /dev/disk6s2
** Checking the container superblock.
   Checking the checkpoint with transaction ID 38056.
** Checking the space manager.
warning: spaceman chunk 50 free count 1048041 > block count 32768
warning: spaceman chunk 76 free count 1047379 > block count 32768
warning: spaceman chunk 77 free count 1045263 > block count 32768
warning: spaceman chunk 81 free count 1047089 > block count 32768
warning: spaceman chunk 88 free count 1046859 > block count 32768
warning: spaceman chunk 95 free count 1048285 > block count 32768
warning: spaceman chunk 96 free count 1045846 > block count 32768
warning: spaceman chunk 106 free count 1038642 > block count 32768
warning: spaceman chunk 107 free count 1047917 > block count 32768
warning: spaceman chunk 108 free count 1048545 > block count 32768
warning: spaceman chunk 118 free count 1042009 > block count 32768
warning: spaceman chunk 120 free count 1047762 > block count 32768
warning: spaceman chunk 121 free count 1044764 > block count 32768
warning: spaceman chunk 159 free count 1043537 > block count 32768
warning: spaceman chunk 192 free count 1048119 > block count 32768
warning: spaceman chunk 197 free count 1047955 > block count 32768
warning: spaceman chunk 198 free count 1031491 > block count 32768
warning: spaceman chunk 214 free count 1020054 > block count 32768
warning: spaceman chunk 220 free count 1045881 > block count 32768
warning: spaceman chunk 234 free count 1046468 > block count 32768
warning: spaceman chunk 257 free count 1048280 > block count 32768
warning: spaceman chunk 270 free count 1045917 > block count 32768
warning: spaceman chunk 280 free count 1048521 > block count 32768
warning: spaceman chunk 288 free count 1047651 > block count 32768
warning: spaceman chunk 289 free count 1044620 > block count 32768
warning: spaceman chunk 294 free count 1046582 > block count 32768
warning: spaceman chunk 304 free count 1037560 > block count 32768
warning: spaceman chunk 305 free count 1047826 > block count 32768
warning: spaceman chunk 328 free count 1048515 > block count 32768
warning: spaceman chunk 330 free count 1045119 > block count 32768
warning: spaceman chunk 333 free count 1046817 > block count 32768
warning: spaceman chunk 334 free count 1047085 > block count 32768
warning: spaceman chunk 335 free count 1047577 > block count 32768
warning: spaceman chunk 336 free count 1037524 > block count 32768
warning: spaceman chunk 338 free count 1047719 > block count 32768
warning: spaceman chunk 342 free count 1047582 > block count 32768
warning: spaceman chunk 345 free count 1048065 > block count 32768
warning: spaceman chunk 348 free count 1046590 > block count 32768
warning: spaceman chunk 351 free count 1048000 > block count 32768
warning: spaceman chunk 354 free count 1048325 > block count 32768
warning: spaceman chunk 359 free count 1047571 > block count 32768
warning: spaceman chunk 360 free count 1048574 > block count 32768
warning: spaceman chunk 362 free count 1045869 > block count 32768
warning: spaceman chunk 364 free count 1023077 > block count 32768
warning: spaceman chunk 366 free count 1047638 > block count 32768
warning: spaceman chunk 368 free count 1047692 > block count 32768
warning: spaceman chunk 370 free count 1047439 > block count 32768
warning: spaceman chunk 373 free count 1048521 > block count 32768
warning: spaceman chunk 376 free count 1044611 > block count 32768
warning: spaceman chunk 379 free count 1039521 > block count 32768
Too many warnings of this type generated; suppressing subsequent ones.
warning: (oid 0x6f84) cib: invalid o_cksum (0xffffffffffffffff)
error: failed to read spaceman cib 27 at address 0x6f84
   Space manager is invalid.
** The container /dev/disk6s2 could not be verified completely.

Related Articles

Latest Articles