• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!
  • Fill out your device list and let everyone know which phones you have!    Edit Your Device Inventory

Fix Persist, resolve IMEI=0, Volte, 4G, Explanation, Requirements

Search This thread

nathanielsametz

Senior Member
Apr 18, 2011
78
11
Melbourne
THANK YOU @NZedPred !!!!!

I was not ever aware of needing to backup the /persist partition (or that it even existed for that matter) !! Been backing up my EFS for a couple years but never persist until I flashed the newest Havoc 4.1 - trying out Android 11 - and that pretty much broke my device... no signal or camera :(

With your older guides and help from yourself and others on this forum I've managed to resurrect my G5+ and use Havoc 3.12 with 4G and my camera ! Huzzah !

Seriously, I cannot thank you enough. Really appreciate all the work you've done for people on this forum and the patience you hold too.

Cheers

All the best
 

Trebleuser

New member
Mar 1, 2021
4
0
Moto G8 Plus
Could anyone please help me fix my problem, I wrote fastboot erase all and my phone got hard bricked and later using edl mode I flashed the original rom but my imei was destroyed and while booting the phone at the top left corner it shows (invalid persist found , flash it with caution ) and it booted into system and the sim doesn't gets detected and gets stopped every 10 seconds

Phone model :- moto G8 plus
Android :- 10

Thanks in advance :) if u could fix😖
 

zfk110

Senior Member
Jan 11, 2014
1,014
200
Atlanta
Also I should also clarify that I recommend TWRP only because you get a nice gui, and for novices entering dd commands with root privileges carries a high level of risk.

My IMEI still Zero


hannah:/ # ls -l /persist
total 228
drwxrwx--- 2 system system 4096 1969-12-31 19:01 alarm
drwxr-xr-x 2 mot_pwric mot_pwric 4096 2019-01-28 22:32 batt_health
drwxrwx--- 2 bluetooth bluetooth 4096 1969-12-31 19:01 bluetooth
drwx------ 2 root system 4096 1969-12-31 19:01 bms
drwxr-xr-x 2 mot_tcmd bluetooth 4096 1969-12-31 19:01 bt
drwxr-xr-x 5 mot_tcmd mot_tcmd 4096 2019-01-28 22:32 camera
drwxrwx--- 2 system system 4096 2019-01-28 22:32 chargeonly
drwx------ 6 system system 4096 2021-03-13 14:00 data
drwxrwx--- 2 system graphics 4096 1969-12-31 19:01 display
drwxrwx--- 2 system system 4096 1969-12-31 19:01 drm
drwxrwx--- 2 system system 4096 1969-12-31 19:01 egis
drwxr-xr-x 5 mot_tcmd mot_tcmd 4096 2019-01-28 22:32 factory
drwxrwx--- 3 rfs rfs_shared 4096 2019-01-28 22:32 hlos_rfs
drwx------ 2 root root 16384 2019-01-28 22:32 lost+found
drwxrwx--- 2 radio radio 4096 2019-01-28 22:32 mdm
drwxrwx--- 2 system system 4096 1969-12-31 19:01 misc
drwxrws--- 2 mot_tcmd mot_tcmd 4096 1969-12-31 19:01 paks
drwxr-xr-x 12 mot_tcmd mot_tcmd 4096 2019-01-28 22:32 public
drwx--x--x 6 rfs rfs 4096 2019-01-28 22:32 rfs
drwx------ 2 root root 4096 1969-12-31 19:01 sds
drwxrwx--- 2 system system 4096 1969-12-31 19:01 secnvm
drwxrws--- 2 drmrpc drmrpc 4096 2019-01-28 22:32 security
drwxrwxr-x 3 system system 4096 2019-01-28 22:32 sensors
drwxrwx--- 2 system system 4096 2019-01-28 22:32 time
drwxrwx--- 2 media media 4096 1969-12-31 19:01 vpp
drwxr-xr-x 2 mot_tcmd mot_tcmd 4096 1969-12-31 19:01 wifi
drwxrwxr-x 2 mot_drm mot_drm 4096 1969-12-31 19:01 wmdrm


hannah:/ # find /persist -type f
/persist/time/ats_1
/persist/time/ats_12
/persist/time/ats_13
/persist/time/ats_2
/persist/time/ats_15
/persist/time/ats_16
/persist/factory/fti
/persist/factory/audio/tas2560_calib_q
/persist/factory/audio/tas2560_calib_rdc
/persist/factory/audio/tas2560_calib_f0
/persist/chargeonly/cooldown
/persist/rfs/msm/mpss/dhob_report.txt
/persist/rfs/msm/mpss/server_check.txt
/persist/rfs/msm/mpss/datablock/id_00
/persist/rfs/msm/mpss/dhob.bin
/persist/rfs/msm/mpss/hob_report.txt
/persist/rfs/msm/mpss/shob.bin
/persist/rfs/shared/server_info.txt
/persist/mdm/oma_dm_update
/persist/sensors/sns.reg
/persist/sensors/sensors_settings
/persist/.twrps
/persist/camera/focus/offset_cal
/persist/batt_health/age
/persist/public/hiddenmenu/life_timer
/persist/public/hiddenmenu/life_calls
/persist/public/hiddenmenu/data/wifi_data_rx
/persist/public/hiddenmenu/data/mobile_data_tx
/persist/public/hiddenmenu/data/wifi_data_tx
/persist/public/hiddenmenu/data/activation_date
/persist/public/hiddenmenu/data/factoryreset_time
/persist/public/hiddenmenu/data/mobile_data_rx
/persist/security/18.bin
/persist/data/keymaster64/AV60gZa+HxaDg5sGFDqWHF4Z68Mn5PRa6OLOjgcp3b
/persist/data/keymaster64/AaTj3Jywsoo2QVLk0z6r4bz+hSyR9VJufoU-J0hLmP.bak
/persist/data/keymaster64/AV60gZa+HxaDg5sGFDqWHF4Z68Mn5PRa6OLOjgcp3b.bak
/persist/data/keymaster64/AaTj3Jywsoo2QVLk0z6r4bz+hSyR9VJufoU-J0hLmP
/persist/data/prov/3920+2M5Az5BCwjSQLYY9vKq-ya3GzmVKvprOa6+4w.bak
/persist/data/prov/3920+2M5Az5BCwjSQLYY9vKq-ya3GzmVKvprOa6+4w
/persist/data/prov/EDR3WRY5bxjGs1OwA6WM1PwcwQF3sM9a7gdKB2PF2r
/persist/data/prov/EDR3WRY5bxjGs1OwA6WM1PwcwQF3sM9a7gdKB2PF2r.bak
/persist/data/prov/prov.bak
/persist/data/prov/prov
hannah:/ #

hannah:/ # chown -R rfs:rfs /persist/rfs
hannah:/ # chown -R rfs:rfs_shared /persist/hlos_rfs
hannah:/ # ls -l /persist
total 228
drwxrwx--- 2 system system 4096 1969-12-31 19:01 alarm
drwxr-xr-x 2 mot_pwric mot_pwric 4096 2019-01-28 22:32 batt_health
drwxrwx--- 2 bluetooth bluetooth 4096 1969-12-31 19:01 bluetooth
drwx------ 2 root system 4096 1969-12-31 19:01 bms
drwxr-xr-x 2 mot_tcmd bluetooth 4096 1969-12-31 19:01 bt
drwxr-xr-x 5 mot_tcmd mot_tcmd 4096 2019-01-28 22:32 camera
drwxrwx--- 2 system system 4096 2019-01-28 22:32 chargeonly
drwx------ 6 system system 4096 2021-03-13 14:00 data
drwxrwx--- 2 system graphics 4096 1969-12-31 19:01 display
drwxrwx--- 2 system system 4096 1969-12-31 19:01 drm
drwxrwx--- 2 system system 4096 1969-12-31 19:01 egis
drwxr-xr-x 5 mot_tcmd mot_tcmd 4096 2019-01-28 22:32 factory
drwxrwx--- 3 rfs rfs_shared 4096 2019-01-28 22:32 hlos_rfs
drwx------ 2 root root 16384 2019-01-28 22:32 lost+found
drwxrwx--- 2 radio radio 4096 2019-01-28 22:32 mdm
drwxrwx--- 2 system system 4096 1969-12-31 19:01 misc
drwxrws--- 2 mot_tcmd mot_tcmd 4096 1969-12-31 19:01 paks
drwxr-xr-x 12 mot_tcmd mot_tcmd 4096 2019-01-28 22:32 public
drwx--x--x 6 rfs rfs 4096 2019-01-28 22:32 rfs
drwx------ 2 root root 4096 1969-12-31 19:01 sds
drwxrwx--- 2 system system 4096 1969-12-31 19:01 secnvm
drwxrws--- 2 drmrpc drmrpc 4096 2019-01-28 22:32 security
drwxrwxr-x 3 system system 4096 2019-01-28 22:32 sensors
drwxrwx--- 2 system system 4096 2019-01-28 22:32 time
drwxrwx--- 2 media media 4096 1969-12-31 19:01 vpp
drwxr-xr-x 2 mot_tcmd mot_tcmd 4096 1969-12-31 19:01 wifi
drwxrwxr-x 2 mot_drm mot_drm 4096 1969-12-31 19:01 wmdrm
hannah:/ #
 

