I have done this many times successfully and without any errors. I have only tested this with a GNex and MIUIAndroid and MIUI.us. This method will NOT work with MIUI.us. The install script in MIUI.us needs to do something with the /data partition and the /data partition will not mount because it is encrypted; therefore the install script fails and does not complete correctly. You might be able to customise the script to work, but that is beyond the scope of this post at the moment.
For this example, let's say we want to upgrade from MIUI 2.7.6 to MIUI 2.7.13. This is just an arbitrary version I picked, it should work with any MIUIv4 to MIUIv4. Currently, MIUI 2.7.6 is installed on your phone and you have chosen to enable full device encryption. You have probably already noticed that you cannot mount your sdcard or your data partition which means you cannot update your OS using CWM functions.
Risks:
This method cannot and will not "brick" your phone. We are only messing with the /system partition here. However, if you need to return your phone to stock for whatever reason (like you've decided to disable encryption) then that process will wipe your sdcard. Make sure you have backups in an encrypted form. Titanium Backup has an encryption option and you can send your encrypted backups to a cloud account (like GDrive, Dropbox, etc). You could also store your backup sdcard data in a Truecrypt container on your PC. Just remember to keep it encrypted, otherwise why even bother with phone encryption in the first place?
You will NOT be able to make a nandroid backup of your phone. That is a function of your custom recovery and your recovery will not be able to make backups of your /data partition (where all your apps, settings, and data are stored) because it cannot open those encrypted partitions.
What you will need:
adb (Here are some instructions on how to install and basic instructions on pushing files via adb: http://prepaidandroid.org/index.php?title=How_to_push_files_to_your_SD_Card_with_ADB)
Your ROM zip file that needs to be applied (this needs to be a file on your PC)
Custom Recovery on Phone
How to upgrade:
You must have your phone booted into your custom recovery.
1) Extract and copy the files update-binary and updater-script from your ROM (you must have a copy of this file still in your ROM zip).
a) Open the ROM zip file in winrar, 7zip, or any program that allows you to manipulate zip files.
b) Find the update-binary and updater-script usually found here: /miui.zip/META-INF/com/google/android/ and copy those two files to the same folder that contains the zip file.
2) Plug your phone into your computer via USB.
3) Now pull up an adb shell and mount /system in rw mode.
a) Find where you installed the android-sdk. Open two command prompts. In BOTH of them navigate to the android-sdk/platform-tools/ folder.
For a Windows example:
For a *nix example:
b) Once you are there, run the command
. You should now see a prompt with this symbol: #. That means you are on a root command prompt on your phone. Now type
. If you wish, you can use this window to watch activity for errors by typing
and simply press Control+C when you're done watching the log.
4) Now push the binary, script and zip from your PC to your /system partition in a separate adb window.
a) In your other window, type
. This may take a minute and will say nothing until it completes or fails. When it has completed type
and finally push the updater-script with
.
Notice the slashes, use \ on Windows and / for the phone and Linux systems. The trailing / behind system MUST BE THERE or you will overwrite the directory /system/ and cause troubleshooting to start.
5) In your adb shell window, run the update binary.
a) You should still have your other window up with the adb shell still up (with the # prompt). In your adb shell type
. Now type
,
, and finally
hitting enter after each command. Your last command will be
and you should see the progress in the prompt.
6) After it is completed type
in the adb shell and then unplug your phone when it is rebooting. You should be done. Hopefully it boots fine where you will type in your PIN/Password and then complete booting into your updated MIUI install!
Troubleshooting:
If your phone is boot looping, you may have simply had a bad install. I've experienced this and the solution I used was to re-download the zip file and do the process over again with the new file.
I accidentally forgot the trailing slash and overwrote the /system/ folder! It's ok. You have lost your data on /system, but you were doing that with an update anyway right? Simply open an adb shell just like we did in the instructions above (with the # prompt) and type
and then
and now you have an empty folder called /system/ and you can put all your files in there and run your update as above.
Encryption Help: If you are encrypting your phone and your phone just reboots without applying encryption, I got mine to complete successfully by going back to stock firmware (which erases ALL of your data, even your sdcard), flashing recovery, then flashing MIUI, choosing fix permissions in recovery and then immediately choosing to encrypt after boot up before I start messing with restoring backups or my settings. You'll know if your phone is not applying encryption if the Android pops up after you choose but you do NOT get a progress bar and it reboots. If your encryption is coming along fine then you will see a progress bar moving slowly above the Android.
Encryption Failure Question: When the encryption process was failing my logcat said that it was failing to mount /data (even sometimes when /data was as close to being empty as possible and I had a new flash). What can I do about it?
I haven't figured out why this happens, but my only solution to this was to rinse and repeat the steps under encryption help.
---------
It took me a few hours to figure this out the first time, but eventually I got it down to 10 minutes by knowing what I had to do. After you get the hang of this, it really is not a big deal at all to upgrade (even weekly)! I hope this guide helped you and please let me know of any errors in the guide or trouble you have following it. Thanks to the MIUI and MIUIAndroid teams for the great ROM!
For this example, let's say we want to upgrade from MIUI 2.7.6 to MIUI 2.7.13. This is just an arbitrary version I picked, it should work with any MIUIv4 to MIUIv4. Currently, MIUI 2.7.6 is installed on your phone and you have chosen to enable full device encryption. You have probably already noticed that you cannot mount your sdcard or your data partition which means you cannot update your OS using CWM functions.
Risks:
This method cannot and will not "brick" your phone. We are only messing with the /system partition here. However, if you need to return your phone to stock for whatever reason (like you've decided to disable encryption) then that process will wipe your sdcard. Make sure you have backups in an encrypted form. Titanium Backup has an encryption option and you can send your encrypted backups to a cloud account (like GDrive, Dropbox, etc). You could also store your backup sdcard data in a Truecrypt container on your PC. Just remember to keep it encrypted, otherwise why even bother with phone encryption in the first place?
You will NOT be able to make a nandroid backup of your phone. That is a function of your custom recovery and your recovery will not be able to make backups of your /data partition (where all your apps, settings, and data are stored) because it cannot open those encrypted partitions.
What you will need:
adb (Here are some instructions on how to install and basic instructions on pushing files via adb: http://prepaidandroid.org/index.php?title=How_to_push_files_to_your_SD_Card_with_ADB)
Your ROM zip file that needs to be applied (this needs to be a file on your PC)
Custom Recovery on Phone
How to upgrade:
You must have your phone booted into your custom recovery.
1) Extract and copy the files update-binary and updater-script from your ROM (you must have a copy of this file still in your ROM zip).
a) Open the ROM zip file in winrar, 7zip, or any program that allows you to manipulate zip files.
b) Find the update-binary and updater-script usually found here: /miui.zip/META-INF/com/google/android/ and copy those two files to the same folder that contains the zip file.
2) Plug your phone into your computer via USB.
3) Now pull up an adb shell and mount /system in rw mode.
a) Find where you installed the android-sdk. Open two command prompts. In BOTH of them navigate to the android-sdk/platform-tools/ folder.
For a Windows example:
Code:
cd C:\Program Files (x86)\android\android-sdk\platform-tools\
Code:
cd /home/user/android-sdk/platform-tools/
b) Once you are there, run the command
Code:
adb shell
Code:
mount /system
Code:
adb logcat
4) Now push the binary, script and zip from your PC to your /system partition in a separate adb window.
a) In your other window, type
Code:
adb push C:\wherever\zip\is\MIUI-2.7.13.zip /system/
Code:
adb push C:\find\update-binary /system/
Code:
adb push C:\find\updater-script /system/
Notice the slashes, use \ on Windows and / for the phone and Linux systems. The trailing / behind system MUST BE THERE or you will overwrite the directory /system/ and cause troubleshooting to start.
5) In your adb shell window, run the update binary.
a) You should still have your other window up with the adb shell still up (with the # prompt). In your adb shell type
Code:
cd /system/
Code:
chmod a+rwx ./MIUI-2.7.33.zip
Code:
chmod a+rwx ./update-binary
Code:
chmod a+rwx ./updater-script
Code:
./update-binary 2 stdout /system/MIUI-2.7.13.zip
6) After it is completed type
Code:
reboot
Troubleshooting:
If your phone is boot looping, you may have simply had a bad install. I've experienced this and the solution I used was to re-download the zip file and do the process over again with the new file.
I accidentally forgot the trailing slash and overwrote the /system/ folder! It's ok. You have lost your data on /system, but you were doing that with an update anyway right? Simply open an adb shell just like we did in the instructions above (with the # prompt) and type
Code:
rm /system
Code:
mkdir /system/
Encryption Help: If you are encrypting your phone and your phone just reboots without applying encryption, I got mine to complete successfully by going back to stock firmware (which erases ALL of your data, even your sdcard), flashing recovery, then flashing MIUI, choosing fix permissions in recovery and then immediately choosing to encrypt after boot up before I start messing with restoring backups or my settings. You'll know if your phone is not applying encryption if the Android pops up after you choose but you do NOT get a progress bar and it reboots. If your encryption is coming along fine then you will see a progress bar moving slowly above the Android.
Encryption Failure Question: When the encryption process was failing my logcat said that it was failing to mount /data (even sometimes when /data was as close to being empty as possible and I had a new flash). What can I do about it?
I haven't figured out why this happens, but my only solution to this was to rinse and repeat the steps under encryption help.
---------
It took me a few hours to figure this out the first time, but eventually I got it down to 10 minutes by knowing what I had to do. After you get the hang of this, it really is not a big deal at all to upgrade (even weekly)! I hope this guide helped you and please let me know of any errors in the guide or trouble you have following it. Thanks to the MIUI and MIUIAndroid teams for the great ROM!