[Moto G Q&A, Help & Troubleshooting] FergusL:
Hi everyone, thanks for the awesome place that XDA is!

As the title suggests I'm into a bit of trouble with my XT1039! (Moto G 4G 2nd gen/peregrine)

I had previously been running AOSP Extended and then Lineage 14.1 by MSe1969 without too much issues for 1-2 years.

Every app started crashing on my phone, I rebooted thinking it was just a temporary issue.

When I realized it wouldn't boot again I set to flash a newer version of the Lineage ROM and here starts the fun.

I did a more-than-what's-necessary wipe to get rid of any serious issue, I didn't mind losing anything I had on the phone.

The zip install would then not work, log:

BLKDISCARD ioctl failed: I/O error
failed to execute command [erase 6,70603,97792,131586,163328,197122,228864]
script aborted: E1001: Failed to update system image.
E1001: Failed to update system image.
error: 1001
Updater process ended with ERROR: 7

Only after this first issue did I realize what really was wrong:

The wipe had not had any effect at all, even though not showing any error.

I tried updating TWRP to 3.5.9 using Install > Install images and then "fastboot flash" which also didn't show any error yet had no effect at all, I was back to 3.3.1 after that. The only way I just found to run TWRP 3.5.9 is with "fastboot boot twrp....img" though I don't think that makes the situation any different?

The whole system is locked on read-only and the various operations as well as dmesg show error on the internal mmcblk0 although not as bad as what I've seen on other threads. This looks similar: https://xdaforums.com/t/my-xt1039-lte-is-soft-bricked-please-help.3595044/ although we don't get to see any log.

Log during wipe shows about 20k lines like this one, presumably one for every file despite resulting success:

I:Unable to unlink '/data/misc/bluedroid/bt_config.bak': Read-only file system

Relevant part of dmesg from boot:

<3>[ 44.781618,0] mmcblk0: error -110 transferring data, sector 2670487, nr 1, cmd response 0x900, card status 0x0
<3>[ 44.783137,0] end_request: I/O error, dev mmcblk0, sector 2670487
<2>[ 44.784164,0] EXT4-fs error (device mmcblk0p34): ext4_find_entry:941: inode #1759: comm recovery: reading directory lblock 0
<3>[ 44.784379,0] Aborting journal on device mmcblk0p34-8.
<2>[ 44.784988,0] EXT4-fs (mmcblk0p34): Remounting filesystem read-only
<2>[ 44.785980,0] EXT4-fs error (device mmcblk0p34): ext4_put_super:844: Couldn't clean up the journal

Output of mount command:

# mount
rootfs on / type rootfs (rw,seclabel)
tmpfs on /dev type tmpfs (rw,seclabel,nosuid,relatime,size=440132k,nr_inodes=110033,mode=755)
devpts on /dev/pts type devpts (rw,seclabel,relatime,mode=600)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,seclabel,relatime)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
tmpfs on /tmp type tmpfs (rw,seclabel,relatime,size=440132k,nr_inodes=110033)
/dev/block/mmcblk0p33 on /cache type ext4 (rw,seclabel,relatime,data=ordered)
/dev/block/mmcblk0p36 on /data type f2fs (ro,seclabel,relatime,background_gc=off,user_xattr,inline_xattr,acl,inline_data,active_logs=6)
/dev/block/mmcblk0p36 on /sdcard type f2fs (ro,seclabel,relatime,background_gc=off,user_xattr,inline_xattr,acl,inline_data,active_logs=6)
/dev/block/mmcblk1p1 on /sdcard1 type vfat (rw,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)

Log for "Format data" operation which I also tried several times:

Info: zone aligned segment0 blkaddr: 512
Info: format version with
"Linux version 3.4.42-g5e5969d-dirty (luca@luca020400-arch) (gcc version 4.9.x-google 20140827 (prerelease) (GCC) ) #1 SMP PREEMPT Sun Feb 7 22:11:19 CET 2016"
Error: Could not conduct fsync!!!
Info: format successful
I:mkfs.f2fs -t 0 /dev/block/mmcblk0p36 process ended with RC=0
Done.
I:mount -o bind '/data/media/0' '/sdcard' process ended with RC=0
You may need to reboot recovery to be able to use /data again.
Updating partition details...
I:Data backup size is 3927MB, free: 1191MB.

This would be enough indications to declare the internal ROM dead if I could have at least found one other thread with the same issue, and it doesn't look as bad as what I've seen during my search.

Googling has resulted in extremely few results for the specific errors reported (Could not conduct fsync or BLKDISCARD for example) as they are either non-android specific or very rare.

Would it be worth it to try to flash from fastboot?

I've seen it advised here and there, I'd be more than happy if I could be pointed to useful documentation on the process.