Rustlings of a Leaf

Running Linux on Android (Part 1/x)

I've always had a soft spot for Raspberry Pi's, however, they have steadily grown out of the price range of "Yeah I'll grab one for fun" to "I should stop and have a think about this." A small, tiny machine that can run Linux, what's not to love? Wait, isn't that also what Android phones do?

A few weeks (months? I dunno time goes too quick) ago Android quietly added a Linux VM to the Pixel phones from 7 and up on Android 15 or later. This seemed perfect! A small, tiny machine that can run Linux, what's not to love? However, it turns out there is a bit not to love about this implementation.

First, you're limited to 4GB of RAM. I guess this makes sense if you want to use your phone as a phone as well, but I'm thinking of just using it as a small dedicated server, there's no point in letting all that RAM sit there not being used.

Second, you're limited to what ever version of Linux the Google decides you get to use. At the moment I believe it is Debian, which isn't bad. But I would rather not rely on Google not changing things if I spend time investing in to this setup.

Well, it turns out that VM's have actually been possible from Android 13 onwards. A utility (program?) was added called 'crosvm', which I think stands for ChRome OS VM. It is this utility that the "new" Linux VM on Android 15+ is using behind the scenes!

And it turns out, that others have already exploited this. A fellow called Danny Lin figured this out and ran Windows 11 on Android via a vm.

A personal note on Twitter/X: I don't like Twitter/X as a company, and I was hesitant to even post an alternative front end but unfortunately this is where the knowledge is siloed.

I'm still not sure if he was using 'crosvm' or something else. I found lots of links to his Patreon which appears to be not around anymore :(

Anyway, the long and short of it is that I can create my own VM's and give them as much resources as possible. Sweet!

End Goal

By the end of the project I want a Linux VM running on an Android device I can use as a home server. It should have the following features:

I would also like to have a series of steps anyone can follow to run their own Linux VM's on supported Android phones.

Target Phone

I was looking through FB Marketplace the other day and saw someone selling a Pixel 7 Pro with a broken touch screen for $100AUD. I nearly impulse purchased it, but I held off. Nearly a month later I saw the phone was still there and bit the bullet.

The phone works perfect except for a little screen damage in the bottom left and the fact the touch screen is broken. Using external keyboard and mouse I was able to go through the process of rooting the phone and installing Magisk on it.

HANDY HINT FOR BROKEN SCREENS: scrcpy is a great utility for mirroring your device to your PC and controlling it from there. However, it requires USB Debugging enabled. If you can't use your touchscreen then you can launch scrcpy with the '--otg' flag. Assuming you've connected your phone via USB to your PC, then a small window will pop up on your computer, capturing your mouse and keyboard input and sending them to the phone instead!

Progress So Far

After rooting the phone I followed a bastardized combination of compiling my own Linux kernel from It's Foss, these instructions on Esper for getting a minimal image booting, and finally what looks to be someone's notes on how they managed to boot Ubuntu on Android.

At the end of this I did actually have an Ubuntu VM I could start up and use. Unfortunately, it didn't have network connection. I ended up getting a bit confused where I was in the process so I deleted everything and started over. Alas, I originally did everything on my work PC which I don't currently have access to so I'm working on my home PC Steam Deck as that's the only working computer I have at home at the moment.

The next steps I will be taking is figuring out how to use DistroBox to run other distros on my Steam Deck. I have no trouble getting them to run, but between boots it seems they die and I'm not sure why. I followed the official DistroBox steps for Steam Deck but still having some issues with it. This very much feels like yak shaving but it must be done.

Thanks for listening to me ramble!


Recent posts