IMEI has become 0 - how to fix? I was using stock Android Pie with build ALI_PPSS29.55-24-2 on my Moto G6 (ALI, XT1925-13). It was also rooted using Magisk.  After more than an year the performance degradation happened and I thought to do a factory reset using the menu option in Settings.
Do not know why the reset operation did not help and ended up in boot loop.
At this juncture I thought to restore the ALI_PPSS29.55-24-2 ROM image and also thought to install RevengeOS which is Android 10 from XDA.
Flashed the latest TWRP for my phone, copied the downloaded image zip file from the XDA page and installed. All went well but the network was not detected at all. Worried with that, I tried to reach out the telegram group but it did not help.
Left alone, I thought to restore ALI_PPSS29.55-24-2 and successfully returned to Android Pie (9). However the network is not detected. Typing *#06# shows bar code with IMEI as 0.
I now read that I should have backed up the EFS partition which was not known. When the instructions for the installation said to backup, I only backed up my files and not the EFS partition.
Is there any options left? Any help is appreciated. Thanks.
The reason for me to raise this as a new question is that time had moved on and the options/suggestions for other question might not work or might have improved.
FYI: I have the back up of persist folder which I am not sure whether is still intact.
Edit : after &quot;Adb reboot bootloader&quot; I can toggle to &quot;Barcode&quot; option and it displays the IMEI number correctly. Also seen with command &quot;fastboot getvar all&quot; - as said in this XDA forum:

Your IMEI is not lost, it's just sitting there. You can see it in fastboot using &quot;fastboot getvar all&quot; command, and in the &quot;Barcode&quot; in bootloader menu.
Any attempt in writing IMEI via QPST tool is futile, because our device is write protected.


Update: Flashed PPSS29.55-24-2 stock Pie image - all went well except the SIM/network/IMEI
[Solved] I read in many XDA posts that IMEI might not be actually lost by installing custom ROM, but it might be just a case that the permission might have been changed.  To verify, see if the IMEI number is shown in boot loader or bar code screen, if so then this is the case. Since my case is also similar, those posts suggested to flash factory image to restore the IMEI. I am not sure why it did not happen when I tried the same with the version that I already downloaded and have flashed already which is ALI_RETAIL_9.0_PPSS29.55-24-2.
Somehow inexplicably this did not work even though I tried to flash many times.
I stumbled on an XDA post which showed me a repository of factory images of various phones and in my phone case (Moto G6 ALI XT1925-13), I found the latest images from here.
From this site, I downloaded latest ALI_RETAIL_9.0_PPSS29.118-15-11-9 image and flashed which worked.
Edit
The above 118 version had was unstable and tried ALI_RETAIL_9.0_PPSS29.55-37-7-6_cid50_subsidy-DEFAULT_regulatory-DEFAULT_CFC.xml.zip which seems to be okay so far.