Installing Linux on a OnePlus 6T [Smartphone Revival Project]

In an ideal world, all smartphones should be customisable!

postmarketOS boot stages postmarketOS boot stages

⚠️️ Warning This is educational content only. Proceed at your own risk. Please read the disclaimer below if you wish to proceed with the steps described in this blog post.

Things can go wrong, including but not limited to, bricking your phone. 📱 ➡ 🧱 😢

Context

Some words have magical powers. “Repurposing” is one of them. In this series labelled Smartphone Revival Project, we see how an old OnePlus 6T smartphone can be repurposed to become a small server. This series shows an example of how old and undesired can become new and fun again. This is even more so important as smartphones are one of the most ubiquitous hi-tech items used in the world. Their relatively short lifespan and the environmental impact of building and shipping them comes at a cost. Until we can finally use a smartphone as long as we use a fridge, repurposing them is one of the best ways to ensure that they don’t end up in landfill so quickly.

postmarketOS is a Linux-based smartphone OS aimed at being as feature rich as Android or iOS. It can be installed on a number of devices. One such device is the OnePlus 6T, a powerful phone that can be found at affordable prices on secondhand markets online, or possibly even for free in your drawer!

Released in 2018, the OnePlus 6T is a smartphone packed with specifications that make it a very decent little computer: RAM capacity between 6GB and 10GB depending on models, 128GB or 256GB of internal storage, a slot for an external SD card, an 8-core ARM64 CPU and of course, WiFi connectivity.

In the next episode, we will see how to run that smartphone without any battery.

And in another episode of this series we will use a OnePlus 6T as a local server, twisting a little bit the original target use case of postmarketOS. We will thus be using the phone as if it were a single-board computer, in a similar fashion to the popular Raspberry Pi.

An alternative method

There are several ways to turn a smartphone into a small server. For Android devices, a viable alternative to the process described in this blog post is to install an application called Termux. Termux is a terminal emulator that allows running a Linux environment and comes with package management. Compared to installing postmarketOS, the benefits of this option include a lower technical entry barrier and a wider range of smartphones it can be installed on. However, drawbacks include a smaller number of available packages than a typical Linux distribution, due notably to porting requirements. Also, the practical lifespan of this option is constrained by both the support lifespan of the device’s Android OS and that of Termux. In other terms if you have an old phone that does not have a recent enough Android OS, Termux may not be compatible, or you may be stuck with an old version of Termux forever.

It is possible to install Linux distributions within Termux, however this can have a negative performance impact and is adding layers on top of layers. We try instead to be as bare metal as possible here.

In short, Termux may be a realistic alternative if your device is not supported by postmarketOS.

Installing postmarketOS

The steps listed below are inspired by the well-written postmarketOS wiki.

Phase 1

As a prerequisite, a computer with fastboot installed is needed.

ℹ️ fastboot is a command-line tool developed by Google that is part of the official Android SDK. This tool helps communicate with the bootloader on an Android device. In our case, we will use it to unlock the OnePlus 6T and copy the postmarketOS images.

The Android SDK Platform-Tools can be downloaded here. Unzip the downloaded file to a target directory and add that directory to your global OS PATH. This will make fastboot available on your machine.

Next, ensure that the smartphone is up-to-date by running a system update.

Once the system update completed, unlock the smartphone bootloader by going to Settings -> About. Then tap Build number 10 times or more, until you see the message You are now a developer.

  • The exact location of the Build number box may vary.
  • Some carrier-locked phones may need an unlock code. See this postmarketOS wiki section for more details.

Congratulations, you are now an Android developer! ☺️ It is possible to enable OEM unlocking in the super secret developer menu.

  • Go to System -> Developer Options and toggle the switch labelled Enable OEM unlocking.

In the second phase below, we will see how to boot the phone in a special state called fastboot mode and how to copy postmarketOS images onto the device.

Phase 2

To start up your OnePlus 6T in fastboot mode:

  • ⏻ Power off the device. It should also be unplugged.
  • Press Volume Up + Volume Down + Power at the same time
  • Once the device has been powered on, keep holding Volume Up + Volume Down
  • The phone will enter fasboot mode after several seconds

ℹ️ Note: fastboot mode displays a single-line menu at the top of the screen. You can press the Volume Up or Volume Down buttons to list all possible actions.

fastboot menu on a OnePlus 6T
fastboot menu on a OnePlus 6T

The next step is to OEM unlock your smartphone. This will erase your device.

  • Connect to phone via a USB cable to a computer that has the utility fastboot
  • Run fastboot oem unlock. Confirmation may be prompted before proceeding as this step will erase the internal storage of your device.

All good. Let’s then install postmarketOS!

Please note that the steps below have been tested for postmarketOS v23.06 only. It is recommended to also check the postmarketOS wiki for later releases as the process could evolve.

  • Download the OnePlus 6T stable images from this link. For info, the Android code name of OnePlus 6T is oneplus-fajita.

    • You will be presented with a page that contains images for several UIs. We have tested the gnome-mobile UI but feel free to use any, with the exception of sxmo-de-sway. More on UIs on this postmarketOS wiki page.
  • Decompress the files using unxz (or 7zip on Windows).

  • At this point, the downloaded images can be flashed onto the device. Reconnect the phone to your computer if not already the case, then run the commands below.

# Each command can take some time to complete.
# If commands fail or get stuck with the message "< waiting for any device >",
# you can try any combination of: rebooting into fastboot mode and/or disconnecting and reconnecting the USB cable to the PC
fastboot erase dtbo
fastboot flash boot [the file that ends in -boot.img]
fastboot flash userdata [the other file]

ℹ️ See the postmarket OS wiki pages of OnePlus 6 and OnePlus 6T for any troubleshooting tips.

Congratulations! You should be able to boot up your phone with postmarketOS. The default PIN to unlock the login screen is 147147.

postmarketOS booting on a OnePlus 6T
postmarketOS booting on a OnePlus 6T

Your phone is now running a hackable version of Linux. It is functional as a smartphone but in this series we will investigate how to use it as a Linux server. Fun times ahead! 🥳🎉✨

Trivia

The name of this series, Smartphone Revival Project, was inspired by the amazing YouTube channel Anatolian Rock Revival Project. If you like rock with a hint of funk, folk and psychedelic rhythms, you will be in good hands on that channel!

Disclaimer

This is educational content only. Proceed at your own risk.

In no events shall the authors of this content be liable for any claim, damages or other liability arising from the use of this content.

We do not warrant or assume any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, product, or process disclosed.
Kédio Blog
Kédio Blog
Exploring software engineering and technology, one blog post at a time.

Kédio - Experts in technology consulting

Next

Related