I was trying to install LineageOS on my Nexus 5 by following the steps mentioned in this link. However my phone got stuck in the TWRP bootloop after installing the TWRP as my custom recovery. It kept showing the message: “Failed to mount ‘/data’ (Invalid argument)“.
I also couldn’t boot into the OS. It always got stuck in the TWRP bootloop. I even couldn’t get to see the TWRP menus.
Fortunately I stumbled upon a thread in Reddit. The TS also had the same issue with me. I tried one of the solution suggested in that thread. In my PC terminal I ran the command: “fastboot format userdata“.
Annddd… It worked like a charm! What happened next was I could get into the TWRP menus and continue to install LineageOS. 🙂