Android Upgrades, Custom ROMs (LineageOS), & Kernels

Ultimate Guide: Preparing Your Device for Custom ROMs Like LineageOS with ADB Sideload Factory Images

Google AdSense Native Placement - Horizontal Top-Post banner

Introduction: Why a Clean Slate Matters for Custom ROMs

Embarking on the journey of installing a custom ROM like LineageOS can unlock new functionalities, enhance performance, and extend the lifespan of your Android device. However, a successful and stable custom ROM installation often hinges on starting from a pristine, unadulterated foundation. This is where Android factory images come into play. While the title mentions “ADB Sideload Factory Images,” it’s crucial to understand the roles of both ADB and Fastboot in this process. Factory images are typically flashed using Fastboot to restore your device to its original, out-of-the-box state. This ensures no remnants of previous software or modifications interfere with your custom ROM. Once this clean base is established, ADB sideload becomes a primary method for installing the custom ROM package itself via recovery.

This comprehensive guide will walk you through the essential steps, from setting up your development environment to using Fastboot for flashing a factory image, preparing your device for a seamless transition to a custom ROM.

Prerequisites: Getting Started

Before you begin, ensure you have the following:

  • Unlocked Bootloader: Your device’s bootloader must be unlocked. This process is device-specific and usually voids your warranty and wipes your data. We will briefly touch upon the command, but assume you have researched and completed this step for your specific device model if not already done.
  • ADB & Fastboot Tools: These are command-line tools crucial for communicating with your Android device.
  • Device-Specific Factory Image: Download the correct factory image for your device model and region. Google provides factory images for Pixel and Nexus devices; other OEMs might have similar resources.
  • USB Debugging Enabled: Allows your computer to communicate with your device via ADB.
  • OEM Unlocking Enabled: A security setting that must be active to allow bootloader unlocking and flashing.
  • Full Device Backup: Flashing a factory image and unlocking the bootloader will wipe all data on your device. Backup everything important!

Step 1: Install ADB and Fastboot Tools

ADB (Android Debug Bridge) and Fastboot are part of the Android SDK Platform-Tools. They are indispensable for custom ROM installation.

For Windows:

  1. Download the latest Platform-Tools ZIP from the official Android Developers website.
  2. Extract the contents to an easily accessible directory (e.g., C:platform-tools).
  3. Add this directory to your system’s PATH environment variable for global access, or navigate to it via Command Prompt for every command.

For macOS/Linux:

You can often install them via package managers:

# For macOS (with Homebrew)brew install --cask android-platform-tools# For Debian/Ubuntu-based Linuxsudo apt install android-tools-adb android-tools-fastboot# For Fedora-based Linuxsudo dnf install android-tools

Verification:

Open a command prompt or terminal and type:

adb devicesfastboot devices

If successful, you’ll see a list of connected devices (when your phone is in appropriate modes and drivers are installed).

Step 2: Enable Developer Options and USB Debugging

On your Android device:

  1. Go to Settings > About phone.
  2. Tap on Build number seven times rapidly until you see a message that says “You are now a developer!”
  3. Go back to Settings > System > Developer options (or directly under Settings on some devices).
  4. Toggle on USB debugging. Confirm any prompts on your device.

Step 3: Enable OEM Unlocking

In Developer options (from Step 2), ensure that OEM unlocking is toggled on. If it’s greyed out, your bootloader might already be unlocked, or you may need to factory reset your device first to enable it. This setting is critical for flashing custom software.

Step 4: Download the Correct Factory Image

Visit the official source for your device’s factory image. For Google Pixel/Nexus devices, this is developers.google.com/android/images. Select the exact image corresponding to your device model and the Android version you wish to flash. Download the ZIP file.

Important: Flashing an incorrect factory image can brick your device. Double-check your device model number.

Step 5: Backup Your Device (Crucial!)

Before proceeding, perform a comprehensive backup:

  • Use Google Cloud Backup or similar services to back up app data, contacts, and photos.
  • Manually transfer important files, photos, and videos to your computer.
  • Consider a full Nandroid backup if you already have a custom recovery like TWRP installed.

Step 6: Unlock Your Bootloader (If Not Already Done)

