Some notes on installing Lineage OS on modern-ish Samsung Android devices
This article provides some supplementary notes about installing
Lineage OS on modern-ish Samsung devices, and rooting them (in that
order). At the time of writing, the most modern device that Lineage
supports is the S20 FE; the oldest is probably the S8. Unofficial
versions exist for some other devices.
I’m not trying to supplant the official Lineage instructions, which are already quite thorough. All I seek to do is to add my own experiences, in the hope that I can save somebody some time and frustration.
Note
I install Lineage OS on my cellphones to de-Google them. It’s certainly possible to install Google stuff under Lineage OS, and also to install stubs of Google services to fool applications into thinking that these services are available. However, I’m specifically trying to avoid Google services, so I won’t be describing how to do any of that in this article (because I don’t know).
Please be aware that there’s a lot more I don’t know about the process of installing Lineage OS. I have successfully installed it on the S10, S10+, S10e, Note 9, and S5e (Wifi). The last of these is a tablet; the rest are smartphones. The installation process is the same for all of them once you get the custom recovery software installed (see below). It’s possible that you can install the custom recovery the same way on all devices, too – but the Lineage OS instructions are different in this regard for different devices, and I’ve generally followed them.
In particular, some devices are documented as using the Odin tool to install the custom recovery, others use Heimdall. More on this point later.
If you’re unsure about whether installing Lineage OS is right for you, please see at least the ‘Things to watch out for’ section at the end of this article. It might help you make up your mind.
Basic principles
Assuming that you’re starting from a stock, up-to-date Samsung device, installation and rooting has four main parts.
- Unlock the bootloader. This is essentially irreversible, and will delete all data. Make a backup first.
- Install a custom recovery image. The purpose of the custom recovery is to write the operating system image (and perhaps other things) to the device’s flash memory. Over the years there have been many custom recovery applications; the most common is probably TWRP. Lineage OS has its own custom recovery, and that’s all I’ve used with Samsung devices. Samsung devices have a built-in recovery mode, but it will only install Samsung software. This – installing the custom recovery – is the part of the process that requires Odin or Heimdall.
- Use the custom recovery image to install Lineage OS. This part of
the process uses the
adb sideload
command. - Install Magisk to provide root access, if required.
I should point out that installing Lineage OS does not require a rooted device, and it will not root the device itself. Lineage OS used to have its own mechanism for enabling root access, but the maintainers now recommend Magisk.
Prerequisites
You’ll need:
- A computer with the
adb
utility. This is released by Google as part of the Android ‘platform tools’ package, and is widely available for most platforms. This is a command-line utility, and I’m assuming you know how to runadb
at a prompt on your computer. - Either Odin or Heimdall, depending on the device. It may be
possible to use these interchangeably, but I have not been brave enough
to try. Odin is available as a graphical utility for Windows and Mac,
and a command-line utility for Linux. The Linux version is called
odin4
and is available, at the time of writing, from here. However, you might need to do some web searching, as these tools can be a bit elusive. - A USB C cable, and a working USB port on the device. The USB ports on Samsung devices are precarious, and data transfer tends to fail after a while, even if charging still works. I don’t know any way to install Lineage OS without a working USB port.
I would strongly recommend that, before going any further, you learn and practice the button-press combinations needed to be able to get into the various “special modes”. You’ll need to be able to do these fluently and at speed, or you’ll end up repeating various parts of the installation, perhaps several times.
How to get into special modes
Installing Lineage OS on a Samsung device requires being able to start the device in particular special modes: “download” mode, and “recovery” mode.
For full details you’ll need to check the specific instructions for your device on the Lineage OS website. However, I’ve found that the following work for all my Samsung cellphones.
If you’ve already installed Lineage OS – you’re trying to install Magisk for rooting, for example – the easiest way to get into the special modes is to do so directly from the Lineage user interface. To do this, enable the ‘Advanced restart’ feature from the Settings app. Then the power-off menu will have an additional ‘Restart’ button that allows direct entry into download mode or recovery mode.
If you don’t have Lineage OS installed yet – and you probably don’t, if you’re reading this – then you’ll need to learn and practice the finger-breaking button combinations below.
Download mode
This is the mode you need for installing a custom recovery image using the Heimdall or Odin utilities. With the device powered off, press and hold the volume-down and bixby buttons, then plug in the USB cable. Unless you have three hands, it takes some practice to complete these steps.
Recovery mode
This is the mode you’ll need for installing Lineage OS using the custom recovery menu. With the device powered off, press and hold volume-up, bixby, and power, for a long time, until the recovery screen appears.
If you’re currently running Android or Lineage OS, and your device is
connected to a computer, you might be able to get into recovery mode by
running adb reboot recovery
. If this works, it might put
the recovery utility directly into ‘sideload’ mode (see below), which
will save a couple fo button-presses. But I’ve found it doesn’t always
work for me.
Hard power-off
To power off when there seems to be no other way to do so, press and hold the volume-down and power buttons together, and hold them for at least ten seconds, or until the screen switches off.
This isn’t just for emergencies – there are steps in the official documentation that require a hard power-off as part of the installation.
From download mode to recovery mode
This is the most fiddly mode switch of all, and you have to be able to get it right. If you fail, you’ll probably have to install the custom recovery from scratch and try again.
With the device in download mode, and having finished downloading the custom recovery, do a hard power-off followed immediately by recovery mode. That is, hold volume-down and power until the screen switches off and then, within half a second or so, press and hold the volume-up, bixby, and power buttons together.
This process is very fiddly, and I get it wrong as often as right, even after practice.
Bootloader unlock issues
The first step in the installation of Lineage OS, or any custom ROM, is to unlock the bootloader.
The Lineage OS instructions say to enable developer mode on the device, and then find the ‘Enable OEM Unlocking’ control in the Settings app. What they don’t say is that you won’t even see this control if there is no WiFi connection. I have no idea why this is the case, and I’m not sure whether anybody else does. I’ve been caught out by this many times, because installing Lineage is usually the very first thing I do on a cellphone. So I usually rush through all the initial set-up steps, to get as quickly as possible to the Settings app. But if you don’t enable WiFi, you won’t be able to enable the bootloader unlock mode when you get there.
There are many reports of how certain devices don’t even have the ‘Enable OEM Unlocking’ control. These seem to be devices that are locked to some specific cellular carrier. I don’t think it’s possible to proceed without completing this step successfully.
Note
Although it’s stated in the Lineage installation instructions, it bears repeating: unlocking the bootloader will erase all data on the device and, even if you proceed no further, certain features of the device will be lost, particularly those concerned with media DRM. There’s really no going back, beyond this point.
Installing the custom recovery software
Depending on the device, the instructions say to use Odin or Heimdall. Although these utilities have many functions, only one is needed to flash the recovery utility. The second-trickiest part of the process is getting into ‘download’ mode to begin it (see above). Thereafter it’s just a matter of running the appropriate Odin or Heimdall commands, which are well-documented.
The trickiest part is getting from download mode to recovery mode without actually starting Android. The finger-breaker for this is also described above and, although I know I’m repeating myself, it’s good to practice it until you can do it without getting your fingers in a tangle.
The problem is that if you leave download mode without entering recovery mode, the device will reboot normally, and restart Samsung’s Android. Doing this will overwrite the custom recovery with the Samsung stock recovery, which is no use to us. So it’s crucial to go straight from download mode to recovery mode.
Using the custom recovery to install Lineage OS
When you boot into recovery mode, either now or after installing Lineage, you should see the Lineage OS custom recovery. This recovery utility has large, white text on a purple background and is touch-sensitive. If you see lots of tiny text, and the menus are not touch sensitive, then you’re not running the Lineage recovery, but the stock Samsung one. This is no use for installing anything except Samsung software.
So if you’re in this situation, you’ll need to retry the installation of the custom recovery.
Installing Lineage OS from the custom recovery is easy, and
well-documented. You’ll need to use the recovery menus to perform a
factory data erase, and then ‘Apply update’. You can then use the
adb sideload
command to send the appropriate Lineage OS
image to the device. This will take a few minutes, and then you’ll be
back at the recovery menu.
It’s possible to install Google stuff at this point and, according to the documentation, you need to do so before starting Lineage OS for the first time. I’ve never done this, so I can’t comment further. I just reboot here, and start Lineage OS.
Rooting using Magisk
This is now the approved way to root Lineage OS. Magisk has two parts to it – some firmware which is executed at boot time, and a regular Android app. I believe there are various ways to install these components; I’m just describing the method that works for me.
- Obtain the Magisk installer APK from GitHub.
- Enter recovery mode, and install the APK using
adb sideload
, as you did to install Lineage OS itself. It’s normal to get a ‘Signature verification error’ message at this point. - Reboot into Lineage OS.
- You’ll see a new app, entitled ‘Magisk’, with a generic Android logo. This is just a stub to download the rest of Magisk. Run this app.
- When prompted, tell the downloader stub to download the full app.
- When the full app has installed, run it. You’ll be told that additional steps are required.
- When prompted, choose ‘Direct installation’. This will install some software and reboot the device.
To test that root access is now possible, I usually install a
terminal emulator like Termux. Then I run su
in the
terminal. This should cause Magisk to pop up a confirmation box and, if
you grant permission for root access, the prompt in the terminal will
change from $
to #
. Other software that
requires root access should also work, although you’ll need to approve
their access when Magisk prompts.
Things to watch out for
- If you get error messages about permissions from
adb
, bear in mind that the missing permissions are probably on the host computer, not the Android device. You might need to runadb
as an administrative user. - If you’re installing Lineage without Google services, you’ll have to find some way to install apps – if you need any – without using the Google Play Store. A good starting point is to install the F-Droid app, which you can get as an APK from the F-Droid website using the built-in web browser. You can get apps from other places in APK format, but you shouldn’t expect too much – most proprietary apps assume the availability of Google services.
- On some Samsung devices, you can expect to get a warning message about the risks of using unofficial software every time you reboot. I don’t know why this applies to some devices and not others.
- Lineage OS can be upgraded in place between minor versions, e.g., from 20.0 to 20.1. However, there is no simple upgrade between major versions – you’ll have to start from scratch, and be prepared to reinstall all your apps and data.
- Unlocking the bootloader will trip the ‘Knox fuse’ on the main board. Even if you can find some way to reinstall the original Samsung firmware – which is difficult – the Knox fuse is a physical device that cannot be reset in software. You might struggle to get a cellphone repaired under Samsung’s warranty terms, if you’ve tripped the Knox fuse. There really is no going back.