keyboard_arrow_left Back to the overview

Install LineageOS on
Sony Xperia Z2

sirius

Basic requirements

  1. Read through the instructions at least once before actually following them, so as to avoid any problems due to any missed steps!
  2. Make sure your computer has adb and fastboot. Setup instructions can be found here.
  3. Enable USB debugging on your device.
  4. Make sure that your model number is one of the following (exact match required!):
    • D6502
    • D6503
  5. Boot your device with the stock OS at least once and check every functionality.
  6. LineageOS is provided as-is with no warranty. While we attempt to verify everything works you are installing this at your own risk!

Unlocking the bootloader

  1. On the device, dial *#*#7378423#*#* (*#*#SERVICE#*#*) to launch the service menu.
  2. Go to service info > configuration and check rooting status - you can only continue if it says Bootloader unlock allowed: Yes.
  3. Go to System Settings > About Phone and record the first IMEI number, which is necessary to get an unlock code from Sony in a later step.
  4. Connect the device to your PC via USB.
  5. On the computer, open a command prompt (on Windows) or terminal (on Linux or macOS) window, and type:
    adb -d reboot bootloader
    

    You can also boot into fastboot mode via a key combination:

    • With the device powered off, hold Volume Up and connect the USB cable. The notification light should turn blue.
  6. Once the device is in fastboot mode, verify your PC finds it by typing:
    fastboot devices
    
  7. Follow the instructions on Sony’s official unlocking website to generate an unlock code for your bootloader.
  8. Use your code to unlock the bootloader of your device:
    fastboot oem unlock <your_unlock_code>
    
  9. Since the device resets completely, you will need to re-enable USB debugging to continue.

Special Requirements

  1. Download and install Flashtool on your machine
    • If you’re are a Windows user of any version, open a file explorer and navigate to C:\Flashtool\drivers folder, then install the drivers found within
    • Additionally, if you are a Windows 8.1 (x64) user you will need a patch found here
  2. Reboot your machine
  3. On the device, navigate to the Settings app, in the System menu, under the About this device listing, and take note of your model number & carrier
  4. Open Flashtool
  5. Click the symbol to download and open XperiFirm (round button on the right) to download the latest firmware for your device
  6. In XPeriFirm, select your device and an appropriate firmware on the middle column with the version 23.5.A.1.291. Then click on the firmware on the right side below Available Firmware and download it
  7. After the download finished, close XperiFirm. Flashtool now automatically recognizes the downloaded files and prepares the image to be flashed
  8. Now click on the lightning symbol (flash device), select Flashmode and click on OK
  9. Select the firmware file you just downloaded above
  10. Check all the boxes under the “Wipe” menu
  11. Click “Flash”
  12. Turn off your phone
  13. Hold the volume-down button and keep holding while connecting the device to your PC
  14. Once the flashing process has started, release the volume rocker as soon as possible
  15. When the flash finishes, boot up the device and once booted, please proceed with the instructions

Installing Lineage Recovery using fastboot

  1. Build a LineageOS installation package. The recovery will be built as part of it!
  2. Connect your device to your PC via USB if it isn’t already.
  3. If your device isn’t already in fastboot mode, on the computer, open a command prompt (on Windows) or terminal (on Linux or macOS) window, and type:
    adb -d reboot bootloader
    

    You can also boot into fastboot mode via a key combination:

    • With the device powered off, hold Volume Up and connect the USB cable. The notification light should turn blue.
  4. Once the device is in fastboot mode, verify your PC finds it by typing:
    fastboot devices
    

    If you don’t get any output or an error:

    • on Windows: make sure the device appears in the device manager without a triangle. Try other drivers until the command above works!
    • on Linux or macOS: If you see no permissions fastboot try running fastboot as root. When the output is empty, check your USB cable (preferably use a USB Type-A 2.0 one or a USB hub) and port!
  5. Flash recovery onto your device:
    fastboot flash recovery recovery.img
    
  6. Now reboot into recovery to verify the installation. Do not reboot into the existing OS, since it will overwrite the recovery you just installed!
    • With the device powered off, hold Volume Down + Power. Keep holding both buttons until the device vibrates, then release.

Installing LineageOS from recovery

  1. Build a LineageOS installation package.
  2. If you are not in recovery, reboot into recovery:
    • With the device powered off, hold Volume Down + Power. Keep holding both buttons until the device vibrates, then release.
  3. Now tap Factory Reset, then Format data / factory reset and continue with the formatting process. This will remove encryption and delete all files stored in the internal storage, as well as format your cache partition (if you have one).
  4. Return to the main menu.
  5. Sideload the LineageOS .zip package but do not reboot before you read/followed the rest of the instructions!
    • On the device, select “Apply Update”, then “Apply from ADB” to begin sideload.
    • On the host machine, sideload the package using: adb -d sideload filename.zip.

Installing Add-Ons

  1. Click Apply Update, then Apply from ADB, then adb -d sideload filename.zip for all desired packages in sequence.
    When presented with a screen that says Signature verification failed, click Yes. It is expected as add-ons aren’t signed with LineageOS’s official key!

All set!

Once you have installed everything successfully, you can now reboot your device into the OS for the first time!

  • Click the back arrow in the top left of the screen, then “Reboot system now”.

Get assistance

After you’ve double checked that you followed the steps precisely, didn’t skip any and still have questions or got stuck, feel free to ask on our subreddit or in #LineageOS on Libera.Chat.