It happened. The old MacBook Pro I purchased in the US finally stopped working. I’ve tried to fix it but the screen simply won’t light up anymore. But I’m not sad because the machine, although expensive, was also very heavy. Rather than securing a new machine I decided it would be wiser to combine them by moving my Linux development environment inside my Huawei P40 Pro+ and how you can too.
To get Linux running on Android install Termux and AnLinux. Termux gives you access to a shell on your phone and from there you can do magic things. Consider also installing Termux:API as well to access lower-level system functions. You do not need root access to your phone to install Linux nor is root recommended.
Open AnLinux, choose the Linux distro you want to install and follow the on-screen instructions to complete base installation. I’m going to install Arch because it has a strong community, supports user-submitted packages and its documentation is nothing short of incredible. AnLinux allows you to install several distros side-by-side including:
- Ubuntu, Debian, Kali, Kali, Backbox, Fedora, CentOS, openSUSE, Black Arch, Alpine and Void Linux
If you’re a distro hopper, this set-up gives you a low-friction approach to try out several distros at a time. If you’re a security expert, you’ve got access to several pen testing distros few will suspect you’ve concealed on your phone. Not sure which distro to choose? Visit DistroWatch and read up.
Arch installation should finish in 3-5 minutes. Once complete follow the on-screen instructions in AnLinux to start the operating system and set-up any additional permissions necessary to run Arch.
Running Arch using a software keyboard on a small screen display obviously isn’t going to be feasible for long. Instead use a keyboard from another device on your home network. To set-up SSH access follow the instructions in this video:
When finished enable the Wakelock for Termux from the Android notification panel and SSH into your Termux shell. You may also wish to check your Android settings to disable automatic management of Termux. If the system manages the battery for Termux, you may experience degraded performance or suspension, leading to a “broken pipe” error from SSH. That shouldn’t happen even with the screen off.
You now have a functional Linux system and keyboard.
Start Arch and run
pacman -Syu as root user to update the system.
To access the Arch User Repository (AUR) install
Yay. AUR packages and Yay itself require the use of
makepkg which cannot be run as root. Create a new user first with
su - <username> to access the user account.
Tip: You’ll also want to
pacman -S sudo && visudo as root to give the new user sudoer permissions, and add them to the
wheel group using
usermod so the system knows they’re an administrator and not an ordinary user.
Access the new user and install Yay:
pacman -S --needed git base-devel
git clone https://aur.archlinux.org/yay-bin.git
The first command must be run with sudoer permissions so prefix it with
sudo if not logged in as root and, if necessary,
exit out of
su back to the root user and
passwd <username> to set the pass for the new user account first.
makepkg you may see an error:
fakeroot, while creating message channels: Function not implemented
This may be due to a lack of SYSV IPC support.
fakeroot: error while starting the `faked' daemon.
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
In this case you can download and rebuild
fakeroot with TCP support to overcome the
SYSV IPC support limitation after installing
tar xvf fakeroot_1.26.orig.tar.gz
./configure --prefix=/opt/fakeroot \
sudo make install
Once the build completes run
makepkg -si again to complete the Yay installation. Then test it out by running:
yay -S --noconfirm zsh-theme-powerlevel10k-git
Which is the
first of two commands to give you a super slick tabline should you decide to switch from bash to Zsh by running
chsh -s /bin/zsh <username>.
You now have a functional and serviceable version of Arch Linux running on your Android device thanks to Termux and AnLinux. In this short tutorial you learned how to install Arch Linux side-by-side next to other Linux distros, how to update the operating system, how to build packages from AUR and how to switch to a themed Zshell. If later you’re not able to connect to your SSH server, make sure Termux is running and that
sshd is running.