Anuj7798

Member
May 14, 2021
7
1
Moto G5 Plus
Hi,
I'm running Android 11 pixel experience plus edition for my moto g5+(potter). I upgraded to this from stock nougat after flashing in TWRP. Right after booting, I noticed my fingerprint is not responding and my LTE is not working. I fixed my fingerprint issue by referring to another forum but I'm not able to get my LTE back on my device and it stays in H+ when I on my mobile data. I checked my APN settings and when I put the preferred network to LTE only the signal goes off. I have backed up my EFS and persist. Is there a solution for this?
 

Anuj7798

Member
May 14, 2021
7
1
Moto G5 Plus
I have created this thread in order to have one thread that details just the solution to fixing your persist, identifying whether or not you have an issue with your persist, and how you can restore your IMEI without hacks. This guide is written for Motorola Moto G5 Plus (Potter). The issue also affects other models, e.g. G5, G5S, G5S Plus, but the guide appears to apply consistently to all of these models. Note that links in this thread are of course for potter.

For information on the history of this issue, refer to the following thread:
[dev][info] imei 0

IMPORTANT: There are a number of poor copy/paste jobs of parts of this guide floating around. Please link to this guide rather than posting only select parts of this (i.e. flashable zips, list of commands with no explanation). One of the lessons we all should have learned from this issue is to not just blindly follow guides because of "Hey this really works you should do it too trust me it works". The explanation and understanding is important, which is why I have taken the time to be as detailed as I have.

This thread is broken down into the following sections:
  • Asking for help
  • Pre-requisites
  • How to tell if you have an issue with your persist, and if it is recoverable
  • How to fix persist
  • Explanation

Before starting though, there is one thing to keep in mind - for this to work YOU MUST HAVE YOUR OWN PERSIST. If you flashed someone else's persist, or a persist from another device, the fix will not work. Your only hope is to have a backup of your own persist that you can restore.

0) Asking for help

If you need to ask for help in following this guide (specifically about any problems you have trying to restore your persist and/or IMEI), please provide the following information (preferably copy/paste this into your post):
- Which version of STOCK rom are you on?
- Are you rooted, and running the commands under root privileges?
- Have you ever flashed someone else's, or another device's persist?
- What functionality are you missing and trying to restore (e.g. IMEI=0, VolTE, etc)?
- Do you get any error messages when trying to execute the commands?

Please also include the full output of the commands below. Ideally wrap the output in 'code tags' so it is nicely formatted :)

Update 2018-09-16
Now that stock Oreo is starting to roll out (ever so slowly...), it is an important point to note that you can now simply upgrade to stock Oreo to overcome the issue described in this guide. Stock Oreo changes the ownership of the relevant folders in persist on every boot.

TWRP flashable Oreo builds are available here [Oreo][Stock][Rom] TWRP Flashable Stock Builds. Do also read the first two posts in detail, as they also cover how to revert to stock Nougat, should you ever wish to move to a custom Oreo rom.



1) Pre-requisites
  • You must currently be on a Stock Nougat ROM. Either the fastboot or TWRP flashable stock roms. You can get the latest TWRP flashable stock roms from this thread: [New][Stock][Rom] TWRP Flashable Stock Builds
  • You must be using your own persist.
  • You must have root access within the stock ROM. All scripts below MUST be run with root permissions

2) How to tell if you have an issue with your persist, and if it is recoverable
From a shell (either adb, or a terminal app on your device), type in the following commands:

Code:
su
ls -l /persist

The su command is to get root, and the 'ls' command lists details about the files in persist, including owners and permissions. On a fully operational persist, you will get a listing like this:
Code:
potter_n:/ # ls -l /persist
total 168
drwxrwx--- 2 system    system     4096 2018-08-04 16:44 alarm
drwxr-xr-x 2 mot_pwric mot_pwric  4096 1970-01-01 12:03 batt_health
drwxrwx--- 2 bluetooth bluetooth  4096 2018-08-04 16:44 bluetooth
drwx------ 2 root      system     4096 1970-01-01 12:03 bms
drwxr-xr-x 2 mot_tcmd  bluetooth  4096 1970-01-01 12:03 bt
drwxr-xr-x 4 mot_tcmd  mot_tcmd   4096 2018-08-04 16:44 camera
drwx------ 6 system    system     4096 2018-08-04 16:44 data
drwxrwx--- 2 system    system     4096 1970-01-01 12:03 drm
drwxr-xr-x 5 mot_tcmd  mot_tcmd   4096 2018-08-04 16:44 factory
[COLOR="red"]drwxrwx--- 3 rfs       rfs_shared 4096 2018-08-04 16:44 hlos_rfs[/COLOR]
drwxrwx--- 2 root      root       4096 2018-08-04 16:44 lost+found
drwxrwx--- 2 radio     radio      4096 2018-08-04 16:44 mdm
drwxrwx--- 2 system    system     4096 1970-01-01 12:03 misc
drwxrwx--- 2 system    system     4096 1970-10-15 07:43 properties
drwxr-xr-x 8 mot_tcmd  mot_tcmd   4096 2018-08-04 16:44 public
[COLOR="red"]drwx------ 6 rfs       rfs        4096 2018-08-04 16:44 rfs[/COLOR]
drwxrws--- 2 mot_tpapi mot_tpapi  4096 2018-08-04 16:44 security
drwxrwxr-x 2 root      root       4096 2018-08-04 16:44 sensors
drwxrwx--- 2 system    system     4096 2018-08-04 16:44 time
drwxr-xr-x 2 mot_tcmd  mot_tcmd   4096 1970-01-01 12:03 wifi
drwxrwxr-x 2 mot_drm   mot_drm    4096 1970-01-01 12:03 wmdrm

The key here, is the rfs folder, and to a lesser degree, the hlos_rfs folder. Notice how the owner is rfs, and in the case of hlos_rfs, the group is rfs_shared.

Important - if you ran these commands from within an Oreo rom, you will see owners such as oem_2903 etc. These owners are valid for Oreo (custom or stock). The point of this guide is so that you know whether or not you have an ownership / permissions issue on Stock Nougat.

Additionally, if you run the following to look for files within persist:
Code:
find /persist -type f

