Posts Install a custom Android ROM

Install a custom Android ROM

Some important facts

  • Please read the whole article before doing anything.
  • Your battery charge should be at least >50% before starting the installation.
  • You should know how to use a terminal in Linux.
  • Every device may need some tweaks and startpaging aka. googeling.
  • If you find any mistakes in this article please send me an email.

Use at your own risk

We cannot be blamed in case you brick the phone nor in case you lose any important data file in the process.

Install adb

  • Ubuntu/ Kali Linux:
    • $ sudo apt-get install adb
    • $ sudo apt-get install fastboot
  • Arch Linux
    • $ sudo pacman -Syy android-tools

Other tools

  • If you have a Samsung device you also need to install Heimdall
    • Ubuntu/ Kali Linux
      • $ sudo apt-get install heimdall-flash
    • Arch Linux
      • $ sudo pacman -Syy heimdall


  • Backup your data before doing anything. If you want to use the terminal to backup your photos etc. you can use adb:
    • First you need to allow USB Debugging. To do this go to Settings -> About and scroll down to Build number and press it several times until you become developer. Then go to Settings -> Developer options and enable USB debugging (Android debugging).
    • Now you can connect your phone via USB cable to your computer. If you run $ adb devices you should see that one device is connected. Then run $ adb shell to get a shell on you Android phone and look for files you want to backup. You can exit the shell with $ exit. In your computer terminal you can run $ adb pull <remote> <local> to copy files from your phone to your local computer.
      • Your probably find your files in /storage/self/primary

Download LineageOS or another custom Android ROM

Install Custom Recovery without root

  • Download the specific custom recovery image for your device at TWRP
    • To verify the image take a look at their FAQ
  • Boot in bootloader mode by running $ adb reboot bootloader
    • alternative you can power off your device and press a device specific key combo to start the bootloader
      • for Nexus devices this should be: volume down + power button
      • for Samsung devices this should be: volume down + home button + power button
  • Flash the custom recovery:
    • Non Samsung:
      • First unlock the bootloader with $ sudo fastboot oem unlock and then reboot it. You have to re-enable USB debugging.
      • Then flash the revocery image with$ sudo fastboot flash recovery twrp.img
    • Samsung: $ heimdall flash --RECOVERY twrp.img --no-reboot
  • Now power off your device and then boot in recovery mode. Again you need to press a device specific key combo to enter custom recovery.
    • for Nexus devices this should be: volume up + power button, alternative you can choose in the bootloader mode to restart in recovery mode.
    • for Samsung devices this should be: volume up + home button + power button.
  • Many devices will remove custom recovery if the system is booted and not directly custom recovery. You may have to reinstall the custom recovery. If you have a custom ROM installed, custom recovery won’t be removed anymore.

Install custom ROM - Option 1

  • All steps below are done while being in custom recovery.
  • First we need to push the zip file, we have downloaded a few steps earlier, to our phone. We use adb to do it. With $ adb push <local> <remote> you can upload it to your USB connected phone. Upload it to your internal storage by using:
    • $ adb push /sdcard
  • Select Wipe and confirm the factory reset process, alternative you can also wipe your internal storage by using Advanced Wipe.
  • Select install and choose the custom ROM, the zip file we have just uploaded and confirm the installation process.
  • Reboot system. TWRP may ask you to install itself as an app but you can deny it.

Install custom ROM - Option 2

  • This way is a bit faster.
  • While being in custom recovery go to Advanced -> ADB Sideload. Check Wipe Dalvik Cache, Wipe Cache and then swipe to start the sideload. Then go to your computer and run $ adb sideload <local> with <local> being the custom ROM zip file.
  • Wait until TWRP says it is finished. The percentage on the computer terminal may be inacurrate. There may be a message that no ROM was installed but you can ignore it, the ROM should have been installed.
  • Reboot system. TWRP may ask you to install itself as an app but you can deny it.


To update your phone you can follow the same steps. Download the new and use Option 2 to sideload your new ROM to your phone. I recommend doing this way because I had some problems with updating LineageOS with the Updater that can be found under Settings -> About phone -> LineageOS updates.

Useful adb commands

  • Settings -> Developer Options -> Enable USB Debugging
  • Useful commands:
    $ adb devices
    $ adb connect <host>[:<port>]
    $ adb push <local> <remote>
    $ adb pull <remote> <local>
    $ adb shell

Encrypt your phone

  • In Android the encryption password is tied to your password you use to unlock your screen. This hampers us to use a good encryption password. But you can choose a simple pin to unlock your screen and change your encryption password to a much better one using adb.
  • Enable USB Debugging and Root access via adb in developer options. Connect your phone to your computer. We need to enter the root shell by first running $ adb root and then $ adb shell. But first you need to allow root access via adb shell by checking Settings -> Developer options -> Root access -> ADB only.
  • In the adb shell you can now change your encryption password without changing you pin to unlock your screen with the following command:
    • # vdc cryptfs changepw password "currentpasswd" "newpasswd"
  • And you can verify the password with:
    • # vdc cryptfs verifypw "yourpass"
    • If you have entered the correct password there should be a 0 at the end of the output otherwise 1.


  • adb has no permissions when trying to sideload a new ROM version
      $ adb devices
      List of devices attached
      02c438ce0ede8404	no permissions; see []
    • Shutdown the adb server with $ sudo adb kill-server and then restart it with $ sudo adb start-server.
    • Also enable USB debbuging as shown in the Backup section.
      • Settings -> Developer options and enable USB debugging (Android debugging)
      • Attach your phone to your computer and connect to it with $ sudo adb shell. A window should pop up on your phone, allow the connection and exit the shell.
      • Now you can reboot in recovery mode and sideload your new ROM version.
  • fastboot has no permissions
    • If $ fastboot devices returns with an no permissions message try to run fastboot as root.

Have a - Donate for free Open Source Software

This post is licensed under CC BY 4.0 by the author.