A user may have many reasons why he needs, he may need "Linux" on "Android". You can, for example, use it to power a LAMP server that runs web applications and serves web pages. If the user is a network administrator, they can install their favorite Linux tools and turn their smartphone into a portable network solution for troubleshooting or checking functionality.
Preparing the device
Initially, the full Linux Installer application is downloaded from the Google Play Store. In addition, you need to go to the Linux project site on Android and download the open source version of the Android app. You must first go to the "Settings" menu, select "Security" and switch to the "Unknown sources" position to enable the installation of applications other than the Play Store.
The app requires a rooted Android device. The exact procedure required to start depends on the device models. The installer requiresto have BusyBox boot Linux to be implemented and installed on first run. In addition to the application created by the Linux project on Android, you will also need a VNC viewer to use the graphical desktop. The project proposes to use the popular Android VNC Viewer app.
Also, you will need another app to access Android's built-in command line. The project suggests using the Android Terminal Emulator app. Next, launch the Complete Linux Installer application. Click on the project icon in the upper left corner of the screen to open a navigation menu that contains several items. The first two are the most important:
- Installation guide, which will guide the user through the steps necessary to set up and install various supported Linux distributions.
- The Launcher element is an integrated launcher that can be used to boot Linux on a smartphone into a configured distribution.
Other items will lead to various information and tips that will help in setting up the system. The process of setting up the distribution kit consists of several stages, for the implementation of which you need to:
- Launch the Complete Linux Installer application.
- Open the navigation menu and click on the "Install Manual" item.
- A list of distributions that can be run on the device will appear.
Run Linux without a device
You can run Linux on an Unrooted Android device thanks to the GNURoot app. Despite its name, it does not require a built-in phone. The main difference between Complete Linux Installer and GNURoot is that the latter gives you access to the Linux distribution's command line interface. To run Linux on Android via GNURoot, you need to grab it from the Google Play Store and also download the companion app for your particular Linux distribution. The application is used for popular distributions such as Debian, Gentoo and Fedora.
These applications are close to 100 MB in size, unlike the GNURoot application which is only a few kilobytes. Once they are installed, launch GNURoot and use the drop-down menu at the top of the page to select the distribution you want to download. Then click the Create New Rootfs button to install the distribution. The process will take some time depending on the resources of the device. When this is done, you need to press the Launch Rootfs button, which will open the terminal and register the user in the Linux distribution on the Android (phone). If you check the box "Run as fake root" before starting the distribution, then you will be logged into the system with superuser privileges.
Instructions for choosing Ubuntu
You must first click on the selected option for further instructions, eg Ubuntu. After that, detailed instructions are displayed, divided into four pages. On theThe first page of the application displays the basic requirements for the device to be able to run the linux distribution on a smartphone. The most important step is to make sure debugging support is enabled. To do this, open the sections "Settings", "Applications", "Development" in sequence and make sure that the "USB Debugging" option is switched.
On the seond page, links to download the image for the selected distribution will appear. Next, click on the “Upload Image” button, a window opens with three additional buttons for uploading one of the three supported image types: large, small, or core.
Then you should install the Linux distribution of your choice, and also choose the size of the downloaded compressed image that will be displayed on the SD card after it is extracted. Next, the sequence of steps is as follows:
- Make sure your Android device is using an ARM v7 processor as most distributions only support this ARM architecture.
- Click on image: This action will bring up another popup with buttons that either download the image from a Sourceforge mirror or download via torrent.
- If the user selects the torrent option, the application will download the torrent file, which will then need to be transferred to the torrent client to download the actual image for the selected Linux distribution.
- You can download the image to your computer and then transfer it toSD card on an Android device. In this case, it is safe to skip the instructions on this page.
- You can unpack the downloaded file either on your computer or on the device itself. For the latter, you will need a universal file manager such as the paid Root Explorer app or the free ES File Explorer app.
- If the user moves images to their device manually, it's best to place them inside a folder. For example, if you're downloading images for an Ubuntu distribution, it's best to extract it to the Ubuntu folder on your SD card.
- After downloading, the user will be taken to a terminal window listing instructions on how to connect to this running Linux installation on an Android (smartphone) using a VNC viewer.
- You must provide the password displayed on the page as you will need it to connect to the VNC server running inside the distribution.
In order to launch the application responsible for downloading distributions, you need to open the navigation menu by clicking on the application icon or by clicking on the launch item. The drop-down menu on the page is then used to select a distribution. If the user receives a message that the image for the selected distribution does not exist, it means that the application cannot find and extract the image files for the distribution. This happens if the downloaded file was not extracted, or if it was saved tonon-standard location.
In this case, you need to manually specify the IMG file of the distribution when starting "Linux" on "Android". For this you will need:
- Press the "Settings" button in the upper right corner of the "Startup" screen, which displays a drop-down menu.
- Click the "Add" option to open the page and complete the entry for the distribution.
- Enter the name of the distribution in the given space and tap the three-dot field to navigate to the file system on the Android device and specify the IMG file for the distribution.
- Click Save Changes.
This custom entry from the distribution will now appear in the dropdown menu on the launch page. When an entry is selected, the app will show a button to launch the distribution.
Procedure for installing "Linux" on an "Android" tablet:
- Press the button to download the distribution. This will launch the terminal application and grant it superuser permission.
- Press the Enter key on the virtual keyboard to download the distribution. Since this is the first time the user has run the distribution, they will be prompted for a default password. This is the password for the default user account, not the password required to log into the VNC session.
- The program will then ask if the distribution needs to run a VNC server to view the graphical desktop and SSH server, or to access the distribution remotely over a secure connection.
- Recommended to run these to take full advantage of running a Linux distribution on an Android device.
- Then you will be prompted to enter the screen resolution of the VNC session. Although you can set it to any size, for a better view, you usually install the product at the same resolution as on the device.
- Please note that when calling the virtual keyboard, it will hide part of the desktop. This is all that is required for the configuration.
- Then the application will prompt you to save the default settings and allow you to download the distribution.
Secure device setup
When a distribution is loaded, the user will see a note with the appropriate settings to VNC into that distribution, and then the standard Linux root prompt will be displayed. You can use this shell to interact with the distribution as with any desktop application. For security purposes, the user must first set a new password to use root.
Procedure for installing the security system:
- Login and enter a new password for the root user. If you want to start an SSH server when you download the distribution, you can connect to it from any computer on the network by entering the Ifconfig command inside the terminal on your Android device.
- Dial the IP address of the device, for example, 192.168.2.101.
- To connect to the device, launch a terminal on another computer and enter:ssh [email protected].
- The system will require the password for the ubuntu user that was set when the distribution was first loaded.
- To view a graphical desktop running on top of a Linux distribution on an Android device, press the home button and minimize the terminal app.
- Run a VNC application like androidVNC to install "Linux" on "Android".
VNC desktop application
VNC has different settings to connect to the distribution running on the device. You need to enter localhost in the field that asks for the IP address of the VNC server and 5900 as the port. In addition to this, you will also need a password to authenticate with the VNC server, which varies by distribution. For Ubuntu images, the password is ubuntu. For Arch Linux it's archlinux, for Linux Debian it's debian and so on. The password is listed on the distribution's wiki page on the LinuxOnAndroid project website.
If the user is using androidVNC, the application prompts to change the color format to 24-bit color (4bpp). Next, click the "Connect" button to start the VNC session after all the information has been entered. The VNC client will connect to the device, immediately displaying the graphical desktop that is running on the distribution you are using.
App developers advise androidVNC users to change input mode to touchpad. To do this, click on the menu button inside the VNC session. This will bring up a lot of options. You need to click the "Input Mode" option, and then select the "Touchpad" radio button from the list of supported input modes. You can now interact with and manage your desktop just like you would on a PC.
Package manager for installation
In Android VNC app, single tap means left click. Double-clicking simulates a right-click. The application will display three buttons: two to zoom in and out, and one to display the virtual keyboard. You can use the package manager to install new applications. The distribution will be able to install applications that have been ported for the ARM architecture, which is true for any popular application.
You can use the above steps to download, set up and use any of the supported distributions on your device. The app also offers some other options to further customize distributions and user interface. To begin with, change the distribution settings when you first enter it. To do this, select the distribution kit to be configured from the drop-down list in the "Running" section.
In addition to the "Start Linux" button, click "Configure Linux" to open the settings page. There are checkboxes for enabling and disabling the launch of SSH and VNC servers. And it is also possible to change the VNC screen resolution by changing the values given on this page. The page has several interesting options, including the Create 1GB SWAP File checkbox. With their help, the application will create a fileswap for distribution.
Paging file for the system
Before enabling this option, you need to make sure that there is enough free space on the SD card. The application can also mount folders from the Android file system to a running Linux.
Order of operations:
- Press the Configure Mounts button to launch the mount editor.
- Click "Options" in the upper right corner, and then select the "Add Mount" option.
- A page will appear where you will need to specify the location of the Android folder that needs to be split manually, for example, storage/sdcard0/Downloads, and then the installation path, for example, home/ubuntu/Downloads.
- You can add as many folders as you like.
- Press the "Save Changes" button, then exit the mount editor.
Move folders to new image
Depending on how the distribution is used, sooner or later the user may run out of free space. In this case, he will have to free up space by creating a larger image and copying all the files and folders from the existing one to the new one. Start the procedure by launching a terminal and creating an empty image of the required size. For example, to create a 4GB image called ubuntuNEW.img, you would use the command:
dd if=/dev/zero of=ubuntuNEW.img bs=1M count=0 seek=4096.
Then you need to format this new image and create a file system with the command:
mke2fs -F ubuntuNEW.img.
Then copy the image file,which you need to get from the device to the computer, for example, with the name ubuntuOLD.img. Next, create two folders on the desktop (ubuntuNEW and ubuntuOLD) to mount these images using the commands:
- sudo mount -o loop ubuntuOLD.img ubuntuOLD;
- sudo mount -o loop ubuntuNEW.img ubuntuNEW.
They will mount the images in their respective folders. Once this is done, copy all the files from the old image to the new image using the command:
sudo cp -rp ubuntuOLD /ubuntuNEW.
Before you need to make sure that the files and folders are copied along with access rights. The process is usually completed by turning off the image using entries:
- sudo umount ubuntuOLD;
- sudo umount ubuntuNEW.
You can now transfer the ubuntuNEW.img file to your phone, delete the existing image, and make sure the distro entry on the startup screen points to the new image. Enable the use of the distribution's CLI package manager tools with GNURoot.
Installing "Linux" on "Android" without root rights
In order to install any Linux distribution on an Android phone, distribution and root permissions supported by ARM are usually required. Since rooting a phone voids the warranty and opens up backdoors to potential attacks, a way to run Linux on Android without rooting must be applied. With GNURoot, the user doesn't have to do these tricks and skiproot permissions.
This method is not like installing full PC for Linux on Android phones as it installs the Linux subsystem which includes many tools. You can use apt-get, SSH, or even turn your Android phone into a LAMP server to run web applications.
Installing Linux on an Android phone with this version will require you to first install GNURoot from the Play Store. The application then installs a fake Linux root filesystem. To do this, simply open the Play Store, find GN, URoot and install these products. Choose a Linux distribution helper application.
By default, GNURoot offers different ARM-based Linux distributions: Linux Debian Wheezy, Fedora, Aboriginal (a lightweight version of BusyBox), and Gentoo. Select any of them and click "Create new Rootfs" to download the necessary files. This process may take some time, so you need to wait a few minutes, after which you should select a Linux distribution and start it.
After the download is complete, select this distribution from the second option in the drop-down list. After ticking the "Run as fake Rootfs" box, get the apt-get commands and other root commands. Click "Run Rootfs" to install and use Linux on Android phone. Once installed, the user is ready to apply Linux on the Android phone. You can now install any package from the distribution using the appropriate package manager using apt-get for Wheezy or yum for Fedora.
To create addition alterminal windows, click on the "+" button. To access menu options for various settings, you can click the icon on the right and other options. The four main Linux distributions available in the GNURoot application will have to work from the command line. You need a GUI to run programs that require windows.
In the first step, this can be implemented using the GNURoot WheezyX distribution, which runs a VNC server. To view the GUI, you need to download the VNC Viewer from the Play Store. The first time the WheezyX distribution is launched in a terminal window, launch the VNC viewer application and enter "localhost:1" as the address and the default "password". This launches a virtual desktop for an xterm terminal window for Wheezy. You can now navigate Linux on Android using your mouse pointer and keyboard icon.