[One (M8) Q&A, Help & Troubleshooting] syntropic:
I recently had a problem where I had to do a factory restore on a non-bootable phone... and my only option was to use adb shell to copy the extracted stock lollipop nandroid files to the TWRP folder in internal storage [there may have been other ways, but I was not aware of one.]. Thanks to 3484jacks, thebobmannh, ckpv5, and redpoint73. I hope I didn't forget anyone.

OK.. so that worked... but it was very messy. Why? Because my first (and obvious) choice was to create the subfolder under TWRP and then adb push the files to that folder.

The folder I am referring to is the "root" folder of internal storage, also called the /sdcard/. It usually has other directories/folders such as .data, Android, Ringtones and/or Media.... I am sure you know what I am referring to. And on this "root" of the internal storage (sdcard) is the TWRP folder which contains backups. The path to the backups is sdcard/TWRP/BACKUPS/{device serial number}/name-date of backup.

However, when I did an adb push to the above folder, by using the following command:

adb push c:/nandroid/ /sdcard/ TWRP/BACKUPS/FXXXXX/nandroid (<<==I had already created the nandroid folder as you cannot push an entire folder to your phone; only the files contained therein will be pushed over)

....my files did not end up in /sdcard/TWRP/BACKUPS/FXXXXX/nandroid. Instead they were copied to /sdcard/storage/TWRP/BACKUPS/FXXXXX/nandroid. For some reason when pushing to the sdcard, adb pushes it to a subfolder called storage. I am not sure why this is... perhaps it is because we really are not talking about a physical sdcard, but rather internal storage. In any event, to fix my phone I had to use adb shell and I copied all of the nandroid files from /sdcard/storage/TWRP/{. . .} to /sdcard/TWRP/{ . . .}.

If you are in the true root (system) directory, there are several paths which lead to "internal storage"... and I want to know if anyone has any clue why there are multiple paths and what they mean. Below are the multiple paths from the system directory to internal storage:

(root)/storage/emulated/0/

(root)/storage/emulated/legacy/

(root)/storage/sdcard/

(root)/sdcard/

All of above paths lead to the exact same place (or so it seems)...a place which very much appears like internal storage.

However, I have run into this weird creation of a storage folder on the sdcard (internal storage) before. Several months ago, I copied via USB my entire sdcard to my Windows desktop. Oddly, several folders that I would have expected to be on the sdcard (as they are when viewing with Root Explorer) were not there. When inspecting what I had copied to my desktop, I found that the Download folder and 4 or 5 other folders, ended up in a "/(sdcard)/storage" sub-folder. EXACTLY like what happened to me yesterday (but kind of in reverse as I was copying TO the sdcard)

So that is my first question... Why does this happen? What is emulated? what is the difference between (root)/storage/emulated/0/ and (root)/storage/emulated/legacy/????

My next question, very intimately related to the above, is more of a problem.

The nandroid files I referred to above which I had initially pushed to the sdcard whereupon they ended up in the storage subfolder are still there. And whether I use Root explorer or adb shell, I get a "DELETE FAILED" or "PERMISSION DENIED" error respectively. And in case you are wondering, I did a 'su -' in adb shell before I attempted this. I had to grant access to SuperSU as a toast came up asking for the root rights.

Strange....I never thought internal storage had permissions, but I guess they do.

So the big question...and a solution to getting rid of the mess of files which are taking up several GBs of space on my sdcard (internal storage)... how do I delete the /storage/ folder on my sdcard? The folder was not there before.

Even if I drill down to the individual files (either in adb shell or root explorer) I still get a PERMISSION DENIED.

Please help. NOTE: I thought about reformatting the partition... but what guarantee will I have if I try to push my backed up sdcard data BACK to internal storage?? I probably can make sure that I delete the problematic nandroid files above by deleting them first in Windows, but that doesn't mean my sdcard won't still have another storage subfolder create.... and who knows what will be in it? [and this is the genesis behind my asking the first questions above about internal storage, the "emulated" name in the path, and the multiple paths from the system folder. I figured if I understood what was going on, I would be more likely to fix it.]

Thank you in advance for any assistance!!!