You will see something like this:
Code:
potter_n:/ # find /persist -type f
/persist/sensors/sensors_settings
/persist/data/prov/eyBMMa7Jo5Dwo4LigJCHx3WxPUdQ9y8GJKIBae9bic
/persist/data/prov/prov
/persist/data/prov/prov.bak
/persist/data/prov/eyBMMa7Jo5Dwo4LigJCHx3WxPUdQ9y8GJKIBae9bic.bak
/persist/data/prov/T2pluw0BDr+EpzrrpM4aIMo1xKHY-DMHg3Uk3GF5yq
/persist/data/prov/T2pluw0BDr+EpzrrpM4aIMo1xKHY-DMHg3Uk3GF5yq.bak
/persist/data/widevine/Saljqyb2k7jJt0wZSxpXq0sdCZJH4urJjb-qcgkn7H
/persist/data/widevine/Saljqyb2k7jJt0wZSxpXq0sdCZJH4urJjb-qcgkn7H.bak
/persist/data/widevine/+CdCfjxBGljLnuTN7yCnhuY3WzhxbvHOjc-rac35xw
/persist/data/widevine/+CdCfjxBGljLnuTN7yCnhuY3WzhxbvHOjc-rac35xw.bak
/persist/camera/ledcal/rear
/persist/mdm/oma_dm_update
/persist/factory/regulatory/regulatory_info.png
/persist/factory/fti
/persist/public/hiddenmenu/data/mobile_data_rx
/persist/public/hiddenmenu/data/mobile_data_tx
/persist/public/hiddenmenu/data/wifi_data_rx
/persist/public/hiddenmenu/data/wifi_data_tx
/persist/security/18.bin
/persist/bluetooth/.bt_nv.bin
/persist/alarm/powerOffAlarmSet
/persist/alarm/timezone
/persist/alarm/powerOffAlarmInstance
/persist/time/ats_1
/persist/time/ats_2
/persist/time/ats_15
/persist/time/ats_12
/persist/time/ats_13
/persist/rfs/shared/server_info.txt
/persist/rfs/msm/mpss/datablock/id_00
/persist/rfs/msm/mpss/datablock/id_01
/persist/rfs/msm/mpss/server_check.txt
[COLOR="red"]/persist/rfs/msm/mpss/dhob.bin
/persist/rfs/msm/mpss/shob.bin
/persist/rfs/msm/mpss/dhob.bin.bak
[/COLOR]

The key files here are those in the /persist/rfs folder, mainly the dhob.bin file, which is used in creation of the EFS (i.e. the modemst1 and modemst2 partitions).

If you do not have the files under the /persist/rfs folder, then you will not be able to restore your persist through this method. Also see post #3 for information on when you have a dhob.bin but no dhob.bin.bak.

Now, if you run the ls command on a 'bad persist', you will get the following output from the ls command:
Code:
potter_n:/ # ls -l /persist
total 208
drwxrwx---  2 system    system    4096 2018-08-05 11:48 alarm
drwxr-xr-x  2 mot_pwric mot_pwric 4096 1970-01-01 12:03 batt_health
drwxrwx---  2 bluetooth bluetooth 4096 2018-08-05 11:48 bluetooth
drwx------  2 root      system    4096 1970-01-01 12:03 bms
drwxr-xr-x  2 mot_tcmd  bluetooth 4096 1970-01-01 12:03 bt
drwxr-xr-x  4 mot_tcmd  mot_tcmd  4096 2018-08-05 11:48 camera
drwxrwx---  2 system    system    4096 2018-08-05 11:48 chargeonly
drwx------  6 system    system    4096 2018-08-05 11:48 data
drwxrwx---  2 system    graphics  4096 1971-01-22 16:48 display
drwxrwx---  2 system    system    4096 1970-01-01 12:03 drm
drwxr-xr-x  5 mot_tcmd  mot_tcmd  4096 2018-08-05 11:48 factory
[COLOR="Red"]drwxrwx---  3 2951      2952      4096 2018-08-05 11:48 hlos_rfs[/COLOR]
drwxrwx---  2 root      root      4096 2018-08-05 11:48 lost+found
drwxrwx---  2 radio     radio     4096 2018-08-05 11:48 mdm
drwxrwx---  2 system    system    4096 1970-01-01 12:03 misc
drwxrwx---  2 system    system    4096 1970-10-15 07:43 properties
drwxr-xr-x 11 mot_tcmd  mot_tcmd  4096 2018-08-05 11:48 public
[COLOR="Red"]drwx--x--x  6 2951      2951      4096 2018-08-05 11:48 rfs[/COLOR]
drwx------  2 root      root      4096 1971-01-22 16:48 sds
drwxrwx---  2 system    system    4096 1971-01-22 16:48 secnvm
drwxrws---  2 mot_tpapi mot_tpapi 4096 2018-08-05 11:48 security
drwxrwxr-x  2 root      root      4096 2018-08-05 11:48 sensors
drwxrwx---  2 system    system    4096 2018-08-05 11:48 time
drwxrwx---  2 media     media     4096 1971-01-22 16:48 vpp
drwxr-xr-x  2 mot_tcmd  mot_tcmd  4096 1970-01-01 12:03 wifi
drwxrwxr-x  2 mot_drm   mot_drm   4096 1970-01-01 12:03 wmdrm

The lines above in red, show that the ownership of the rfs and hlos_rfs folders are numbers, i.e. they are unknown to the system. To resolve, we need to change the ownership.

3) How to fix your persist
To fix the ownership, use the following commands (use su if not in a root shell):
Code:
chown -R rfs:rfs /persist/rfs
chown -R rfs:rfs_shared /persist/hlos_rfs
ls -l /persist

Now when the ls command shows the ownership of the folders, you should see the correct ownership.

Fixing your IMEI if it was zero

If your IMEI was zero, reboot, and cross your fingers that you will have your IMEI back (Settings > About Phone > Status > IMEI information).

NEW - TWRP flashable Stock Persist Fix

I've created a TWRP flashable zip that does the above ownership fixes. The script has slight differences, it uses the AIDs (Android IDs) of rfs and rfs_shared in stock.
potter-stock-persist-fix.zip



4) Explanation

4a) What happened to persist.

To understand what happened, you need to know a few things about filesystem permissions in Linux. Files and folders have user and group ownership, and permissions. Examples of owners are the system, root, user, etc. Examples of permissions are read access, write access, execute access. The permissions are applied at three levels 1) the user, 2) the group, 3) everyone else.

@rachitrawat's investigation into the failures showed that the issue was relating to the persist partition, specifically some files dhob.bin etc that are under the rfs sub folder in this partition. Under stock, these files/folders are owned by a user called rfs, and have group ownership under a group also called rfs. Additionally, the permissions on these files/folders are limited - only the rfs user can read/write/execute these files. Other users, groups, or everyone else, cannot access the files.

Edit: This part here wasn't quite correct, it is fixed below. It kind of still applies, but only if looking from within TWRP (I wrongly assumed that TWRP had the same user names as Lineage, my bad!):
So something happened in the Oreo roms. If you flash and boot into an Oreo rom, and you look at the permissions/ownership, you will see exactly the same ownership patterns as stock. But there's a catch!

There was a change in the Oreo roms. If you flash and boot into an Oreo rom, and you look at the permissions/ownership, you will see that a user and group oem_2951 owns the rfs folder, and a group oem_2952 owns the hlos_rfs folder. Now this is a different name, but on its own, a different name does not mean different ownership.

In Linux, all users and groups are assigned an ID, i.e. a number. So for example, on my phone, the rfs user has ID 3012 under stock. In lineage oreo, the oem_2951 user has ID 2951. So something happened in lineage that changed the user IDs that are applied to the rfs folder.

If you look at the ownership of persist files/folders within TWRP, you will see that a STOCK PERSIST has the owner of the rfs folder as rfs_old. Similarly in TWRP, a LINEAGE PERSIST has the owner of the rfs folder as rfs. So TWRP is seeing owners differently again to stock and Lineage. Trying to run the above commands in TWRP will not fix the issue, as it will use ID 2951 for the user rfs, but we need it to be 3012 in stock (which TWRP sees as rfs_old).

In addition to the rfs folder, there is also another folder that is impacted - hlos_rfs. Its user owner is rfs, but its group owner if rfs_shared. A stock rfs_shared is shown as rfs_shared_o in TWRP. It appears that this folder is not as important in getting the IMEI back, but I have included the commands to restore ownership, to ensure there are no future errors.

4b) What happened to IMEI.

Despite the issue above, many people who flashed Oreo roms would have had no problems (other than I guess, bugs in the roms themselves). The change of ownership of the rfs folder didn't change the actual file content, so essentially all is intact. In fact, I verified that my dhob.bin and other files had the same md5sum in stock and lineage persist.

