[Android Software Development] DragonFire1024:
I spent weeks trying to find a way to install a Linux distribution alongside my Android devices, or replace Android with one entirely. While researching the possibility, I was really disappointed to learn installing a distribution alongside Android was already a 'fad' which had already come and pretty much gone. A lot of the methods that worked in 2012 and 2013, no longer work on current Android devices, or at least very few of them. However I don't go down without a fight. Please note, I did NOT create any of this software nor did I develop it. I just put it all back together, in a working order. Though it's pretty much impossible to brick your device using this guide, I still feel obligated to say: I am not responsible for any damage this guide may cause to your device, yourself, or the jealous friends you'll have after installation is completed xD

In order to install a Linux distribution, your Android device MUST be rooted. Unfortunately there is no way around that. After more than 2 weeks of research, reading and testing, I have managed to get three different distributions working across four devices, with plans to test it on at least one more device:

- Amazon Kindle HD 8.9 (Rooted with TWRP custom recovery and a custom CyanogenMod [CM] Marshmallow 6.0 ROM).

- Samsung Galaxy J1 (Rooted. Android Lollipop 5.1.1).

- Samsung Galaxy S3 (Rooted with TWRP custom recovery and a custom SlimRom Marshmallow 6.0 ROM).

- Samsung Galaxy S7 (Rooted, US Variant, Android Nougat 7.0).

- (Plan to test) Amazon Fire 7 (Rooted. Custom Lollipop 5.1.1 ROM).

