Can't resize macOS partition (APFS error code 49187)

I'm unable to shrink my APFS macOS partition in Disk Utility or by using diskutil. When I try with either method, I receive error code 49187. There appears to be no reference for these codes and I can't find any information online. I have tried deleting Time Machine snapshots and that made no difference. First Aid on my disk reveals some kind of corruption in the partition map:

enter image description here

I tried what it said and First Aid only lets me scan my macOS partition in Recovery Mode. Using diskutil gives me Error starting file system repair for disk0: Invalid request (-69886).

Is there any way to fix this? I'm trying to add a FAT32 partition to my disk.

This is on macOS 10.13.3.


Solution 1:

I solved this error for myself by the following steps, (to be sure I included all)

  • Time Machine snapshot delete fix
  • Decrypt harddrive from filevault

This resulted in the persistence of the error. But then I booted in recovery mode (reboot and hold cmd+R) and started the disk utility there. To my surprise the Disk Utility showed me different values for the free space of my partition. I only had 20g free instead of the 50g I tried to allocate each time.

When I did the normal partition steps in the recovery boot Disk Utility everything went fine and I am currently running Ubuntu 18.04.1 alongside Mojave 10.14.1 without problems, be it that I only have 20g.

Solution 2:

I experienced the same error code, 49187. Below is some background context from my situation and my resolution at the end.

I had re-imaged a MacBook Air as a dev machine and forgot that I wanted to partition the drive.

I, too, ensured file encryption and Time Machine were not active (and used tmutil to thin snapshots) but still experienced the same partition error as the OP. I then took the scorched earth approach; I was going to re-format entirely. I first ensured I had a Mojave installer on a USB thumb drive (using DiskMaker X) then rebooted into recovery mode (Cmd-R).

There, I started Disk Utility to erase and partition. In fact, it failed there as well. After it failed, it showed used file space of roughly 1gig and 75gig of 'other' (which is actually the size of the partition I attempted to add).

The resolution, fortunately, was at hand. I was able to Unmount the APFS drive and actually erase/re-format it with APFS and then create the additional partition.

I am not exactly sure why this worked. When I looked at my drive initially in Disk Utility, it said that it was shared by 4 volumes although I hadn't partitioned anything myself. Once I unmounted and erased the entire drive in Recovery Mode, it showed as One Volume. I wonder if any recovery volume(s) added during High Sierra or Mojave's install prevented APFS partitioning to take effect.

Solution 3:

My solution was trying a smaller second partition size. Disk Utility said the space was free but I guess it really isn't.

Solution 4:

I managed to solve the problem.

Error code 49187 appears to be an internal error in the structure of the APFS that occurred during the file system installation.

I couldn't find a solution to fix it, so I could only recover the following steps:

#Step 1: I made a Time Machine backup (otherwise I just updated my existing one)

#Step 2: I restarted the computer and selected the installation option from the USB installer

#Step 3: I then run the following command in the terminal to list the disks:

diskutil list

(The terminal can be found as a menu item once the installer boots)

#Step 4: I selected the disk on which the macOS is installed (in this case, this was "disk1")

#Step 5: Then I ran the following command (To convert an APFS container into a free space, you must first delete the container):

diskutil apfs deleteContainer disk1

#Step 6: Then restore the system using Time Machine

After restoring the system, I was able to partition without problems.

If Boot Camp Assistant fails trying to partition a Mojave OSX volume after a clean install, giving an unhelpful message to run Disk Utility (which finds no problem), it is a "silent" 49187 error. Seems to be triggered by a Bootcamp partition that is much larger than the OSX partition. Confirmation comes by trying to create partitions with the same size in Disk Utility, which reports the 49187 error. This Time Machine backup/wipe/restore procedure cures the silent 49187 error and lets Boot Camp Assistant perform the partition. enter image description here