The issue of the IMEI changing to zero has only happened when people have flashed Stock roms. All of the guides that I have seen, have included the following commands (and equivalent commands have been included in the TWRP flashable stock builds as well):
Code:
fastboot erase modemst1
fastboot erase modemst2

The partitions modemst1 and modemst2 are your EFS. Normally, if your persist is pure stock, if either is erased, the modem re-creates them. But, referring to the above about permissions, if the rfs user (which is presumably used by the modem) cannot access the files (because the owner of the files is someone else, and the permissions on the files mean that only the owner can access them), then the modem cannot recreate the EFS, and the IMEI is left as zero.

4c) Restoring IMEI.

Changing the ownership of your otherwise untouched persist allows the rfs user to access those files. Rebooting will result in the modem checking the EFS, and when it sees that it is still blank, it will recreate the IMEI.

However, the dhob.bin file in persist is encrypted, and goes through some sort of hash check. You can only use your own dhob.bin to recreate the IMEI. This is why it is essential that you have your own persist, and no one else's will work.

5) Other info

Other things that may be good to know about this issue.

5a) Why did flashing another device's persist fix Volte?
Or rather, why did flashing another device's persist "fix Volte" at the expense of permanently breaking key functionality of your device?

Flashing another device's persist gave the impression of working, but most probably this was due to one thing alone - the permissions on the persist partition of Moto devices is similar. That is, other Moto devices have rfs and hlos_rfs folders, and the owner is the same (both in name and AID - Android ID).

So, after flashing a custom Oreo rom, then going back to stock, Volte would not work. However, if they hadn't erased modemst1/2 (EFS) they would still have IMEI, but other functionality would be broken (Volte, 4G, possibly others). Flashing the other persist changed the permissions to the right ones, and boom all of a sudden Volte worked. The regret comes after, when the user has erased EFS through an update or other flash.

XDA:DevDB Information
The Persist Project, Tool/Utility for the Moto G5 Plus

Contributors
NZedPred, rachitrawat

Version Information
Status:
Stable

Created 2018-08-05
Last Updated 2018-09-15
Hi,
I'm running Android 11 pixel experience plus edition for my moto g5+(potter). I upgraded to this from stock nougat after flashing in TWRP. Right after booting, I noticed my fingerprint is not responding and my LTE is not working. I fixed my fingerprint issue by referring to another forum but I'm not able to get my LTE back on my device and it stays in H+ when I on my mobile data. I checked my APN settings and when I put the preferred network to LTE only the signal goes off. I have backed up my EFS and persist. Is there a solution for this?
 

Wolfcity