This step will factory reset your device. If your bootloader is already unlocked, you can skip this. If not, proceed with caution:

  1. Boot your device into Fastboot mode. This usually involves powering off and then holding Volume Down + Power button simultaneously.
  2. Connect your device to your computer via USB.
  3. Open your command prompt/terminal and navigate to your platform-tools directory (if not in PATH).
  4. Execute the unlocking command. Note that commands vary slightly by OEM:
    • For Google Pixel/Nexus:
      fastboot flashing unlock
    • For other OEMs (e.g., OnePlus, Xiaomi): The command might be fastboot oem unlock or similar. Consult your device-specific forums.
  5. On your device, you will see a prompt. Use the volume keys to navigate and the power button to confirm unlocking.
  6. Your device will reboot and perform a factory reset.

Step 7: Flashing the Factory Image via Fastboot

This process will completely erase your device’s data and install a fresh stock Android build, providing a clean slate for your custom ROM.

  1. Extract the Factory Image: Unzip the downloaded factory image file. You’ll typically find several .img files (e.g., boot.img, system.img, vendor.img) and a flash-all.bat (Windows) or flash-all.sh (Linux/macOS) script.
  2. Boot to Fastboot Mode: Power off your device. Hold Volume Down + Power button simultaneously until you see the Fastboot screen.
  3. Connect to PC: Connect your device to your computer via USB.
  4. Execute the Flash Script:

    Navigate to the extracted factory image folder in your command prompt/terminal.

    • Windows: Double-click flash-all.bat or run it from Command Prompt.
    • macOS/Linux: Open a terminal, navigate to the folder, and run:
      chmod +x flash-all.sh./flash-all.sh

    This script automates the flashing of all necessary partitions (bootloader, radio, system, vendor, etc.). It can take several minutes. Do not disconnect your device.

    Manual Flashing (if `flash-all` script fails or for specific partitions):

    # Example commands, vary by device and image contentfastboot flash bootloader <bootloader_filename>.imgfastboot reboot-bootloaderfastboot flash radio <radio_filename>.imgfastboot reboot-bootloaderfastboot flash vendor <vendor_filename>.imgfastboot flash system <system_filename>.imgfastboot flash boot <boot_filename>.imgfastboot -w # Wipes user data and cache (equivalent to factory reset)fastboot reboot

Step 8: Verifying the Clean Install

After the flashing process completes, your device will reboot into a fresh Android setup wizard. Complete the initial setup to ensure everything is working correctly. Do not install many apps or customize settings extensively, as you are preparing to wipe it again for the custom ROM.

Step 9: Preparing for Custom ROM Installation (Using ADB Sideload)

Now that your device has a clean factory image, it’s perfectly poised for a custom ROM like LineageOS. The next steps typically involve:

  1. Install a Custom Recovery: (e.g., TWRP). Download the correct .img file for your device and flash it via Fastboot:
    fastboot flash recovery twrp-<version>-<device>.imgfastboot reboot recovery # Immediately boot into recovery
  2. Transfer Custom ROM (ADB Sideload): Once in a custom recovery (like TWRP or LineageOS Recovery), you’ll often find an option to “Apply Update” or “Advanced > ADB Sideload.” Select this option.
  3. On your computer, with the custom ROM’s .zip file in your platform-tools directory, execute:
    adb sideload lineageos-<version>-<device>.zip

    The ROM will be pushed and installed onto your device. Follow any on-screen instructions within the recovery.

  4. Flash GApps (Optional): If your custom ROM doesn’t include Google Apps, you’ll need to sideload a compatible GApps package immediately after the ROM, before the first boot.
  5. Reboot: After flashing the ROM and GApps (if applicable), perform a data wipe (if not already done by the ROM installer) and reboot your device into the new custom ROM.

Conclusion

By diligently following these steps, you’ve ensured your Android device has a pristine, factory-fresh foundation, eliminating potential conflicts that can arise from leftover data or incompatible software. This preparation is paramount for a smooth and stable experience with your chosen custom ROM, setting you up for success in optimizing your device’s potential. Remember to always back up your data and consult device-specific forums for any unique considerations or commands.

Android Mobile Specs & Compare Directory

Are you researching mobile hardware properties, processor SoCs, GPU chipsets, or RAM configurations? Access our complete specs catalog to compare up to 5 devices side-by-side!

Compare Devices Specs →
Google AdSense Inline Placement - Content Footer banner