It finally happened! The dream has come true. It is now possible to run full linux terminal apps directly on your Android 15 device without root or hacky workarounds. At least for Pixel owners anyway (for now). Just make sure you have the latest system update and then go look in Developer Options for the new Linux development environment setting. This will enable a new Terminal app.
Once activated you will need to install a 565MB virtual machine. And that's it! Now you have a full Linux Development Environment on your phone. How awesome is that?! Now we can run Node apps or any other services you want directly-on-device.
To start, you'll probably want to setup sshd to be able to sftp files into the VM. First we'll need to install the package. No problem! This VM is Debian based, so :
$ sudo apt update
$ sudo apt install openssh-server
Then you will need to change the port that sshd runs on because priviledged ports below 1024 are blocked.
$ sudo nano /etc/ssh/sshd_config
I set my port to 2222 so it'll be easy to remember. Then you'll need to set a password, and reload sshd.
$ sudo passwd droid
...
$ sudo systemctl reload sshd
Accept the request to open the port and then find out what your IP is.
$ ip addr
Then, using an app like Solid Explorer, you can add a network storage location and access the files inside your VM.
And then go ahead and install whatever you want from there. I'm going to start with Node.
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash
$ source ~/.bashrc
$ nvm install node
$ nvm install-latest-npm
I am very excited about the possibilities this opens up. I build and run Node apps for personal use all the time. Being able to run these directly on my phone is gonna be sweeeeet! 🎇
Top comments (2)
Here are some notes after my first couple days messing around with this:
app.listen('7777');
in an Express based Node app did not trigger the port request notification. I had to specifically bind to the loopback interfaceapp.listen('7777', '127.0.0.1');
which did work and I was able to access my server from the Android host ashttps://127.0.0.1:7777
.ssh -p 2222 droid@localhost
to access it. Now I can copy/paste and access sftp without fiddling around on the phone screen. That app has paid for itself many times over.top
on my phone screen while connected via ssh and have seen it steadily run low on RAM before crashing during some heavier operations. Even doing a full system update is enough to bog it down. Compiling software is hit or miss. Clearing out background activities on the phone helps. The problem seems to be that the 4GB allotted to the VM is not dedicated but rather represents the total pool of available RAM which can be used up by other processes.Once inside the chroot:
Good luck... this eats RAM and the VM might crash which corrupts pacman's database and forces you to restore from the archive and try again. I did eventually get it to complete a full upgrade.
When you're done, you can exit the chroot and clean up the mounts:
If you leave the mounts active you can enter and exit the chroot as many times as you want.
/sdcard/linux/images.tar.gz
. But your Android install needs to be built with the debuggable option for this to work. I considered attempting to spoof the download URL of the stock VM. That might work, but would be awkward to reproduce. However, it would be much cleaner than attempting to expand Arch out of chroot. I found the script that prepares the Debian img to run inside AVF and will use this as a guide to build an Arch img.I was not able to connect to the Terminal app's Debian VM using the
vm console
command. But, building a custom Arch VM was pretty straightforward based on this example.This runs fine and boots into a shell that can be accessed through adb, but I have not been able to gain network access. I think without
adb root
the VM does not get assigned thetap
network device to enable this. So without root it seems that only the Terminal app or a custom app that uses AVF can create this connection. But.../data/user/0/com.android.virtualization.terminal/files
gets mapped to/mnt/internal
which can be accessed as root (withsu -
) inside the Debian VM. This is where the config file and boot/root images are stored. The root user inside the vm has write access to this dir, so it should be possible to push a new disk img here and modify the config which then ought to load through the Terminal app. It seems necessary to includeguest_forwarder
,ttyd
and other services from the Debian img to ensure proper network access. More on this later when I have more time to experiment.Looking forward to trying this! Sounds fun 😄🎉