[Fixed] Fastboot error: mke2fs failed, Cannot generate image for userdata

While flashing the factory images of our Nexus devices, we get the Fastboot error: mke2fs failed, Cannot generate image for userdata. Or, in detail –

Couldn't parse erase-block-size '0x'.
Couldn't parse logical-block-size '0x'.
mke2fs 1.44.6 (5-Mar-2019)
/tmp/TemporaryFile-HqqlrY: Unimplemented ext2 library function while setting up superblock
/usr/lib/android-sdk/platform-tools/mke2fs failed with status 1
mke2fs failed: 1
error: Cannot generate image for userdata

Remove “-w” from the fastboot update command

In flash-all.sh script file, you must have noticed few line of code resembling –

fastboot oem unlock
fastboot erase boot
fastboot erase cache
fastboot erase recovery
fastboot erase system
fastboot erase userdata
fastboot flash bootloader bootloader-grouper-4.23.img
fastboot reboot-bootloader
sleep 10
fastboot -w update image-nakasi-ktu84p.zip

All you have to do is – remove “-w” option from the last line. Then save the script and execute it again.

fastboot update image-nakasi-ktu84p.zip

Fastboot is basically a command line utility which is used for flashing and booting Android devices. Here, “-w” option is used to erase both cache as well as user data. The utility option can format the partition type too. Since, the commands for erasing user data and cache (i.e. fastboot erase cache and fastboot erase userdata) are already present in our script file. So, apart from formatting the partition (of supported type) there is nothing more the “-w” option does. In that scenario, we can safely ignore the option.

For man page of fastboot –

man fastboot

Scroll down the man page of fastboot to get yourself acquainted with more options. Or, you could simple run the following in terminal –

fastboot help

In conclusion, Fastboot error: mke2fs failed, Cannot generate image for userdata could be resolved by removing the “-w” option from the fastboot update command line section provided with the script.