Project

General

Profile

BackupTheEFS » History » Version 37

Denis 'GNUtoo' Carikli, 11/09/2020 08:18 PM

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 29 Denis 'GNUtoo' Carikli
* [[GalaxyS2I9100|Galaxy S II (GT-I9100)]]
17
* [[GalaxyS3I9300|Galaxy S III (GT-I9300)]]
18
* [[GalaxyS3I9305|Galaxy S III 4G (GT-I9305)]]
19 26 Denis 'GNUtoo' Carikli
* [[GalaxyNexusI9250|Galaxy Nexus (GT-I9250)]]
20
* [[GalaxyNoteN7000|Galaxy Note (GT-N7000)]]
21 34 Denis 'GNUtoo' Carikli
* [[GalaxyNote2N7100|Galaxy Note II (GT-N7100)]]
22 26 Denis 'GNUtoo' Carikli
* [[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 36 Denis 'GNUtoo' Carikli
*NOTE*: for security reasons, you may want to [[ADB#Revoking-all-computers-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 37 Denis 'GNUtoo' Carikli
To reboot in the recovery, you can follow the instructions in the [[RebootIntoTheRecovery]] wiki page.
41 3 Denis 'GNUtoo' Carikli
42 14 Mark Matney
h2. Ensure that your device's system partition is mounted
43 3 Denis 'GNUtoo' Carikli
44 14 Mark Matney
In order to get a root shell in the recovery, your devices system partition must be mounted.
45 3 Denis 'GNUtoo' Carikli
46 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.
47 1 Denis 'GNUtoo' Carikli
48 14 Mark Matney
In any case, it's still best to do the following to make sure that the system partition is mounted:
49
50 16 Mark Matney
# Select *Advanced*.
51
# Select *Mount /system*.
52 14 Mark Matney
# Press the back key to get back to the general menu.
53
54 23 Denis 'GNUtoo' Carikli
h2. Copy and pasting commands
55
56
The next sections will have commands that you can copy and paste. To ensure that they work correctly it's best to:
57
* Type them in the same terminal window
58
* 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.
59
60 24 Denis 'GNUtoo' Carikli
Also to make sure that they are really executed, you can press the 'enter' key after having pasted them. 
61 23 Denis 'GNUtoo' Carikli
62 24 Denis 'GNUtoo' Carikli
Pressing 'enter' twice will not hurt as the command will still be executed only once.
63 23 Denis 'GNUtoo' Carikli
64 14 Mark Matney
h2. Backup the modem data partition
65
66
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):
67
68 23 Denis 'GNUtoo' Carikli
You can do this with the following commands:
69 1 Denis 'GNUtoo' Carikli
<pre>
70 14 Mark Matney
REPLICANT_EFS_BACKUP_DIR=~/replicant_devices/0123456789abcdef/backup_efs
71
mkdir -p $REPLICANT_EFS_BACKUP_DIR && cd $REPLICANT_EFS_BACKUP_DIR
72
</pre>
73
74
The remaining steps you must take depends on which device you have.
75
76 34 Denis 'GNUtoo' Carikli
h3. Galaxy S 2 (GT-I9100), Galaxy S III (GT-I9300), Galaxy S III 4G (GT-I9305), Galaxy Note (GT-N7000), or Galaxy Note II (GT-N7100), Galaxy Note 8.0 GSM (GT-GT-N5100)
77 14 Mark Matney
78
While inside the backup directory you just created, run the following commands:
79
80
<pre>
81 1 Denis 'GNUtoo' Carikli
adb shell "mkdir /efs"
82
adb shell "mount /dev/block/platform/*/by-name/EFS /efs"
83
adb pull /efs/ efs
84
adb shell "umount /efs"
85 15 Mark Matney
adb shell "rmdir /efs"
86 18 Denis 'GNUtoo' Carikli
adb shell "cat /dev/block/platform/*/by-name/EFS > /EFS.img"
87
adb pull /EFS.img ./
88 1 Denis 'GNUtoo' Carikli
</pre>
89
90 31 Denis 'GNUtoo' Carikli
h3. Galaxy Nexus (GT-I9250)
91 14 Mark Matney
92
While inside the backup directory you just created, run the following commands:
93
94 1 Denis 'GNUtoo' Carikli
<pre>
95
adb shell "mkdir /efs"
96
adb shell "mount /dev/block/platform/*/*/by-name/efs /efs"
97
adb pull /efs/ efs
98
adb shell "umount /efs"
99
adb shell "rmdir /efs"
100 18 Denis 'GNUtoo' Carikli
adb shell "cat /dev/block/platform/*/*/by-name/efs > /efs.img"
101
adb pull /efs.img ./
102 1 Denis 'GNUtoo' Carikli
</pre>
103
104 32 Denis 'GNUtoo' Carikli
h3. Galaxy Tab 2 7.0 (GT-P3100)
105 14 Mark Matney
106
While inside the backup directory you just created, run the following commands:
107
108 1 Denis 'GNUtoo' Carikli
<pre>
109
adb shell "mkdir /efs"
110 11 Denis 'GNUtoo' Carikli
adb shell "mount /dev/block/platform/*/*/by-name/EFS /efs"
111 1 Denis 'GNUtoo' Carikli
adb pull /efs/ efs
112
adb shell "umount /efs"
113
adb shell "rmdir /efs"
114 18 Denis 'GNUtoo' Carikli
adb shell "cat /dev/block/platform/*/*/by-name/EFS > /EFS.img"
115
adb pull /EFS.img ./
116 11 Denis 'GNUtoo' Carikli
</pre>
117
118 14 Mark Matney
This will create a copy of the contents of /efs in the backup directory. It will also backup the full partition.
119 11 Denis 'GNUtoo' Carikli
Keep these files around as a backup in case anything goes wrong.
120
121 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.
122 11 Denis 'GNUtoo' Carikli
123 14 Mark Matney
h2. Reboot your device
124 1 Denis 'GNUtoo' Carikli
125 25 Denis 'GNUtoo' Carikli
Once the backup is done, you can reboot your device into Replicant by one of two ways.
126 14 Mark Matney
127 25 Denis 'GNUtoo' Carikli
You can reboot by running the following command on your computer:
128 14 Mark Matney
<pre>
129
adb reboot
130
</pre>
131
132 25 Denis 'GNUtoo' Carikli
Or alternatively you can use the Replicant recovery graphical user interface to reboot by selecting *Reboot system now*.
133 14 Mark Matney
134
h2. Revoke USB debugging permissions
135
136 35 Denis 'GNUtoo' Carikli
If you don't need @USB debugging permissions@ anymore, it might be a good idea to remove them. The [[ADB#Revoking-all-computers-USB-debugging-permissions|Revoking all computer's USB debugging permissions]] section in the ADB wiki page explains how to do that.
137 14 Mark Matney
138
That's it! Your device's EFS partition is now backed up. Your device should be running Replicant normally again.
139 19 Denis 'GNUtoo' Carikli
140
h1. See also
141
142 33 Denis 'GNUtoo' Carikli
* 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 backups are done.