[Moto G5 Questions & Answers] Suhsad:
Hi friend,

I installed custom rom 8.1 with twrp 64 bits and it was working fine. then i installed stock rom with fastboot mode and lost my imei.

went back to 8.1 rom and got imei back. I had already taken back up of my stock rom previously. so I though I should try that may be I will get imei back on stock. tried that and got Imei back on stock. everything fne till now.

now I have no 4G and started to fix 4G. flashed some back up found on some form thought may b it will resolve the issue.

restarted and no 4g.

tried to flash stock again and lost imei again.

now tried to flash custom 8.1 still no imei.

went back to back ups still no imei.

tried everything still no imei.

I don't know what happen.

Now lets discuss and fix this issue once for all.

Found some important information about our issue:

Network Related Partitions

modemst1 and modemst2: These partitions appear to contain non-essentials/temporary network related data. Interestingly, they are erased when flashing a stock rom, meaning they are probably not crucial, possibly some kind of ‘baseband cache’?

modem: The modem partition contains modem/baseband related files. These files store store settings that allow the device to communicate with cell towers, such as the frequencies. This partitions is region, not device, specific. This partition is flashed as part of the stock firmware flash procedure, so it also is likely not unique (again ensure to get firmware for the right region).

fsg: This partition also contains files related to the modem firmware/baseband. These files store store settings that allow the device to communicate with cell towers, such as the frequencies. This partitions is region, not device, specific. This partition is flashed as part of the stock firmware flash procedure, so it likely contains non-unique data (but ensure to get firmware for the right region).

Maybe ‘fsg’ and ‘modem’ are related to the modemst1 and modemst2 partitions?

Important/Unique Partitions

pds: This partition likely contains important device specific data like the IMEI, Serial Number, etc. It is important to backup this partition when you get the chance, as people in other threads attribute the loss of the IMEI to this partition. This is not included in stock firmware, reinforcing the importance of backing up this partition.

persist: Apparently this partition contains files related to WiFi, Bluetooth, MAC addresses etc. Nevertheless, it is quite important and should be backed up if possible.

hob and dhob: The exact function is not known, but they appear to contain very important information relating to the modem and/or IMEI.

fsc: Appears to be empty. Although, this partition could sometimes store important IMEI related info. Not included in factory firmware and so best left alone.

IMEI backup/restore scripts (pds partition)

Requirements:

- Device has to be rooted, with USB debugging enabled.

- Motorola fastboot (see attachment).

- ADB installed, minimal or the full ADK.

You can search the forum to find how to meet these requirements or for the terms described in this post beginning here:

http://xdaforums.com/show....php?t=2558638

Installation:

Extract imei_scripts.zip (attached) and copy the scripts "imei_backup.bat" and "imei_flash.bat" into the ADB root directory.

Extract mfastboot_only.zip (attached) and copy "mfastboot.exe" into the ADB root directory.

Description/How to use:

These are batch scripts and can be run by double-clicking them or opening a command window from the ADB root. Help is also contained in the scripts. They are run interactively and won't execute anything without the user selecting a choice.

"imei_backup.bat"

Use this script to backup and restore normally using ADB.

"imei_flash.bat"

Use this script to flash the partition as an alternative to the other method using mfastboot while in bootloader mode. The backup, "pds.img" must be located in the ADB directory for the script to run.

The backup is made on the sdcard and is named "pds.img". You'll want to store this elsewhere once backed up. Once done, that's it! You don't need to do anything more. The purpose is as a preventative in the event of the loss of your IMEI.

Run the scripts for additional options and help.

Sources/Interesting information:

https://xdaforums.com/moto-g/general/motorola-moto-g-partitions-explained-t3418644

https://xdaforums.com/showthread.php?t=2675326

DISCLAIMER: Every information is form internet and xda and I will not be responsible for any loss of data or corrupt phones or sd card. That is, use only at your own risk!

Thanks to eastdata for making scripts.

And Professor Gibbins for providing important info.