Skip to content

Instantly share code, notes, and snippets.

@karlding
Created May 8, 2016 21:16
Show Gist options
  • Save karlding/1037d038bc7b8ff65a40db1f8f80a3ba to your computer and use it in GitHub Desktop.
Save karlding/1037d038bc7b8ff65a40db1f8f80a3ba to your computer and use it in GitHub Desktop.
How to flash a new Android Factory Image, and various tips and tricks post-installation

Android fastboot flashing

Here are some instructions on how to successfully flash a new Android System Image.

Preparation

First download and extract the Android System Image that you want to flash. I'll be using hammerhead-mob30h, which is the May security update for my Nexus 5 (2013).

Extract the archive and enter the directory. You'll also want to extract the image-*.zip file as well (image-hammerhead-mob30h.zip in my case), which contains the other img files.

cd ~/Downloads/image-hammerhead-mob30h

Reboot our device into fastboot mode so we can begin flashing the new image.

adb reboot-bootloader

At this point, your device should restart and you'll end up in fastboot mode.

Note: If you haven't set up adb before, you might have to accept the prompt on your device to trust your computer's key.

Flashing the Factory Image ROM

Flash the bootloader, replacing bootloader-hammerhead-hhz20f.img with the bootloader image.

fastboot flash bootloader bootloader-hammerhead-hhz20f.img

Now reboot the bootloader

fastboot reboot-bootloader

Flash the radio, replacing radio-hammerhead-m8974a-2.0.50.2.29.img with the radio image.

fastboot flash radio radio-hammerhead-m8974a-2.0.50.2.29.img

Flash the boot image.

fastboot flash boot boot.img

Flash the system image. This will take a while since it is the largest image, so don't panic if it takes a few minutes.

fastboot flash system system.img

If you're using the stock recovery, you might want to flash the recovery image. Otherwise, if you're using something like TWRP, flash that instead.

fastboot flash recovery recovery.img

If flashing a new system image is all you wanted, and you don't wish to install root/Xposed, then we're done. Reboot into the Android system.

fastboot reboot

Note: Technically, it is only necessary to flash whatever images have changed between versions. Here we assumed that everything has changed.

Post-Installation

If you're like me, you also want to do some things after flashing the new ROM.

TWRP, Root and Xposed Framework

I'll be using TWRP to flash ChainFire's systemless root and the Xposed ZIP archives.

Since I didn't flash TWRP and I use the stock recovery, I use fastboot to boot into TWRP.

cd ~/Downloads
fastboot boot twrp-3.0.0-0-hammerhead.img

Now select whatever ZIP files you want to install and flash them using TWRP, then hit Reboot System.

Note: If you're using an older version of TWRP and are using the systemless root, make sure you don't follow the prompt and install SuperSU.

Disabling System Notification Sounds

Finally, I like to disable all the audio notification sounds. I haven't managed to find a setting in the Android system to toggle notification sounds, so I use chmod and just deny the permissions. Once Android has finished optimizing all your apps, get an adb shell and obtain root—you may have to accept the SuperSU prompt.

adb shell
su

Now that we're root, mount the Android /system partition with read/write permissions, as we are going to change the permissions of the audio notification files using chmod so that they can't be read by the OS. The audio notification files are stored under /system/media/audio/ui.

mount -o rw,remount,rw /system
cd /system/media/audio/ui
chmod 000 *.ogg

Now unmount the /system partition and exit the root adb shell.

mount -o ro,remount,ro /system
exit
exit

Done! At this point, feel free to install AdAway and whatever other Xposed modules.

@Ouermimohamed
Copy link

J'ai rooter mon téléphone et j'ai installé twrp je veux installé une rom img je vois pas système image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment