Flashing Nexus 5 factory image fails on writing userdata Recently, I purchased a used Nexus 5. I would like perform a full reset, so I’m trying to flash the factory image using Google’s official instructions.

However, I keep getting the message FAILED (remote: 'Bogus size sparse and chunk header') for the Writing 'userdata' step.

Am I doing something wrong, or is something wrong with the instructions or image from Google?

(Possibly) relevant info:


I'm running macOS Mojave 10.14 (18A391) on my computer.
I'm using fastboot from the Android SDK Platform-Tools version 28.0.1, installed using Android Studio 3.2.1.
I tried the two most recent images of Android version 6.0.1 (M4B30X and M4B30Z), both give the same issue.


The full output of the flashing process can be seen here:

$ ./flash-all.sh 
Sending 'bootloader' (3124 KB)                     OKAY [  0.310s]
Writing 'bootloader'                               OKAY [  0.516s]
Finished. Total time: 0.923s
rebooting into bootloader                          OKAY [  0.108s]
Finished. Total time: 0.108s
Sending 'radio' (45489 KB)                         OKAY [  1.640s]
Writing 'radio'                                    OKAY [  3.130s]
Finished. Total time: 4.867s
rebooting into bootloader                          OKAY [  0.104s]
Finished. Total time: 0.104s
extracting android-info.txt (0 MB) to RAM...
--------------------------------------------       
Bootloader Version...: HHZ20h
Baseband Version.....: M8974A-2.0.50.2.30
Serial Number........: ***redacted***
--------------------------------------------       
Checking product                                   OKAY [  0.100s]
Checking version-bootloader                        OKAY [  0.100s]
Checking version-baseband                          OKAY [  0.100s]
extracting boot.img (8 MB) to disk... took 0.037s
archive does not contain 'boot.sig'
archive does not contain 'dtbo.img'
archive does not contain 'dt.img'
archive does not contain 'odm.img'
archive does not contain 'product.img'
archive does not contain 'product-services.img'
extracting recovery.img (9 MB) to disk... took 0.033s
archive does not contain 'recovery.sig'
archive does not contain 'super.img'
extracting system.img (996 MB) to disk... took 7.816s
archive does not contain 'system.sig'
archive does not contain 'vbmeta.img'
archive does not contain 'vendor.img'
mke2fs 1.44.3 (10-July-2018)
Creating filesystem with 7137786 4k blocks and 1785856 inodes
Filesystem UUID: aab8dc10-d114-48a0-b9dc-c7ebdd24c79d
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   

mke2fs 1.44.3 (10-July-2018)
Creating filesystem with 179200 4k blocks and 44832 inodes
Filesystem UUID: 2d2b45ab-678b-43ba-8b3c-83827764dbc8
Superblock backups stored on blocks: 
    32768, 98304, 163840

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

Sending 'boot' (9154 KB)                           OKAY [  0.510s]
Writing 'boot'                                     OKAY [  0.776s]
Sending 'recovery' (10012 KB)                      OKAY [  0.564s]
Writing 'recovery'                                 OKAY [  0.832s]
Sending 'system' (1020665 KB)                      OKAY [ 36.364s]
Writing 'system'                                   OKAY [ 69.147s]
Erasing 'userdata'                                 OKAY [ 14.079s]
Sending 'userdata' (4272 KB)                       OKAY [  0.360s]
Writing 'userdata'                                 FAILED (remote: 'Bogus size sparse and chunk header')
Finished. Total time: 133.541s
I encounter the same problem today :)
flash-all script failed when writing userdata

I have managed to solve this issue by manually continue the flashing process:

1) extract image-hammerhead-m4b30z.zip

2) cd to the extracted folder

3) run the following commands (one by one)
fastboot erase userdata
fastboot flash userdata userdata.img
fastboot erase cache
fastboot flash cache cache.img
fastboot reboot