|So you want to know how to install a real
Linux distro on your smart phone? This guide will attempt to
help you with that, based on my experiences in getting it
List of things you'll need:
Apps you'll need through Google Play:
WARNING: Android 4.x (KitKat) seems to have made it nearly impossible to write to the internal SDcard correctly with Linux Deploy and BusyBox. If this is the only Android version you can use, I'd suggest trying to find a phone that lets you install an earlier or later Android version.
Also, anything less than Android 2.4 and you won't be able to use this setup either!
Also-also, stay away from any ROM that has xx in the name, like zeroltexx, these wouldn't install to either of my phones. Something about a list in the ROM to check if the ROM matches the hardware, and I didn't feel like looking up how to force it to install.
First step is to check to see if there's a custom Android ROM out there for your phone, and what the status of it is. If it's an early release, it's probably buggy as hell, and not worth the effort. If it's in beta, you'll probably be alright. If it's at stable, you're good to go.
A Google search for your phone's model number (located at Settings > About Phone > Model & Hardware, or something similar) along with "CyanogenMod" or "Lineage OS" will get you started. xda-developers is an amazing source of information and links for tons of custom ROMs.
Next step is to root your phone. You can check out the various ways to do this by another Google search. Some are really easy, with a simple .apk download like TowelRoot, others are a bit more complicated.
After your phone is rooted, download a root checker app from the Play store and see if your phone is actually rooted. If it's rooted, great! You can move onto the next step. If not, you'll have to look for alternate ways to root your phone. Keep trying until you succeed!
Once your phone is rooted, you'll want to use your computer to download a custom Android ROM and the corresponding Open GApps file for the Android version you're downloading. I've found that for running a BBS on the phone, SELinux needs to be set to Permissive, and for some reason the official ROMs from Lineage OS won't let you do that. Only unofficial ROMs will. If you don't know what SELinux is, don't worry, it'll be explained later.
Once you've found a ROM you'd like to try and the corresponding GApps (I'd suggest getting the Nano version if you're just running a BBS on this), keep them handy on your computer. You're going to need ADB (Android Debug Bridge). This guide will tell you how to download and install it for various OSes, along with the phone options to turn on.
Now you're going to need to install a custom boot loader. TWRP is the most popular, and is constantly updated. Find your device in the list, click on the link, and download the .img to your phone.
Read this guide to get you going on the next part to install TWRP.
Something I had to do with my phone was do the install, and then after rebooting I had to immediately enter the bootloader menu again (Volume Up, Home and Power on S3 and S6), otherwise my stock Android reflashed the original bootloader.
After you get into TWRP, wipe everything completely out on your phone. Select Wipe > then swipe to the right to Factory Reset. Go back to the Wipe menu afterwards and hit Format Data and swipe to do that.
Make sure your phone is connected to your computer via USB, and open a terminal. In Linux, I installed it via apt, so I could use it immediately, but if you had to download it, make sure you go to the directory you uncompressed it into.
Type adb push /path/to/android/image/android.zip /sdcard to put the ROM on your phone, replacing path with your path, and image name with the actual image. If using Linux and apt install, just head to the directory you have the ROM and GApps, then just adb push android.zip /sdcard or whatever your image name is.
After that, type adb push /path/to/android/gapps/gapps.zip /sdcard, replacing with actual path and name as needed.
Head back to the main TWRP menu, and hit Install. In the file browser, select the ROM and install it. If you've gotten the correct ROM for your phone, it will start flashing it. If not, you'll have to search for another ROM to install from a different source.
After the ROM flashes to your phone, go back to the Install file browser and install the GApps package.
After both of those are installed, just do a Reboot. It will take a bit for the OS to boot up on first install, so don't panic if it takes 3-5 minutes. If after 10 minutes it still hasn't booted to the Welcome screen, you've probably installed a wrong ROM, and will have to reboot back to TWRP to install the correct one. My phone has a non-removable battery, so in order to soft reboot from a loop, holding down Volume Up/Down, Power and Home at the same time for 5 seconds reboots.
Now that you've got a custom ROM on your phone, I'm going to tell you how to get a real Linux install on your shiny new custom Android install.
If you installed Lineage OS (official or unofficial), most likely it has the option to root your phone built in. Other ROMs might have this option as well, not sure. If not, you'll have to re-root your phone before proceeding.
Once it's booted into the OS, go through the config option. Make sure you sign into Google to use Google Play as well.
If you have CyanogenMod or Lineage OS, head to Settings > About Phone > Build Number and tap on it about 8 times to enable Developer Options. Depending on the Android version, back out to the previous screen and look for Developer Options. If it's not immediately visible, try System > Advanced, and it should be there (at least it is in Pie).
Open Google Play and install the root check app you used on the stock ROM. Run it and check for proper root access. If it worked, awesome! If not, you'll have to disable the built-in ROM root access and try another way.
Look for Root access and turn on for Apps and ADB, then scroll down a bit and look for Local terminal, and turn that on as well.
Wait a bit for it to show in your installed apps, and open it up. Type su to get super user, then type getenforce to see if SELinux is set to Enforcing or Permissive. If it's Permissive, you don't need to use the terminal, just close it at that point. If it's Enforcing, type setenforce 0 to set Permissive. Afterwards, type getenforce again to see the status. If it still says Enforcing, you've got an Android kernel that won't allow it to be changed, and you'll need to flash one that will let you. Generally, the unofficial ROMs aren't enforcing, or will allow it to be changed.
Now open Google Play and install BusyBox. I use the one by Stericson. There's another one by the author of Linux Deploy, but like I mentioned earlier it has an image limitation of 2GB, which sucks.
Open BusyBox, and install it to the default dir. Make note of where it installs (generally /system/xbin), you might need that info later in Linux Deploy. Close the app.
Go back to Google Play and install a VNC viewer. I use RealVNC Viewer for my setup.
Now install Linux Deploy. This is where things are going to possibly be completely different for you, but hopefully not, and might either be 100% on target for your setup, or only slightly different.
These are the options I have setup on my Linux Deploy to get it 100% working:
Tap the config options in the bottom right corner to get to the Linux install options. My selections are:
Containerization method - chroot
Distribution - Debian
Architecture - armhf
Distribution suite - stretch
Source path (leave the default it picks for you)
Installation type - File
Installation path - /storage/emulated/0/linux.img
(this installs it on the internal storage; you can pick your external SDcard if you want)
Image size - 4000
(4000 should be fine, you can use 8000 if you have the room)
File system - ext4
(shouldn't need to be changed, unless you're using a really old version of Android, then I'd suggest ext2)
User name - (change to what you like, people have suggest root as the username, but that's a security risk)
User password - (change to what you like, it's limited to 8 characters)
Privileged users - (leave at default)
DNS - Automatic detection
Localization - en_US.UTF-8 (for English, obviously, pick whichever one you're comfortable with)
Enable - Turn this on
Init system - sysv (if using Debian, not sure about other flavors)
Init settings - (leave default)
Enable - Turn this on
Mount points - Tap this and setup a mount point if you like. I have Source set to /storage/emulated/0/bbsBackup and Target set to /mnt/bbsBackup so I can easily move my BBS backup .zip to the Android local system.
Enable - Turn this on if you want to SSH to your Linux install
SSH settings - leave default if you like
Enable - Leave off
Enable - Turn this on
Graphics subsystem - VNC
GUI settings - Tap this
Display - 0
Depth (bits) - 24
DPI - 100
WIdth - 1024 (set to whatever you like)
Height - 768 (set to whatever you like)
VNC options - leave default
Xfce (you can use whichever you like, Xcfe seems to be the easiest to use)
Back out to the main Linux Deploy window, tap the three lines at the top left, then tap Settings.
Lock Screen - Turn this on
Lock Wi-Fi - Turn this on
Wake lock - Turn this on
Language - whichever you like
Font size - Leave default
Scroll size - Leave default
Theme - Leave default
Timestamp - Turn this on
Show icon - Turn this on
Stealth mode - Turn this off
Autostart - Turn this off; doesn't seem to work
Network trigger - Turn on if you anticipate your phone's IP changing, otherwise leave off
ENV directory - /data/data/ru.meefik.linuxdeploy/files
PATH variable - /system/xbin
(if you get SU errors on starting your Linux install, try clearing it. Lineage OS 12 and 13 have issues, so you might need to use a different version of Lineage OS)
Enable CLI - Turn this on
Scroll down a bit and turn on Debugging, then back up a bit and tap Update ENV. Some versions of Android will let it go forever on the "Updating operating environment", so just wait a few seconds and then tap somewhere on the phone to clear it.
Go back to the main Linux Deploy window and tap the three dots in the top right, and select Install. If everything is set correctly for your phone and OS, it should start to install. You'll see a bunch of text with it retrieving source files and whatnot. Let it go through the install process, then at the end you'll see something like <<< deploy or <<< install. Hit Start in the bottom left to start your Linux OS!
Either use the VNC app you installed earlier to connect right on the phone (IP - 127.0.0.1 and username and pw you supplied in the Linux Deploy settings), or if you're on a local network you can use a separate VNC viewer. The phone's IP is right at the top of the Linux Deploy main window.
In order to get my Linux install to boot on phone startup, I had to install an app called Kernel Adiutor (that's not a misspelling). If you use this, open the app, give it root permissions, then scroll down a bit on the main window, then back up a bit to get the three lines for options in the top left. Tap that, scroll down to Init.d, and enable it. Create an init file (mine is named Linux_Deploy), then make sure your phone is plugged into your computer and fire up ADB again.
Type adb shell and you're in your phone's shell. Now type su to get super user and type mount -o rw,remount /system which will make your system files writable.
Type nano /etc/init.d/Linux_Deploy (or whatever you named your init script) and put this in it:
/data/data/ru.meefik.linuxdeploy/files/bin/linuxdeploy -p linux start -m
Hit CTRL-X, Y to save, then Enter to keep the same file name.
Once back to the command prompt, type mount -o ro,remount /system to make your system files read-only again.
Since you're still possibly in Kernel Adiutor, you'll probably need to set governors on your CPU(s). On older phones, you'll most likely need to set the minimum frequency to something close to your max to be able to eke out whatever performance gain possible. On newer phones, you'll have more leeway.
On my S6, it has two CPUs, a little one and a big one. The little CPU is mainly used as the workhorse, but the frequency floor is horrendous (200 MHz) and rarely popped above that. Linux Deploy never really seemed to touch the big CPU, so you can imagine how slow my setup was.
In Kernel Adiutor, open the menu and go to CPU, and enable it. Scroll down a bit to see the first set of CPU Maximum Frequency (if your setup is multi-core).
Leave the max frequency alone, but change the minimum frequency to something close to max (mine is set 2100MHz max, 1600MHz min)
Scroll down a bit more and change CPU Governor to performance. If you only have the one CPU listed, you're all set. Back out of the app and restart your phone. If not, read on.
Scroll down some more to the next set of cores. Leave the max frequency alone, and change the min to within a few hundred MHz of max (mine is 1800MHz max, 1500MHz min). Change the governor for the little CPU to performance as well.
Restart your phone to apply changes.
After restarting, open Wakelock Revamp installed from Google Play. Apply the Wi-Fi high performance and Processor wakelocks to keep your phone from putting your CPU or WiFi to sleep when your phone's screen is off for an extended period of time.
And that should be it! Try rebooting your phone to see if it boots into your Linux install. Once you're booted up, you can VNC into it and do almost everything a standalone Linux install will let you.
NOTE: Linux Deploy will only ever do minimal installs of Linux, which means you will be missing a ton of stuff that you might need to install through apt in the CLI. Synaptic doesn't seem to work in Debian Stretch with Xfce as well, but it seemed to in MATE. Whenever you try and run something and it throws an error, you can do a Google search to see what's missing and install it through apt.