Phone Server Setup

this dump would provide both the information of my current phone as a server and a guide to setting it up with some important perquisites (otherwise it’s likely not gonna work)

Phone Information

Device: Xiaomi Redmi 9A (China version codenamed dandelion)
Chipset: MediaTek Helio G25 (MT6762G armv8l)
Storage: 64 GB (10GB used after debloat)
RAM: 4GB + 2GB swap (idle at ~1GB after startup and debloat)

and it runs on android 11 in arm8l (32-bit os in 64-bit cpu), no 5ghz band support 😭

erm debloat what

I’ve optimized the phone using adb and tried to minimize any CCP spyware and chinese stuff, they do absolutely nothing when turning it into a server.

This phone does support wireless debugging on the developer mode menu, so you can install debugging apps like Shizuku to run adb without hassle, with rish 😀
^^ but you would need to manually start the app and wireless debugging stuff which I don’t even bother to setup an automatic startup for this…

But I’ll show how to mostly debloat the phone later on, but let’s have some background information first.

alr what are u running

Termux 0.118.3 (GitHub version) that are currently running the tobyfox-media channel and my cute lil bot named @Niko, with pm2 and cloudflared for a secured tunnel connection.
The average WiFi speed is ~30Mbit/s download speed and ~25Mbit/s upload speed.
Used Termux:Boot addon to automatically boot up Termux.
technical information:

cris $ uname -a
Linux localhost 4.19.127-perf-gbb0f387b2ec1 #1 SMP PREEMPT Tue Apr 11 13:22:31 CST 2023 armv8l Android
cris $ echo $TERMUX_VERSION - $TERMUX_APK_RELEASE
0.118.3 - GITHUB
cris $ speedtest-go

    speedtest-go v1.7.11 (git-dev) @showwin

✓ ISP: 14.191.x.x (VNPT) [0.000, 0.000]
✓ Found 20 Public Servers

✓ Test Server: [27598] 1083.53km Phu Ly (Vietnam) by Viettel Network
✓ Latency: 10.437753ms Jitter: 3.627718ms Min: 6.809769ms Max: 18.547846ms
✓ Packet Loss Analyzer: Running in background (<= 30 Secs)
✓ Download: 35.07 Mbps (Used: 43.56MB) (Latency: 51ms Jitter: 20ms Min: 7ms Max: 75ms)
✓ Upload: 24.32 Mbps (Used: 45.98MB Confirmed: 97.9%) (Latency: 568ms Jitter: 649ms Min: 7ms Max: 2196ms)
✓ Packet Loss: 0.00% (Sent: 357/Dup: 0/Max: 356)

btw u can flash a ROM into this, the thing is that most ROMs, especially postmarketOS don’t support primary functionality such as wifi, and battery and probably the display itself, though if you want to flash the ROM without the Xiaomi’s official Mi Unlock Tool, better use mtkclient.

so how do u make one

I prefer checking the Android version of the phone to see if it’s using Android 12+.
This version introduced the phantom process killer which terminates processes that use a lot of CPU power or forked more than 32 child processes.
If that’s the case for the phone, use this repository to temporarily delete the limit: https://github.com/atamshkai/Phantom-Process-Killer

When i use Termux for the first time, i would update the packages and setup the server mirror, then I get some necessary packages like termux-services termux-api openssh, basically a service manager and openssh for running processes without using external tools like screen.
I won’t show the exact setup because I don’t want to make this even longer, anyways that’s all.

i want a web server 🤔

try cloudflared and setup a custom service

# creates dir and files
pkg install cloudflared
mkdir -p $PREFIX/var/service/cloudflared/
cat <<< EOF > $PREFIX/var/service/cloudflared/run
#!/data/data/com.termux/files/usr/bin/sh
exec cloudflared tunnel run --token-file $HOME/.cloudflared/token
EOF

docs for the config file (in ~/.cloudflared/config.yml)

btw it has a 100Mbits limit on data upload if u use their free tier and it will disconnect the communication

how do you debloat this phone

there’s a lot of scripts and a github repository that points out which package (or apps) is safe to delete for Xiaomi phones. I’ve compiled a bash script (using Claude and I checked most packages) that contains which package is safe to debloat, and others that would lead to loss functionality and some would likely brick the phone.

You are forced to modify the bash script if you want to delete what you want to keep and not

the arrays listed here are:
safe_pkg => are considered safe to debloat
nonfunctional-pkg => are packages that would lead to functionality loss (eg. carrier services)
and unsafe-pkg means its unsafe to debloat and would likely get your phone bricked

debloat.sh

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top