Recognized Contributor
Apr 26, 2013
4,317
2,703
Germany
Moto G 2014
Moto G5 Plus
Hi,
I'm running Android 11 pixel experience plus edition for my moto g5+(potter). I upgraded to this from stock nougat after flashing in TWRP. Right after booting, I noticed my fingerprint is not responding and my LTE is not working. I fixed my fingerprint issue by referring to another forum but I'm not able to get my LTE back on my device and it stays in H+ when I on my mobile data. I checked my APN settings and when I put the preferred network to LTE only the signal goes off. I have backed up my EFS and persist. Is there a solution for this?
As far as I know pixel experience needs Android 8 (Oreo) as base (check OP of the ROMs thread or ask the dev. Also search the thread:

Losing fingerprint is a typical issue when coming from nougat instead of Oreo!

So the best way would be going back to your stock firmware, update it to Oreo and than flash Pixel experience. Read first how to do it, check that the ROM is for your location and if the model is XT1684 or XT1685.
You may try to restore your efs and persist (important) now but I don't think that will help if PE needs Oreo as base for flashing as most custome ROMs do.
Don't forget to backup your persist/efs again when you're on Oreo stock.

Full signed firmwares can be found here:
 
Last edited:
  • Like
Reactions: Anuj7798

MohdAhmed

Senior Member
May 13, 2016
306
23
Xiaomi Redmi Note 7 Pro
Hi,
I'm running Android 11 pixel experience plus edition for my moto g5+(potter). I upgraded to this from stock nougat after flashing in TWRP. Right after booting, I noticed my fingerprint is not responding and my LTE is not working. I fixed my fingerprint issue by referring to another forum but I'm not able to get my LTE back on my device and it stays in H+ when I on my mobile data. I checked my APN settings and when I put the preferred network to LTE only the signal goes off. I have backed up my EFS and persist. Is there a solution for this?
Remember LTE works only on Sim 1. And when you flashed from nougat, the stock rom, your Jio sim (LTE sim) should be on sim 1 in stock rom.
If it was in sim 1 in stock rom, then just go to twrp and restore the EFS and Persist back you had of stock rom on this custom rom, and it will work.
 
  • Like
Reactions: Anuj7798

Anuj7798

Member
May 14, 2021
7
1
Moto G5 Plus
Solved my issue by reverting back by flashing the latest android nougat with the aroma installer and then flashing the latest orea on it. Then went on with pixel experience plus rom android 11. This fixed my LTE and fingerprint issues. Thank you.
 
  • Like
Reactions: Wolfcity

jaysonwcs

Member
Apr 21, 2020
9
1
Moto G5S
I know this is for Moto G5 Plus, but on my Moto G5S (montana) there's no persist partition.
My phone is working fine with LineageOS 18, but everytime I try to flash the stock ROM, I lose my IMEI.
I believe the problem is the one described here, but I cannot access the partition to check the file permissions.

Can someone give me some help?

Thanks
 

jaysonwcs

Member
Apr 21, 2020
9
1
Moto G5S
Found partition on /mnt/vendor/persist:

Code:
montana:/ # ls -l /mnt/vendor/persist
total 108
drwxrwx---  2 system           system           4096 1969-12-31 21:01 alarm
drwxrwxr-x  2 vendor_mot_pwric vendor_mot_pwric 4096 2019-10-18 17:26 batt_health
drwxrwx---  2 bluetooth        bluetooth        4096 2019-10-18 17:26 bluetooth
drwx------  2 root             system           4096 1969-12-31 21:01 bms
drwxr-xr-x  2 vendor_mot_tcmd  bluetooth        4096 1969-12-31 21:01 bt
drwxr-xr-x  5 vendor_mot_tcmd  vendor_mot_tcmd  4096 1971-03-09 13:44 camera
drwxrwx---  2 system           system           4096 2019-10-18 17:26 chargeonly
drwx------  6 system           system           4096 2019-10-18 17:26 data
drwxrwx---  2 system           graphics         4096 1970-08-10 06:21 display
drwx------  2 system           system           4096 1969-12-31 21:01 drm
drwxr-xr-x  5 vendor_mot_tcmd  vendor_mot_tcmd  4096 2019-10-18 17:26 factory
drwxrwx---  3 vendor_rfs       oem_2904         4096 2019-10-18 17:26 hlos_rfs
drwxrwx---  2 root             root             4096 2019-10-18 17:26 lost+found
drwxrwx---  2 radio            radio            4096 2019-10-18 17:26 mdm
drwxrwx---  2 system           system           4096 1969-12-31 21:01 misc
drwxrws---  2 vendor_mot_tcmd  vendor_mot_tcmd  4096 2019-10-18 17:26 paks
drwxrwx---  2 system           system           4096 1970-04-25 08:36 properties
drwxr-xr-x 11 vendor_mot_tcmd  vendor_mot_tcmd  4096 2019-10-18 17:26 public
drwx--x--x  6 vendor_rfs       vendor_rfs       4096 2019-10-18 17:26 rfs
drwx------  2 system           system           4096 1970-01-03 05:55 sds
drwxrwx---  2 system           system           4096 1970-08-10 06:21 secnvm
drwxrws---  2 drmrpc           vendor_mot_tcmd  4096 2019-10-18 17:26 security
drwxrwxr-x  3 system           system           4096 2019-10-18 17:26 sensors
drwxrwx---  2 system           system           4096 2019-10-18 17:26 time
drwxrwx---  2 media            media            4096 1970-08-10 06:21 vpp
drwxr-xr-x  2 vendor_mot_tcmd  vendor_mot_tcmd  4096 1969-12-31 21:01 wifi
drwxrwxr-x  2 vendor_mot_drm   vendor_mot_drm   4096 1969-12-31 21:01 wmdrm


However, the permitions are set to the users oem_2904 and vendor_rfs. Not sure if this is right. I will try to flash the stock ROM without erasing modem partitions and see what happens.
 

jaysonwcs

Member
Apr 21, 2020
9
1
Moto G5S
Ok, I was wrong. That way the partition was mounted occurs only on LineageOS. Didn't know different ROMs mounted on different directories.

Found the Persist partition on the standard folder:

Code:
montana:/ # ls -l persist
total 108
drwxrwx---  2 system    system    4096 1969-12-31 21:01 alarm
drwxr-xr-x  2 mot_pwric mot_pwric 4096 2019-10-18 17:26 batt_health
drwxrwx---  2 bluetooth bluetooth 4096 2019-10-18 17:26 bluetooth
drwx------  2 root      system    4096 1969-12-31 21:01 bms
drwxr-xr-x  2 mot_tcmd  bluetooth 4096 1969-12-31 21:01 bt
drwxr-xr-x  5 mot_tcmd  mot_tcmd  4096 1971-03-09 13:44 camera
drwxrwx---  2 system    system    4096 2019-10-18 17:26 chargeonly
drwx------  6 system    system    4096 2019-10-18 17:26 data
drwxrwx---  2 system    graphics  4096 1970-08-10 06:21 display
drwxrwx---  2 system    system    4096 1969-12-31 21:01 drm
drwxr-xr-x  5 mot_tcmd  mot_tcmd  4096 2019-10-18 17:26 factory
drwxrwx---  3 oem_2903  oem_2904  4096 2019-10-18 17:26 hlos_rfs
drwxrwx---  2 root      root      4096 2019-10-18 17:26 lost+found
drwxrwx---  2 radio     radio     4096 2019-10-18 17:26 mdm
drwxrwx---  2 system    system    4096 1969-12-31 21:01 misc
drwxrws---  2 mot_tcmd  mot_tcmd  4096 2019-10-18 17:26 paks
drwxrwx---  2 system    system    4096 1970-04-25 08:36 properties
drwxr-xr-x 11 mot_tcmd  mot_tcmd  4096 2019-10-18 17:26 public
drwx--x--x  6 oem_2903  oem_2903  4096 2019-10-18 17:26 rfs
drwx------  2 system    system    4096 1970-01-03 05:55 sds
drwxrwx---  2 system    system    4096 1970-08-10 06:21 secnvm
drwxrws---  2 drmrpc    drmrpc    4096 2019-10-18 17:26 security
drwxrwxr-x  3 system    system    4096 2019-10-18 17:26 sensors
drwxrwx---  2 system    system    4096 2019-10-18 17:26 time
drwxrwx---  2 media     media     4096 1970-08-10 06:21 vpp
drwxr-xr-x  2 mot_tcmd  mot_tcmd  4096 1969-12-31 21:01 wifi
drwxrwxr-x  2 mot_drm   mot_drm   4096 1969-12-31 21:01 wmdrm

Now, I'm not sure the user oem_2903 and oem_2904 are right or wrong. It found the IMEI number, but the brightness are always on maximum, and the screen takes too long to light up when I press the unlock button.

Not sure why I'm not able install the Stock ROM properly =(
 

jaysonwcs

Member
Apr 21, 2020
9
1
Moto G5S
Ok, I was wrong. That way the partition was mounted occurs only on LineageOS. Didn't know different ROMs mounted on different directories.

Found the Persist partition on the standard folder:

Code:
montana:/ # ls -l persist
total 108
drwxrwx---  2 system    system    4096 1969-12-31 21:01 alarm
drwxr-xr-x  2 mot_pwric mot_pwric 4096 2019-10-18 17:26 batt_health
drwxrwx---  2 bluetooth bluetooth 4096 2019-10-18 17:26 bluetooth
drwx------  2 root      system    4096 1969-12-31 21:01 bms
drwxr-xr-x  2 mot_tcmd  bluetooth 4096 1969-12-31 21:01 bt
drwxr-xr-x  5 mot_tcmd  mot_tcmd  4096 1971-03-09 13:44 camera
drwxrwx---  2 system    system    4096 2019-10-18 17:26 chargeonly
drwx------  6 system    system    4096 2019-10-18 17:26 data
drwxrwx---  2 system    graphics  4096 1970-08-10 06:21 display
drwxrwx---  2 system    system    4096 1969-12-31 21:01 drm
drwxr-xr-x  5 mot_tcmd  mot_tcmd  4096 2019-10-18 17:26 factory
drwxrwx---  3 oem_2903  oem_2904  4096 2019-10-18 17:26 hlos_rfs
drwxrwx---  2 root      root      4096 2019-10-18 17:26 lost+found
drwxrwx---  2 radio     radio     4096 2019-10-18 17:26 mdm
drwxrwx---  2 system    system    4096 1969-12-31 21:01 misc
drwxrws---  2 mot_tcmd  mot_tcmd  4096 2019-10-18 17:26 paks
drwxrwx---  2 system    system    4096 1970-04-25 08:36 properties
drwxr-xr-x 11 mot_tcmd  mot_tcmd  4096 2019-10-18 17:26 public
drwx--x--x  6 oem_2903  oem_2903  4096 2019-10-18 17:26 rfs
drwx------  2 system    system    4096 1970-01-03 05:55 sds
drwxrwx---  2 system    system    4096 1970-08-10 06:21 secnvm
drwxrws---  2 drmrpc    drmrpc    4096 2019-10-18 17:26 security
drwxrwxr-x  3 system    system    4096 2019-10-18 17:26 sensors
drwxrwx---  2 system    system    4096 2019-10-18 17:26 time
drwxrwx---  2 media     media     4096 1970-08-10 06:21 vpp
drwxr-xr-x  2 mot_tcmd  mot_tcmd  4096 1969-12-31 21:01 wifi
drwxrwxr-x  2 mot_drm   mot_drm   4096 1969-12-31 21:01 wmdrm

Now, I'm not sure the user oem_2903 and oem_2904 are right or wrong. It found the IMEI number, but the brightness are always on maximum, and the screen takes too long to light up when I press the unlock button.

Not sure why I'm not able install the Stock ROM properly =(
Tried to flash the Nougat Stock ROM (Android 7) without erasing modem partitions, without the SIM card . Started the system, inserted the SIM card, no signal, but IMEI detected.
After that, I formatted data and system with TWRP, reflashed Oreo Stock ROM (Android 8) without erasing modem partitions and without the SIM card. Started the system, inserted the SIM card and voilà!
Now it's working 100% (cell phone signal, 4G, brithgness working properly etc.).

Just in case someone has any problems, you can try this procedure, with Moto G5 Plus, G5S or any other.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 51
    I have created this thread in order to have one thread that details just the solution to fixing your persist, identifying whether or not you have an issue with your persist, and how you can restore your IMEI without hacks. This guide is written for Motorola Moto G5 Plus (Potter). The issue also affects other models, e.g. G5, G5S, G5S Plus, but the guide appears to apply consistently to all of these models. Note that links in this thread are of course for potter.

    For information on the history of this issue, refer to the following thread:
    [dev][info] imei 0

    IMPORTANT: There are a number of poor copy/paste jobs of parts of this guide floating around. Please link to this guide rather than posting only select parts of this (i.e. flashable zips, list of commands with no explanation). One of the lessons we all should have learned from this issue is to not just blindly follow guides because of "Hey this really works you should do it too trust me it works". The explanation and understanding is important, which is why I have taken the time to be as detailed as I have.

    This thread is broken down into the following sections:
    • Asking for help
    • Pre-requisites
    • How to tell if you have an issue with your persist, and if it is recoverable
    • How to fix persist
    • Explanation

    Before starting though, there is one thing to keep in mind - for this to work YOU MUST HAVE YOUR OWN PERSIST. If you flashed someone else's persist, or a persist from another device, the fix will not work. Your only hope is to have a backup of your own persist that you can restore.

    0) Asking for help

    If you need to ask for help in following this guide (specifically about any problems you have trying to restore your persist and/or IMEI), please provide the following information (preferably copy/paste this into your post):
    - Which version of STOCK rom are you on?
    - Are you rooted, and running the commands under root privileges?
    - Have you ever flashed someone else's, or another device's persist?
    - What functionality are you missing and trying to restore (e.g. IMEI=0, VolTE, etc)?
    - Do you get any error messages when trying to execute the commands?

    Please also include the full output of the commands below. Ideally wrap the output in 'code tags' so it is nicely formatted :)

    Update 2018-09-16
    Now that stock Oreo is starting to roll out (ever so slowly...), it is an important point to note that you can now simply upgrade to stock Oreo to overcome the issue described in this guide. Stock Oreo changes the ownership of the relevant folders in persist on every boot.

    TWRP flashable Oreo builds are available here [Oreo][Stock][Rom] TWRP Flashable Stock Builds. Do also read the first two posts in detail, as they also cover how to revert to stock Nougat, should you ever wish to move to a custom Oreo rom.


    1) Pre-requisites
    • You must currently be on a Stock Nougat ROM. Either the fastboot or TWRP flashable stock roms. You can get the latest TWRP flashable stock roms from this thread: [New][Stock][Rom] TWRP Flashable Stock Builds
    • You must be using your own persist.
    • You must have root access within the stock ROM. All scripts below MUST be run with root permissions

    2) How to tell if you have an issue with your persist, and if it is recoverable
    From a shell (either adb, or a terminal app on your device), type in the following commands:

    Code:
    su
    ls -l /persist

    The su command is to get root, and the 'ls' command lists details about the files in persist, including owners and permissions. On a fully operational persist, you will get a listing like this:
    Code:
    potter_n:/ # ls -l /persist
    total 168
    drwxrwx--- 2 system    system     4096 2018-08-04 16:44 alarm
    drwxr-xr-x 2 mot_pwric mot_pwric  4096 1970-01-01 12:03 batt_health
    drwxrwx--- 2 bluetooth bluetooth  4096 2018-08-04 16:44 bluetooth
    drwx------ 2 root      system     4096 1970-01-01 12:03 bms
    drwxr-xr-x 2 mot_tcmd  bluetooth  4096 1970-01-01 12:03 bt
    drwxr-xr-x 4 mot_tcmd  mot_tcmd   4096 2018-08-04 16:44 camera
    drwx------ 6 system    system     4096 2018-08-04 16:44 data
    drwxrwx--- 2 system    system     4096 1970-01-01 12:03 drm
    drwxr-xr-x 5 mot_tcmd  mot_tcmd   4096 2018-08-04 16:44 factory
    [COLOR="red"]drwxrwx--- 3 rfs       rfs_shared 4096 2018-08-04 16:44 hlos_rfs[/COLOR]
    drwxrwx--- 2 root      root       4096 2018-08-04 16:44 lost+found
    drwxrwx--- 2 radio     radio      4096 2018-08-04 16:44 mdm
    drwxrwx--- 2 system    system     4096 1970-01-01 12:03 misc
    drwxrwx--- 2 system    system     4096 1970-10-15 07:43 properties
    drwxr-xr-x 8 mot_tcmd  mot_tcmd   4096 2018-08-04 16:44 public
    [COLOR="red"]drwx------ 6 rfs       rfs        4096 2018-08-04 16:44 rfs[/COLOR]
    drwxrws--- 2 mot_tpapi mot_tpapi  4096 2018-08-04 16:44 security
    drwxrwxr-x 2 root      root       4096 2018-08-04 16:44 sensors
    drwxrwx--- 2 system    system     4096 2018-08-04 16:44 time
    drwxr-xr-x 2 mot_tcmd  mot_tcmd   4096 1970-01-01 12:03 wifi
    drwxrwxr-x 2 mot_drm   mot_drm    4096 1970-01-01 12:03 wmdrm

    The key here, is the rfs folder, and to a lesser degree, the hlos_rfs folder. Notice how the owner is rfs, and in the case of hlos_rfs, the group is rfs_shared.

    Important - if you ran these commands from within an Oreo rom, you will see owners such as oem_2903 etc. These owners are valid for Oreo (custom or stock). The point of this guide is so that you know whether or not you have an ownership / permissions issue on Stock Nougat.

    Additionally, if you run the following to look for files within persist:
    Code:
    find /persist -type f

    You will see something like this:
    Code:
    potter_n:/ # find /persist -type f
    /persist/sensors/sensors_settings
    /persist/data/prov/eyBMMa7Jo5Dwo4LigJCHx3WxPUdQ9y8GJKIBae9bic
    /persist/data/prov/prov
    /persist/data/prov/prov.bak
    /persist/data/prov/eyBMMa7Jo5Dwo4LigJCHx3WxPUdQ9y8GJKIBae9bic.bak
    /persist/data/prov/T2pluw0BDr+EpzrrpM4aIMo1xKHY-DMHg3Uk3GF5yq
    /persist/data/prov/T2pluw0BDr+EpzrrpM4aIMo1xKHY-DMHg3Uk3GF5yq.bak
    /persist/data/widevine/Saljqyb2k7jJt0wZSxpXq0sdCZJH4urJjb-qcgkn7H
    /persist/data/widevine/Saljqyb2k7jJt0wZSxpXq0sdCZJH4urJjb-qcgkn7H.bak
    /persist/data/widevine/+CdCfjxBGljLnuTN7yCnhuY3WzhxbvHOjc-rac35xw
    /persist/data/widevine/+CdCfjxBGljLnuTN7yCnhuY3WzhxbvHOjc-rac35xw.bak
    /persist/camera/ledcal/rear
    /persist/mdm/oma_dm_update
    /persist/factory/regulatory/regulatory_info.png
    /persist/factory/fti
    /persist/public/hiddenmenu/data/mobile_data_rx
    /persist/public/hiddenmenu/data/mobile_data_tx
    /persist/public/hiddenmenu/data/wifi_data_rx
    /persist/public/hiddenmenu/data/wifi_data_tx
    /persist/security/18.bin
    /persist/bluetooth/.bt_nv.bin
    /persist/alarm/powerOffAlarmSet
    /persist/alarm/timezone
    /persist/alarm/powerOffAlarmInstance
    /persist/time/ats_1
    /persist/time/ats_2
    /persist/time/ats_15
    /persist/time/ats_12
    /persist/time/ats_13
    /persist/rfs/shared/server_info.txt
    /persist/rfs/msm/mpss/datablock/id_00
    /persist/rfs/msm/mpss/datablock/id_01
    /persist/rfs/msm/mpss/server_check.txt
    [COLOR="red"]/persist/rfs/msm/mpss/dhob.bin
    /persist/rfs/msm/mpss/shob.bin
    /persist/rfs/msm/mpss/dhob.bin.bak
    [/COLOR]

    The key files here are those in the /persist/rfs folder, mainly the dhob.bin file, which is used in creation of the EFS (i.e. the modemst1 and modemst2 partitions).

    If you do not have the files under the /persist/rfs folder, then you will not be able to restore your persist through this method. Also see post #3 for information on when you have a dhob.bin but no dhob.bin.bak.

    Now, if you run the ls command on a 'bad persist', you will get the following output from the ls command:
    Code:
    potter_n:/ # ls -l /persist
    total 208
    drwxrwx---  2 system    system    4096 2018-08-05 11:48 alarm
    drwxr-xr-x  2 mot_pwric mot_pwric 4096 1970-01-01 12:03 batt_health
    drwxrwx---  2 bluetooth bluetooth 4096 2018-08-05 11:48 bluetooth
    drwx------  2 root      system    4096 1970-01-01 12:03 bms
    drwxr-xr-x  2 mot_tcmd  bluetooth 4096 1970-01-01 12:03 bt
    drwxr-xr-x  4 mot_tcmd  mot_tcmd  4096 2018-08-05 11:48 camera
    drwxrwx---  2 system    system    4096 2018-08-05 11:48 chargeonly
    drwx------  6 system    system    4096 2018-08-05 11:48 data
    drwxrwx---  2 system    graphics  4096 1971-01-22 16:48 display
    drwxrwx---  2 system    system    4096 1970-01-01 12:03 drm
    drwxr-xr-x  5 mot_tcmd  mot_tcmd  4096 2018-08-05 11:48 factory
    [COLOR="Red"]drwxrwx---  3 2951      2952      4096 2018-08-05 11:48 hlos_rfs[/COLOR]
    drwxrwx---  2 root      root      4096 2018-08-05 11:48 lost+found
    drwxrwx---  2 radio     radio     4096 2018-08-05 11:48 mdm
    drwxrwx---  2 system    system    4096 1970-01-01 12:03 misc
    drwxrwx---  2 system    system    4096 1970-10-15 07:43 properties
    drwxr-xr-x 11 mot_tcmd  mot_tcmd  4096 2018-08-05 11:48 public
    [COLOR="Red"]drwx--x--x  6 2951      2951      4096 2018-08-05 11:48 rfs[/COLOR]
    drwx------  2 root      root      4096 1971-01-22 16:48 sds
    drwxrwx---  2 system    system    4096 1971-01-22 16:48 secnvm
    drwxrws---  2 mot_tpapi mot_tpapi 4096 2018-08-05 11:48 security
    drwxrwxr-x  2 root      root      4096 2018-08-05 11:48 sensors
    drwxrwx---  2 system    system    4096 2018-08-05 11:48 time
    drwxrwx---  2 media     media     4096 1971-01-22 16:48 vpp
    drwxr-xr-x  2 mot_tcmd  mot_tcmd  4096 1970-01-01 12:03 wifi
    drwxrwxr-x  2 mot_drm   mot_drm   4096 1970-01-01 12:03 wmdrm

    The lines above in red, show that the ownership of the rfs and hlos_rfs folders are numbers, i.e. they are unknown to the system. To resolve, we need to change the ownership.

    3) How to fix your persist
    To fix the ownership, use the following commands (use su if not in a root shell):
    Code:
    chown -R rfs:rfs /persist/rfs
    chown -R rfs:rfs_shared /persist/hlos_rfs
    ls -l /persist

    Now when the ls command shows the ownership of the folders, you should see the correct ownership.

    Fixing your IMEI if it was zero

    If your IMEI was zero, reboot, and cross your fingers that you will have your IMEI back (Settings > About Phone > Status > IMEI information).

    NEW - TWRP flashable Stock Persist Fix

    I've created a TWRP flashable zip that does the above ownership fixes. The script has slight differences, it uses the AIDs (Android IDs) of rfs and rfs_shared in stock.
    potter-stock-persist-fix.zip


    4) Explanation

    4a) What happened to persist.

    To understand what happened, you need to know a few things about filesystem permissions in Linux. Files and folders have user and group ownership, and permissions. Examples of owners are the system, root, user, etc. Examples of permissions are read access, write access, execute access. The permissions are applied at three levels 1) the user, 2) the group, 3) everyone else.

    @rachitrawat's investigation into the failures showed that the issue was relating to the persist partition, specifically some files dhob.bin etc that are under the rfs sub folder in this partition. Under stock, these files/folders are owned by a user called rfs, and have group ownership under a group also called rfs. Additionally, the permissions on these files/folders are limited - only the rfs user can read/write/execute these files. Other users, groups, or everyone else, cannot access the files.

    Edit: This part here wasn't quite correct, it is fixed below. It kind of still applies, but only if looking from within TWRP (I wrongly assumed that TWRP had the same user names as Lineage, my bad!):
    So something happened in the Oreo roms. If you flash and boot into an Oreo rom, and you look at the permissions/ownership, you will see exactly the same ownership patterns as stock. But there's a catch!

    There was a change in the Oreo roms. If you flash and boot into an Oreo rom, and you look at the permissions/ownership, you will see that a user and group oem_2951 owns the rfs folder, and a group oem_2952 owns the hlos_rfs folder. Now this is a different name, but on its own, a different name does not mean different ownership.

    In Linux, all users and groups are assigned an ID, i.e. a number. So for example, on my phone, the rfs user has ID 3012 under stock. In lineage oreo, the oem_2951 user has ID 2951. So something happened in lineage that changed the user IDs that are applied to the rfs folder.

    If you look at the ownership of persist files/folders within TWRP, you will see that a STOCK PERSIST has the owner of the rfs folder as rfs_old. Similarly in TWRP, a LINEAGE PERSIST has the owner of the rfs folder as rfs. So TWRP is seeing owners differently again to stock and Lineage. Trying to run the above commands in TWRP will not fix the issue, as it will use ID 2951 for the user rfs, but we need it to be 3012 in stock (which TWRP sees as rfs_old).

    In addition to the rfs folder, there is also another folder that is impacted - hlos_rfs. Its user owner is rfs, but its group owner if rfs_shared. A stock rfs_shared is shown as rfs_shared_o in TWRP. It appears that this folder is not as important in getting the IMEI back, but I have included the commands to restore ownership, to ensure there are no future errors.

    4b) What happened to IMEI.

    Despite the issue above, many people who flashed Oreo roms would have had no problems (other than I guess, bugs in the roms themselves). The change of ownership of the rfs folder didn't change the actual file content, so essentially all is intact. In fact, I verified that my dhob.bin and other files had the same md5sum in stock and lineage persist.

    The issue of the IMEI changing to zero has only happened when people have flashed Stock roms. All of the guides that I have seen, have included the following commands (and equivalent commands have been included in the TWRP flashable stock builds as well):
    Code:
    fastboot erase modemst1
    fastboot erase modemst2

    The partitions modemst1 and modemst2 are your EFS. Normally, if your persist is pure stock, if either is erased, the modem re-creates them. But, referring to the above about permissions, if the rfs user (which is presumably used by the modem) cannot access the files (because the owner of the files is someone else, and the permissions on the files mean that only the owner can access them), then the modem cannot recreate the EFS, and the IMEI is left as zero.

    4c) Restoring IMEI.

    Changing the ownership of your otherwise untouched persist allows the rfs user to access those files. Rebooting will result in the modem checking the EFS, and when it sees that it is still blank, it will recreate the IMEI.

    However, the dhob.bin file in persist is encrypted, and goes through some sort of hash check. You can only use your own dhob.bin to recreate the IMEI. This is why it is essential that you have your own persist, and no one else's will work.

    5) Other info

    Other things that may be good to know about this issue.

    5a) Why did flashing another device's persist fix Volte?
    Or rather, why did flashing another device's persist "fix Volte" at the expense of permanently breaking key functionality of your device?

    Flashing another device's persist gave the impression of working, but most probably this was due to one thing alone - the permissions on the persist partition of Moto devices is similar. That is, other Moto devices have rfs and hlos_rfs folders, and the owner is the same (both in name and AID - Android ID).

    So, after flashing a custom Oreo rom, then going back to stock, Volte would not work. However, if they hadn't erased modemst1/2 (EFS) they would still have IMEI, but other functionality would be broken (Volte, 4G, possibly others). Flashing the other persist changed the permissions to the right ones, and boom all of a sudden Volte worked. The regret comes after, when the user has erased EFS through an update or other flash.

    XDA:DevDB Information
    The Persist Project, Tool/Utility for the Moto G5 Plus

    Contributors
    NZedPred, rachitrawat

    Version Information
    Status: Stable

    Created 2018-08-05
    Last Updated 2018-09-15
    12
    Backing up your persist

    One thing that cannot be emphasized enough is that you must keep backups of your persist. (Your efs is even more important to backup if you no longer have your own persist.) Once backed up, make a copy on your PC or laptop, and keep a private cloud copy somewhere as well.

    Recent versions of TWRP have made it easy to back up your persist partition. Older versions may not have had native functionality to back it up, however there was also an alternative. Relevant details below.

    TWRP backup of persist (recommended)

    The official TWRP thread is below. You should consult this thread to check for the latest versions.
    [RECOVERY][OFFICIAL][potter] TWRP 3.2.2-0 touch recovery

    At the time of writing (2018-08-05), there was a special build made that fixed backing up with encryption. This is the one that I have used in my testing. Link below:
    https://forum.xda-developers.com/showpost.php?p=77207112&postcount=199

    You will see persist as an available option in Backup and Restore. The backup file will be called persist.ext4.win. It is in fact a tar archive, so you can extract it with tar if you want to examine the contents on your PC.

    Image backup of persist

    If you don't have TWRP handy, or an older version of it, you can instead use the dd command from a root shell (either within stock or within TWRP)

    The following can be used to create a backup and place it at /sdcard/persist.img:
    Code:
    dd if=/dev/block/bootdevice/by-name/persist of=/sdcard/persist.img

    The following can be used to restore a backup placed at /sdcard/persist.img:
    Code:
    dd if=/sdcard/persist.img of=/dev/block/bootdevice/by-name/persist

    dd backups are bit-perfect, and can also be mounted if you need to look at a filesystem from e.g. your PC.
    6
    You can find this guide in an always current version here:




    Which firmware should I download? I am from INDIA.
    Can you point me to any guide for flashing official factory images via fastboot? I am familiar with twrp methods

    Flashing signed stock firmware

    You need
    Latest signed stock firmware:
    Europe (RETEU):
    https://drive.google.com/file/d/13WuhoogtAdoincAyTwCLvRj0d-Z9kL0P/view?usp=sharing

    India (RETIN):
    https://mirrors.lolinet.com/firmwar...ubsidy-DEFAULT_regulatory-DEFAULT_CFC.xml.zip

    US (RETUS):
    https://mirrors.lolinet.com/firmwar...ubsidy-DEFAULT_regulatory-DEFAULT_CFC.xml.zip

    All other locations:
    https://mirrors.lolinet.com/firmware/moto/potter/official/

    flashallO.bat:
    https://www.dropbox.com/s/zfh67uzfle9hsco/flashallO.bat?dl=0

    Motorola drivers:
    https://drive.google.com/file/d/0B0WGdtNWubBJYnlDcWRBZXltanc/view?usp=sharing

    Mini ADB & Fastboot
    https://drive.google.com/file/d/1lLYfimKN1U5CJ9cfpTCkhtMiuG8EfXBZ/view?usp=sharing


    1) Download the 8.1.0_OPS28.85-17-6-2 firmware for your region (it's the last one for the Moto G5+ (potter), there won't be any updates anymore, so no risk of bootloader downgrading)

    2) Install Mini ADB & Fastboot (best place is the root directory of C: or wherever your OS resides).

    3) Extract the firmware to that ADB & Fastboot folder.

    4) Download my "flashallO.bat" and move it to that folder too.It removes the need for you to manually flash all partitions, just double-click it and it'll run all the commands for you.

    5) Download and install Motorola device drivers.The program is called "Motorola Device Manager".

    6) Reboot your phone to the bootloader. To do this, turn it off, then hold down the power and volume down buttons until you see a bugdroid undergoing open-heart surgery.
    7) Connect the phone to your PC with your USB cable. Type
    Code:
     fastboot devices
    to check if your device is connected. A serial number should be shown.
    8) Run the flashallO.bat script. (Caution: This will wipe your device completely!) It will take some time to flash, just be patient and don't worry.
    If the command window appears for a brief moment and then disappears, the device drivers may not be installed correctly. You can ask me in that case, there are some special drivers that may solve that.
    9) Once the command window closes, it should have completed the flashing process and you are safe to press the power key on the phone to start Android. Just make sure that the text near the buttons reads "START".

    That's it.

    You can save your (internal) data when you open the flashallO.bat and delete the command
    Code:
    fastboot erase userdata
    so that it will be omitted.
    I won't recommend it but it's possible.


    Rooting:

    You need:

    Magisk (at the moment 20.4 is actual):
    https://github.com/topjohnwu/Magisk
    For devices running android 11 use
    Magisk 21.1 (beta): https://github.com/topjohnwu/Magisk/releases/tag/v21.1

    TWRP 3.4.0:

    Maybe
    Disable_Dm-Verity_ForceEncrypt.zip:
    https://yadi.sk/d/HLr5vjnkA8gaqw

    - Download TWRP from the above link and place it in your ADB & Fastboot folder.
    - Download magisk.zip and Magisk Manager APK and place it in your internal storage.
    - Turn the phone off again and reboot to bootloader using previously mentioned key combination.
    - Navigate to the folder where you placed the TWRP image.
    - Hold down the "shift" key and right-click anywhere in the Explorer window,it should give you an option to "Open command window here."
    - Now input the command: "fastboot flash recovery [filename].img", where [filename] is the name of your TWRP image file. Tap Enter and it will take a few seconds to flash the new recovery.
    - Alternatively, you can use "fastboot boot [filename].img" to temporarily boot TWRP for the purpose of flashing Magisk. This retains the stock recovery.
    - Now that TWRP has been flashed, press the volume down key until you see the label on the side change to read "RECOVERY." At that point you can press the power button and you will boot right into TWRP.

    - If you decide to decrypt your device:
    In that case go to "Wipe" in TWRP and use "format data" (the option where you have to confirm with "yes"). Just wipe data is not enough!
    - If you want your device to stay encrypted skip that step.

    - Now press the "Install' button in TWRP and navigate to the location where the magisk.zip is located. Simply tap it and "Swipe to install."

    - If you decided to decrypt your device normally magisk should take care that it doesn't get encrypted again.
    Magisk only disables the enforced encryption flag, the device will still be encrypted and that's why a wipe of data is necessary to remove the encryption.

    If that's not the case and you get problems to reboot flash Disable_Dm-Verity_ForceEncrypt.zip after magisk.zip.

    More information about decryption/encryption:
    https://didgeridoohan.com/magisk/Magisk#hn_Disabling_dm-verity_and_forced_encryption

    - Reboot your device, if the Magisk Manager isn't installed already (it should) install the Magisk Manager APK.


    (I think I will make a tutorial out of this if users still need it)

    Thanks to @Jrhotrod for the rooting tutorial and other parts!

    Sent from my Moto G5 Plus using XDA Labs
    5
    Yes, applying OTA is what I wanted to say with "trouble in the future". If EFS (which seems to be in fact modemst1 and 2) will be erased the IMEI may be gone again without having a correct persist file.
    From what I read in a thread about flashing/sideloading the Oreo soak update for the Cedric device (Yes, someone uploaded it there) for some users the IMEI is gone after flashing latest 7.0 but returns after flashing the 8.1 soak update.
    As this device is almost similar to potter there's a chance that stock Oreo fixes the whole problem.

    And I agree, I never had a device that caused so much problems when switching between custom ROMs and stock firmware. I'm fortunately not affected as I have been on stock until now but I'm thankful that @NZedPred spent so much time and
    commitment to find the cause of it all and if I ever decide to check some custom ROM I have my persist backup saved.

    Sent from my Moto G5 Plus using XDA Labs
    I did a TWRP flashable for the Cedric Oreo soak test (keeping my skills up :D). And yes, Oreo changes the ownership, and downgrading to Nougat causes problems until users apply the persist fix, or go back to another Oreo rom. Really Nougat should have been changing the ownership on the folders, and this mess wouldn't have happened.
    4
    I am going to say right now that I am speechless.

    I thought that there was ultimately no hope for getting this issue solved, and that the efforts of @rachitrawat were in vain. I thought that I was going to have a dud device that could never be restored to stock and resold. But along comes @NZedPred, who in the past months has earned my utmost respect through being helpful, friendly, and having a very impressive amount of knowledge! I never thought that I would just hop onto XDA one day and see this issue that has plagued so many devices SOLVED! It completely and totally worked for me!

    I am so grateful to both Rachit and NZedPred for figuring this issue out... along with the people who helped them by providing information from their own devices! The potter community is ecstatic for this new development and now I can finally go back to stock if I ever want to.

    Thanks again!

    @Jrhotrod, you have made my day with this message. Quite often we developers (well, I don't consider myself a developer, just someone who is good with technology, and good at working through problems, I digress...) toil away and all we get is an incremental count on the thanks meter. The amount of time we then spend trying to help those that we couldn't actually help, outweighs the recognition that we get from those that we could. Thank you for your kind words!