How do I recover from a botched adopted storage migration? I can't take pictures or screenshots TL;DR: I messed up. Now my phone won't store pictures because it's probably trying to write to some directory that doesn't exist. How can I fix this? What directory structure is expected? I caused it by maybe screwing up a bit when moving to Adopted Storage, but that may not be important for the answer.



I migrated to adopted storage this morning. I wanted a mixed partitioning, but accidentally got full-card adoption (i used the GUI). As part of that I suppose I migrated the existing /storage/emulated to the adopted storage.

Because I wanted a mixed setup and I had backups of my data, I just ran sm partition ... mixed 25 and nuked the existing adopted storage.

Now I can't take any pictures. If I do a screenshot, it says it couldn't save it. If I take a picture with OpenCamera, it says the same.

I would like to avoid the hassle of factory resetting if it's just a matter of creating some directories and/or creating some symlinks. I tried setting up a symlink /media/expand/&amp;lt;my-adopted-storage&gt;/user -&gt; /storage/emulated and created DCIM (mode 1777) in /storage/emulated/0/DCIM (where it used to be). That doesn't help.

Am I on the right track and just getting the details wrong, or am I screwed?



As you can see from the tags, I'm on CyanogenMod 13 / Android 6 / Marshmallow.



Further investigation:

Looked where OpenCamera is looking, and it's looking at /sdcard/DCIM. /sdcard is a symlink to /storage/self/primary and that's a symlink to /mnt/user/0. Tried creating a symlink to the existing DCIM there, didn't help. Maybe it needs to point to the right place in the system to slip through the security tracks? Trying a reboot and seeing where things end up.

EDIT: It was /sdcard -&gt; /storage/self/primary -&gt; /mnt/user/0/primary. I created /mnt/user/0/primary -&gt; /mnt/expand/*/user/0. No go.



There is a secondary user on the phone. When I switch to that, I get a bunch of "Unfortunately YouTube/Gallery/foo stopped." and I can't run any of the installed apps -- then I get the same message.



I had three SD "Cards" listed in Storage &amp; USB: Purple (successfully adopted), Grey (first adoption, now abandoned, said "not mounted") and sdcard1. I figured that maybe it's still yearning for that unmounted (nonexistent) partition, so I clicked it and chose "Forget". Now sdcard1 is corrupt (!). Will reboot again and see what it makes of it.



Progress! After forgetting that original adoption and rebooting, now we have /sdcard -&gt; /storage/self/primary -&gt; /storage/emulated/0.

/storage/emulated/0 is a FUSE system that seems to have the same size as /data, so things look pretty normal now. I took a screenshot, and /sdcard/Pictures was created.

sdcard1 is back and looks fine.



Now there was a Migrate data command on both Internal storage and the adopted storage. When I clicked it on the adopted storage, emulated/0 was remounted as a FUSE proxy for the adopted storage and screenshots now go there instead of to internal-internal. I think this is like I want it now.
I believe what solved my problem was that I ran Migrate data in the newest adopted storage. Until then the system was in a state where the abandoned adopted storage was the "primary storage", but wasn't present.

I'm not sure why Migrate data on Internal storage wasn't available before I abandoned the first adopted storage. Maybe all I would have had to do was to reboot and the command would have been available.

I am going to move more of the story from the answer to the question, to create a more coherent Q&amp;A picture.