The following guides will allow you to install any Linux distribution you desire (provided it's available). You can install the distributions as a .img on your internal storage/sdcard or partition part (or use all) of an removable sdcard (external storage). It is recommended you have at least 4GB of free storage space. If you want to try another distribution, it's just a case of deleting a few files or folders to uninstall them. Or you can partition another part of your sdcard (external storage). Please note you will not be able to repartition any internal storage.

These guides will be long. It will seem harder than it is. I really think this is one of the coolest things for Android I've stumbled upon. I haven't even begun to scrape the surface of what this allows you to do. Be patient and have fun :D

Part One: Installing a Linux distribution on internal storage

To get started, you need to do and have installed the following things:

- Make sure you have root.

- Make sure you have BusyBox installed and working.

- Terminal Emulator for Android, Termux and it's API or an SSH client.

- VNC Viewer for Android or your preferred VNC viewer.

- Linux Deploy

- AParted ( Sd card Partition )

1. Go to Sourceforge and download your preferred Linux .img. Those .img files are courtesy of a once awesome organization called 'LinuxOnAndroid'. Simply click on one of the nine distributions and download whichever one and size you prefer.

2. Extract the .zip in a folder on your PC. Name the folder the name of the distribution (i.e. Kali, Debian etc). **NOTE: You MUST download and extract all distributions on your desktop PC. These .zip files will not decompile and extract properly on your Android and the .img files will not boot.**

3. On your Android, using a root explorer, create a folder with the distribution's name in /sdcard or /storage/emulated/0. On your PC, in your extracted Linux distribution folder, copy and paste the .img file into the folder you created in one of those two storage directories.

4. If you haven't already, download and install Linux Deploy from Google Play.

5. It's now time to configure your distribution. Tap the three lines at the bottom right corner. You will then get a screen with a list of configurations. For the purpose of this guide, I have selected the Debian distribution. The first set of configurations should be as follows (See image below the list):

- Containerization method: chroot

- Distribution: Debian

- Architecture: armhf (This allows the Linux OS to be compatible with armv7)

- Source Path: (This will be an automatically selected URL and will vary from distribution to distribution. You should never have to change this configuration)

6. Now we configure the type of installation we will be doing. For this particular guide, we are installing the distribution on internal storage. Please configure your settings as listed (See image below the list):

- Installation Type: File

- Installation Path: /sdcard/Debian or /storage/emulated/0/Debian

- Image size: 6000 (The lowest recommended allocation is 4000MB [4GB])

- File System: ext4 (Not all devices support ext4. Some only support ext2 or ext3. If ext4 doesn't work, try one of the other two. You will also have to select the proper .img format from LinuxOnAndroid i.e. ext4, ext3, ext2).

- User Name: android (You can choose any name you like. This will be used to connect to the OS via a VNC viewer later on).

- User Password: ******* (Although the password is automatically generated, you can make this any password you want. This will be used to connect to the OS via a VNC viewer later on).

7. Set the configurations below See images below the lists):

- Privileged Users: root (This will be the name given to you when entering a root shell via the sudo command. You can change this to your liking)

- DNS: Automatic Detection

- Localization: en_US.UTF-8 (Language and region selection. If you're not sure of this setting, use Google to determine your local i.e. en = English, US = United States)

- INIT: Make sure box is checked to enable

- Init System: run-parts

- Mounts: Make sure box is checked to enable

- SSH: Make sure box is checked to enable (This allows you to set up an SSH client to connect to the Linux OS as opposed to using a VNC viewer)

- GUI: Make sure box is checked to enable (This tells the Linux OS to create a graphical interface so you're able to use a VNC viewer)

- Graphics Subsystem: VNC

8. Now you can configure GUI settings. This creates graphics of high or low quality. You are able to customize these settings to your liking and they will vary from device to device based on screen sizes and resolutions. In this case, I have the distribution loaded on my Galaxy J1 so these settings are set to my taste based on that device (See image below the list):

- Display: 0

- Depth (bits): 24 (The higher the number, the better the graphics)

- DPI: 100 (Dots per inch)

- Width: 800

- Height: 480

9. Tap the back button once. From the main screen swipe right or tap the three lines in the upper left corner and tap the settings option. Here you can configure the application settings for Linux Deploy. A lot of these options are already selected and some don't require any changes. Please set the settings according to the list below (See image below the list):

- Lock Screen: Make sure the box is checked

- Lock WiFi: Make sure box is checked (Some devices will turn off WiFi when you aren't using Android for a period of time. Some carriers and manufacturers do not give you the option to 'keep WiFi on' when the device is 'asleep.' Checking this box will allow the application to attempt to keep WiFi on)

- Wake Lock: Make sure box is checked. (This option can be set to your taste. However, to avoid problems with Linux Deploy and a VNC viewer in case you don't shut down your Linux environment or Linux Deploy, keep this box checked)

- Language: English (Obviously this option would change depending on your preferred language)

- Font Size: 10 = default (This changes the size of the text in Linux Deploy application only)

- Scroll Size: 100 (This tells Linux Deploy how many lines of text you're able to scroll back and look at in the application)

- Theme: Dark or Light (Take your pick)

- Timestamp: Shows the timestamp next to the lines of test in the application. Totally up to you)

- Show Icon: Make sure box is checked (Some devices will attempt to shut down Linux Deploy, even with root. Displaying the icon in the status bar allows a constant notification to be present, which generally stops the system from shutting down the app)

- Stealth Mode: Hides the application icon within your launcher

- Autostart: Check the box if you want Linux Deploy to open and start the Linux OS each time you reboot. This is not recommended especially for lower end/older devices

- Autostart Delay: Tells Linux Deploy how long after the system boots, to open and activate the container (Linux OS)

- Network Trigger: Check this box if you plan on leaving your distribution running while traveling with your device.

- Terminal Command: telnet 127.0.0.1 5023 (This allows you to open a terminal in your distribution that connects to the device. This is just a standard terminal so you don't have to open a terminal emulator in Android. In order to use this you'll need to install the telnet package once your distribution is operational)

- ENV Directory: Auto selected. No need to change (Not sure what exactly this does)

- Path Variable: Blank. (Also not sure of this setting so I didn't change it)

- Enable CLI: Make sure this box is checked (Allows the application to use a command line within, I believe, both the application and the distribution)

- Update ENV: Update the operating environment (This updates the operating environment setup of Linux Deploy. (Please see the next step on how this function works)

- Remove ENV: Removes/deletes the operating environment (This removes/deletes the operating environment. Anytime you change the settings in this settings menu, you MUST tap Remove ENV and tap yes. Then tap Update ENV and yes to update the settings you just changed. Only do these last two

steps when completely done changing settings)

- Telnet: Enable telnetd daemon (Make sure box is checked. You need this option if you choose to install and use the telnet application on your Linux distribution)

- Port: 5023 (Preconfigured. The port that telnet uses to connect to your device inside the Linux OS via terminal)

- Localhost: Make sure this box is checked. This is a security feature which allows only the localhost (that's you inside the Linux OS) to be allowed to connect to the distribution. Leaving the box blank can potentially set yourself up to be hacked, in a bad way. Leave it blank at your own risk and is you know what you're doing)

- Enable Httpd daemon: I am not sure what this does. The box is preconfigured as blank, so I left it as such

- Debug mode: Enable debugging information if you wish

- Trace mode: Enable if you wish.

- Logging: Enable if you wish. The setting below it tells Linux Deploy what type of file to save logs as

10. Now once all those settings are configured, scroll up and tap on Remove ENV and yes when it asks. Then tap on Update ENV and yes when it asks. You have not configured Linux Deploy. Tap the arrow (back) at the top left of the screen.

11. Tap the three dots at the top right of the screen. Tap 'Install'. If everything has been properly configured, and you placed your .img of your distribution in the correct place, Linux Deploy should begin to install your chosen distribution.

If installation doesn't work or fails to install for whatever reason, don't worry; it will NOT brick you're device. It is impossible. You CAN however, corrupt your sdcard, which usually just means you have to reformat it completely and repartition it (but that is a discussion for my next thread). The installation process requires a constant connection to WiFi until it completes. The time the installation takes depends on several variables i.e. your chosen img size and distribution, how good your WiFi connection is and so on. Based on my experience, installation took anywhere from 10 minutes to as long as 40 minutes. If for whatever reason it doesn't complete installation, it will list errors. Be sure to get a screen shot of those errors. I've never had Linux Deploy freeze during installation. You may see the same line of text for a few minutes, especially during the first few minutes of installation.

12. Installation will be complete when you see <<deploy appear as the last line of text. Tap stop at the bottom of the screen. When the process completes (usually a few seconds), tap the three dots at the top right again. Tap configure. This will assure your Distribution is configured to the proper settings that we set up earlier. It will also install any needed updates. This process could take anywhere from 30 seconds to a minute or two (usually). When completed tap stop.

13. You should be ready to launch the distribution. Tap start at the bottom of the screen. If absolutely no errors are given, this should boot up your distribution. If you see the word 'skip,' this is ok and is NOT an error.

14. Now here's the fun part. It's time to configure a VNC viewer. For the purpose of this guide, and one of two VNC viewers I use, we will be setting up VNC Viewer for Android. It will start in landscape mode, but you can rotate once the viewer connects to the distribution. Remember the settings you configured in Linux Deploy? Your distribution will be your chosen height and width once it loads.

15. You will need to set up VNC Viewer for Android as follows:

- Nickname: android (Or the name you chose in Linux Deploy as the 'username')

- Password: The password you set up in Linux Deploy

- Address: 127.0.0.1 (This should be universal for all devices and is what the Linux Deploy application uses to connect)

- Port: 5900 (Also preconfigured in Linux Deploy and it's the port it uses to connect)

- Username: You can leave this blank. I usually do

- Color Format: 24-bit color (4 bpp) (This allows for the best quality graphics possible. And honestly, the graphics are pretty great)

- Local Mouse Pointer: Check the box for a track-pad type mouse (I think? Should enable the mouse to act like a track pad on a laptop. Leave unchecked to use the mouse as pointer tapping?)

- Force Full Screen Bitmap: Make sure box is checked (Could be preference, but I've always had the box checked)

- Use Immersive mode (Devices running KitKat 4.4 and above ONLY)

- Use Wake Lock: Check the box if you desire

- Repeater: No repeater (Not a clue what this does)

That's it. You should be configured. Scroll to the top of the screen in the VNC viewer and make sure the box is checked where it says 'keep' to save the settings when you restart the application.

Now the moment of truth. Can I have a drum roll please? tap, tap, ap, tap, tap.....tap on connect.....iy might take a second or two for your distribution's wallpaper to appear. You may get an error box that pops up just before it fully boots. Just tap on ok or use the 'mouse pointer' to tap it. Sometimes the distribution boots a tad slower than the virtual connection through the viewer.

That's it! You have successfuly installed a Linux OS alongside your Android device. You can interact with your device in a terminal and view files and folders on your distribution, that exist on your device. Perhaps the coolest part of all, you now have access to hundreds, if not thousands of applets in the terminal. Tap on the far bottom left corner icon that will bring up your menu. Tap on system tools and tap on the terminal. Now you can use Linux terminal like it was a full, operating system...because it is :) You also get a root shell. In terminal type:

sudo -i

If you want to install an application, for example git (github for Linux. You have access to just about every repository on github now) you need to have a root shell first. Type in the terminal:

sudo -i
apt-get install git

Debian on my Samsung Galaxy J1, Lollipop 5.1.1

Type in the letter Y if propted. To get a list of all available applications you can install with that command (this is a very, very long list), type in the terminal:

apt list

To exit the VNC connection ONLY, simply tap your recent apps button and swipe it away. To stop the Linux distribution, in Linux deploy, tap the stop button at the bottom of the screen. Then tap the three bars at the top left and tap exit. This should be done EVERY time you want to end your session in Linux Deploy. Do NOT exit or stop Linux Deploy via the recent apps button.

Please stay tuned for the next post below this one titled:

'Part Two: Partitioning external storage (removable sdcard) and installing a Linux Distribution onto it'

I want to thank everyone who followed this guide. Please give me a thanks by tapping the thumb at the bottom of this post or consider a small donation ;) I really think this is awesome and I haven't begun to scratch the surface. I've been too excited getting this to work on so many devices! Please post your results and problems. I very much look forward to your replies!