Project

General

Profile

BackupTheEFS » History » Version 28

Denis 'GNUtoo' Carikli, 10/27/2020 02:58 PM
Make the first parts more generic to be able to move them or share them with other backup articles

1 1 Denis 'GNUtoo' Carikli
h1. How to backup the EFS
2
3
Many devices supported by Replicant have a partition with the modem data (IMEI, etc) which is called EFS.
4
5 14 Mark Matney
It's a good idea to do a backup of this partition so that you can restore it if it becomes corrupted, which "can sometimes happen with Replicant":https://redmine.replicant.us/issues/1869.
6 1 Denis 'GNUtoo' Carikli
7 14 Mark Matney
The actual backup process is run while the [[RecoveryImage|Replicant recovery]] is booted (rather than Replicant itself) to ensure that the modem data partition is not modified during the backup.
8
9
{{TOC}}
10
11
h2. Prerequisites
12
13
h3. Ensure that your device has a modem data partition
14
15 1 Denis 'GNUtoo' Carikli
Only the following devices that are supported by Replicant have a modem data partition (EFS):
16 26 Denis 'GNUtoo' Carikli
* [[GalaxyS2I9100|Galaxy S 2 (GT-I9100)]]
17
* [[GalaxyS3I9300|Galaxy S 3 (GT-I9300)]]
18
* [[GalaxyS3I9305|Galaxy S 3 4G (GT-I9305)]]
19
* [[GalaxyNexusI9250|Galaxy Nexus (GT-I9250)]]
20
* [[GalaxyNoteN7000|Galaxy Note (GT-N7000)]]
21
* [[GalaxyNote2N7100|Galaxy Note 2 (GT-N7100)]]
22
* [[GalaxyTab270P31xx|Galaxy Tab 2 7.0 (GT-P3100)]]
23
* [[GalaxyTab2101P51xx|Galaxy Tab 2 10.1 (GT-P5100)]]
24
* [[GalaxyNote80N51xx|Galaxy Note 8.0 (GT-N5100)]]
25 1 Denis 'GNUtoo' Carikli
26 21 Denis 'GNUtoo' Carikli
If your device is not listed above, it probably doesn't have a modem data partition. In that case, you don't need to backup something that doesn't exist, so you can ignore these instructions.
27
28 22 Denis 'GNUtoo' Carikli
This can be the case for devices without a modem like the WiFi versions of the tablets supported by Replicant, or for future devices that aren't supported yet at the time of writing.
29 1 Denis 'GNUtoo' Carikli
30 14 Mark Matney
h2. Setup ADB
31 1 Denis 'GNUtoo' Carikli
32 14 Mark Matney
Follow the instructions for [[ADB|setting up ADB on your computer]] so that you can access a root shell on your device.
33 1 Denis 'GNUtoo' Carikli
34 28 Denis 'GNUtoo' Carikli
*NOTE*: when prompted on your Replicant device, make sure that you check the box that says *Always allow from this computer* when you grant your computer USB debugging permissions. Otherwise, you will be unable to obtain root shell access on your Replicant device when you reboot it into the recovery OS to actually perform the backup.
35 1 Denis 'GNUtoo' Carikli
36 28 Denis 'GNUtoo' Carikli
*NOTE*: for security reasons, you may want to [[BackupTheEFS#Revoke-USB-debugging-permissions|revoke these non-expiring permissions]] once the backup is complete.
37 1 Denis 'GNUtoo' Carikli
38 14 Mark Matney
h2. Reboot into the recovery
39 1 Denis 'GNUtoo' Carikli
40 14 Mark Matney
You can reboot your device into the recovery by one of the following methods:
41 1 Denis 'GNUtoo' Carikli
42 14 Mark Matney
h3. Using ADB
43 1 Denis 'GNUtoo' Carikli
44 14 Mark Matney
Run the following on your computer:
45 1 Denis 'GNUtoo' Carikli
46 14 Mark Matney
<pre>
47
adb reboot recovery
48
</pre>
49 1 Denis 'GNUtoo' Carikli
50 14 Mark Matney
h3. Using your Replicant device's user interface
51 1 Denis 'GNUtoo' Carikli
52 14 Mark Matney
Do the following:
53 1 Denis 'GNUtoo' Carikli
54 14 Mark Matney
# Make sure that your device is booted under Replicant.
55
# Press the power button until a menu appears.
56 16 Mark Matney
# Press *Reboot*.
57
# Select *Recovery* and then press *ok*.
58 3 Denis 'GNUtoo' Carikli
59 14 Mark Matney
h2. Ensure that your device's system partition is mounted
60 3 Denis 'GNUtoo' Carikli
61 14 Mark Matney
In order to get a root shell in the recovery, your devices system partition must be mounted.
62 3 Denis 'GNUtoo' Carikli
63 14 Mark Matney
On certain devices, "the system partition is already mounted":https://redmine.replicant.us/issues/1934, so you might already be able to get a root shell without mounting the system partition again.
64 1 Denis 'GNUtoo' Carikli
65 14 Mark Matney
In any case, it's still best to do the following to make sure that the system partition is mounted:
66
67 16 Mark Matney
# Select *Advanced*.
68
# Select *Mount /system*.
69 14 Mark Matney
# Press the back key to get back to the general menu.
70
71 23 Denis 'GNUtoo' Carikli
h2. Copy and pasting commands
72
73
The next sections will have commands that you can copy and paste. To ensure that they work correctly it's best to:
74
* Type them in the same terminal window
75
* Copy/paste one line at the same time. For instance if you copy 10 lines and just paste then, in some cases you could have some issues.
76
77 24 Denis 'GNUtoo' Carikli
Also to make sure that they are really executed, you can press the 'enter' key after having pasted them. 
78 23 Denis 'GNUtoo' Carikli
79 24 Denis 'GNUtoo' Carikli
Pressing 'enter' twice will not hurt as the command will still be executed only once.
80 23 Denis 'GNUtoo' Carikli
81 14 Mark Matney
h2. Backup the modem data partition
82
83
First, create a directory on your computer where you will store the backup data. One way to keep this data organized is with a directory for each device named with its serial number (useful if you have more than one Replicant device):
84
85 23 Denis 'GNUtoo' Carikli
You can do this with the following commands:
86 1 Denis 'GNUtoo' Carikli
<pre>
87 14 Mark Matney
REPLICANT_EFS_BACKUP_DIR=~/replicant_devices/0123456789abcdef/backup_efs
88
mkdir -p $REPLICANT_EFS_BACKUP_DIR && cd $REPLICANT_EFS_BACKUP_DIR
89
</pre>
90
91
The remaining steps you must take depends on which device you have.
92
93 27 Denis 'GNUtoo' Carikli
h3. Galaxy S 2 (I9100), Galaxy S 3 (I9300), Galaxy S 3 4G (I9305), Galaxy Note (N7000), or Galaxy Note 2 (N7100), Galaxy Note 8.0 GSM (GT-N5100)
94 14 Mark Matney
95
While inside the backup directory you just created, run the following commands:
96
97
<pre>
98 1 Denis 'GNUtoo' Carikli
adb shell "mkdir /efs"
99
adb shell "mount /dev/block/platform/*/by-name/EFS /efs"
100
adb pull /efs/ efs
101
adb shell "umount /efs"
102 15 Mark Matney
adb shell "rmdir /efs"
103 18 Denis 'GNUtoo' Carikli
adb shell "cat /dev/block/platform/*/by-name/EFS > /EFS.img"
104
adb pull /EFS.img ./
105 1 Denis 'GNUtoo' Carikli
</pre>
106
107 14 Mark Matney
h3. Galaxy Nexus (I9250)
108
109
While inside the backup directory you just created, run the following commands:
110
111 1 Denis 'GNUtoo' Carikli
<pre>
112
adb shell "mkdir /efs"
113
adb shell "mount /dev/block/platform/*/*/by-name/efs /efs"
114
adb pull /efs/ efs
115
adb shell "umount /efs"
116
adb shell "rmdir /efs"
117 18 Denis 'GNUtoo' Carikli
adb shell "cat /dev/block/platform/*/*/by-name/efs > /efs.img"
118
adb pull /efs.img ./
119 1 Denis 'GNUtoo' Carikli
</pre>
120
121 14 Mark Matney
h3. Galaxy Tab 2 7.0 (P3100)
122
123
While inside the backup directory you just created, run the following commands:
124
125 1 Denis 'GNUtoo' Carikli
<pre>
126
adb shell "mkdir /efs"
127 11 Denis 'GNUtoo' Carikli
adb shell "mount /dev/block/platform/*/*/by-name/EFS /efs"
128 1 Denis 'GNUtoo' Carikli
adb pull /efs/ efs
129
adb shell "umount /efs"
130
adb shell "rmdir /efs"
131 18 Denis 'GNUtoo' Carikli
adb shell "cat /dev/block/platform/*/*/by-name/EFS > /EFS.img"
132
adb pull /EFS.img ./
133 11 Denis 'GNUtoo' Carikli
</pre>
134
135 14 Mark Matney
This will create a copy of the contents of /efs in the backup directory. It will also backup the full partition.
136 11 Denis 'GNUtoo' Carikli
Keep these files around as a backup in case anything goes wrong.
137
138 14 Mark Matney
*NOTE*: if your device has an EFS and is not mentioned in the instructions above, please contact us through the "mailing list":https://lists.osuosl.org/mailman/listinfo/replicant so we could add instructions for your device.
139 11 Denis 'GNUtoo' Carikli
140 14 Mark Matney
h2. Reboot your device
141 1 Denis 'GNUtoo' Carikli
142 25 Denis 'GNUtoo' Carikli
Once the backup is done, you can reboot your device into Replicant by one of two ways.
143 14 Mark Matney
144 25 Denis 'GNUtoo' Carikli
You can reboot by running the following command on your computer:
145 14 Mark Matney
<pre>
146
adb reboot
147
</pre>
148
149 25 Denis 'GNUtoo' Carikli
Or alternatively you can use the Replicant recovery graphical user interface to reboot by selecting *Reboot system now*.
150 14 Mark Matney
151
h2. Revoke USB debugging permissions
152
153
If you are concerned about security, you may want to revoke the non-expiring USB debugging permissions that you granted to your computer earlier (which you may of course grant again at any time, as desired). This control is located at *Settings* > *Developer options* > *Revoke USB debugging authorizations*.
154
155
That's it! Your device's EFS partition is now backed up. Your device should be running Replicant normally again.
156 19 Denis 'GNUtoo' Carikli
157
h1. See also
158
159
* The [[BackupsResearch]] page has information on why the backup is done this way. It might also be useful to read and contribute to it if you intend to change the way the EFS backups are done.