[Nexus 6 Q&A, Help & Troubleshooting] ethanmad:
tl;dr Android OS is missing from my Nexus 6 for an unknown reason, fastboot isn't working (nor is flashing via recovery), /system and /firmware partitions read 0 MB in each. Help!

Context

My Nexus 6 is a replacement I got in the beginning of February after some speaker issues with my original N6. The device was unlocked, encrypted, used TWRP as custom recovery, and rooted (with Chainfire's SuperSU). I was running stock 5.1 (shamu-lmy47d). My root apps were few: AdAway, TitaniumBackup, SuperSU, Solid Explorer, and Cerberus (no account activity with Cerberus in the past two weeks). I'm familiar with fastboot, custom recoveries, flashing, etc. I've been doing this on my Droid X, Nexus 4, Nexus 7, and Nexus 6 for years and never had anything like this happen (nor have I really run into issues I couldn't figure out).

Situation

While using Sync for Reddit, some apps started crashing. Then Sync stopped loading anything. Then seemingly every app on my device reported a crash. Thinking a reboot would fix whatever was going on, I rebooted my phone. The boot animation didn't end after ten minutes, so I shut my phone back off and got into recovery.

I tried rebooting to system from TWRP. The first thing I noticed was that TWRP did not prompt me for a PIN. When I tried rebooting to system, I was greeted with the following message: "No OS installed! Are you sure you wish to reboot?". Confused, I went to the backup page to check partition sizes. TWRP showed "System (0MB)", "Data (56975MB)" (that's 57GB--I probably had 20GB maximum).

TWRP logs read as follows:

Data successfully decrypted, new block device '/dev/block/dm-0'
Updating partition details...
[COLOR="Red"]E:Unable to mount '/system'
E:Unable to mount '/firmware'[/COLOR]
...done
[COLOR="red"]E:Unable to mount storage[/COLOR]
Successfully decrypted with default password.
Updating partition details...
[COLOR="Red"]E:Unable to mount '/system'
E:Unable to mount '/firmware'[/COLOR]
...done
[COLOR="red"]E:Unable to mount storage.
E:Unable to mount /data/media during GUI startup.[/COLOR]
Full SELinux support is present.
[COLOR="red"]E:TWFunc::Copy_Log -- Can't open destination log file: '/cache/recovery/log'
E:Unable to mount /data/media/TWRP/.twrps when trying to read settings file.
E:Unable to open '/cache/recovery/.version'.
E:Unable to mount '/data'[/COLOR]
MTP Enabled

A factory reset from TWRP returns the following:

Factory Reset Complete
[COLOR="red"]Failed[/COLOR]

and in the log:

[COLOR="red"]E:Unable to mount '/data'
E: Unknown MTP message type: 1[/COLOR]
Formatting Cache using make_ext4fs function.
[COLOR="red"]E:Unable to mount '/cache'[/COLOR]
Updating partition details...
[COLOR="red"]E:unable to mount '/system'
E:Unable to mount '/cache'
E:Unable to mount '/firmware'[/COLOR]
...done
[COLOR="red"]E:Unable to mount storage.[/COLOR]

I will now post the results of several fastboot commands. Some analysis will follow at the end of this post, but I don't really have a clue as to what is going on.

$ fastboot flash system system.img
target reported max download size of 536870912 bytes
sending sparse 'system' (522112 KB)...
OKAY [ 17.483s]
writing 'system'...
OKAY [ 8.162s]
sending sparse 'system' (510197 KB)...
OKAY [ 17.036s]
writing 'system'...
OKAY [ 7.362s]
sending sparse 'system' (515601 KB)...
OKAY [ 17.891s]
writing 'system'...
OKAY [ 8.047s]
sending sparse 'system' (188485 KB)...
OKAY [ 6.661s]
writing 'system'...
(bootloader) Failed to flash sparse image
FAILED (remote failure)
finished. total time: 94.184s

$ ./flash-all.sh
target reported max download size of 536870912 bytes
sending 'bootloader' (3807 KB)...
OKAY [ 0.120s]
writing 'bootloader'...
(bootloader) flashing partition ...
(bootloader) This may take a few seconds if a
(bootloader) different partition table is being
(bootloader) flashed since we need to backup
(bootloader) and restore a few partitions
(bootloader) Flashing primary GPT image...
(bootloader) Failed to write primary GPT.

(bootloader) Failed to flash partition
FAILED (remote failure)
finished. total time: 6.105s
rebooting into bootloader...
OKAY [ 0.001s]
finished. total time: 0.001s
target reported max download size of 536870912 bytes
sending 'radio' (85422 KB)...
OKAY [ 2.676s]
writing 'radio'...
(bootloader) flashing modem ...
(bootloader) Failed to erase partition
(bootloader) Failed to flash modem
FAILED (remote failure)
finished. total time: 13.678s
rebooting into bootloader...
OKAY [ 0.001s]
finished. total time: 0.001s
archive does not contain 'boot.sig'
archive does not contain 'recovery.sig'
archive does not contain 'system.sig'
--------------------------------------------
Bootloader Version...: moto-apq8084-71.08
Baseband Version.....: D4.0-9625-02.95
Serial Number........: ZX1G322CNQ
--------------------------------------------
checking product...
OKAY [ 0.002s]
checking version-bootloader...
OKAY [ 0.002s]
checking version-baseband...
OKAY [ 0.003s]
sending 'boot' (7681 KB)...
OKAY [ 0.243s]
writing 'boot'...
(bootloader) Failed to flash partition boot

(bootloader) Failed to flash partition boot
FAILED (remote failure)

$ fastboot oem lock
...
(bootloader) Failed to erase partition
(bootloader) General Lock failure!
(bootloader) sst lock failure!
FAILED (remote failure)
finished. total time: 11.836s

$ fastboot -w
erasing 'userdata'...
(bootloader) Failed to erase partition
FAILED (remote failure)
finished. total time: 5.758s

$ fastboot format system
formatting 'system' partition...
Formatting is not supported for filesystem with type 'raw'.
FAILED ()
finished. total time: 0.002s

I'll try any suggested commands as nothing appears to be working anyways. At this point, I don't care about my data. It's encrypted anyways, so it's probably unrecoverable regardless of if I get my phone working again.

I think the partition table somehow got destroyed or the flash memory failed. What's curious is that /data, /boot, /recovery, /EFS are still intact while /firmware and /system are not. I blame hardware because the issues started while the OS was booted (what on the OS level has permissions to write to /system and /firmware?) and nothing writes to the partitions anymore (they can't even be mounted!).

I'm looking for help in any way, especially the in the following:

(1): Finding the cause of this issue and squashing it if it's a bug in Android, TWRP, or some other software.

(2): Getting my phone back to a working state. Again, I don't care about the data on the device.

(3): (if 2 fails) getting my phone locked and removing TWRP so that I can RMA it--Google has already offered a replacement, but I don't want to send it in unlocked and with TWRP (may cause them to charge me for the replacement)​

If this is indeed a software-caused error (again, I don't think my actions of using Sync for Reddit caused this issue), I'm terrified that this may affect others who are less capable of seeking help, or those who have critical data on their devices.

Thanks for reading. Please offer any guidance you may have.

-Ethan