User:Vitrinekast/The ongoing headache of getting an android phone to work as a webserver

From XPUB & Lens-Based wiki

This document follows the process of me trying to figure out how to set up a web server on various devices. Please note that this was really not a seamless experience, and every step of the way is just me trying things (over and over again). It’s more written like an ongoing conversation with myself to keep track of things.


It’s a Sony Xperia z5, and I’d like it to work as a webserver, as I already had it lying around and it would be an interesting alternative to a non-portable-server.

  • Install documentation of postmarketOS Installation - postmarketOS
  • I have to use pmbootstrap in order to install postmarketOS on the android phone
  • I need linux in order to install it, so first installing linux trough UTM on my macbook No luck yet with installing, as the postmarketOS documentation is a bit all over the place. But i did find an article about running a webserver on the android device, might be interesting: How to host a Static Website on your Android Phone
  • install f-doid
  • install termux
  • enable ssh

Unlock the bootloader via the Sony website instructions

Steps taken:

  1. check if bootloader is possible on the device
    1. In your device, open the dialer and enter ##7378423## to access the service menu.
    2. Tap Service info > Configuration > Rooting Status. If Bootloader unlock allowed says Yes, then you can continue with the next step. If it says No, or if the status is missing, your device cannot be unlocked.
  2. Download the [platform tools](https://developer.android.com/tools/releases/platform-tools
  3. enable USB debugging and the developer tools on the android device
  4. figure out the IMEI to unlock the unlock code by dialling *#06#
    1. 354187075829298
    2. fill in that number in the unlock code generator
    3. E43DC85FEDAC79C5
  5. connect to fastboot
    1. turn off device
    2. press volume up on device
    3. keep it and plug into usb
    4. in the extracted platform tools folder, run ./fastboot devices
    5. verify that there are no errors
  6. enter unlock key

now i ran

pmbootstrap flasher flash_rootfs
pmbootstrap flasher flash_kernel

Now it should work, but it is in a startup loop so i tried again

$ pmbootstrap build linux-sony-sumire
$ pmbootstrap build device-sony-sumire
$ pmbootstrap install --android-recovery-zip
$ pmbootstrap flasher --method=adb sideload

hmm. i did some undocumented things, to get out of the loop. ultimately i ran:

$ pmbootstrap initfs hook_add maximum-attention
$ pmbootstrap flasher boot

which took it into a loop, as documented in the wiki. so i removed the hook, and now it is loading the postmarket os for a little while, stating on the devices screen that its resizing the partition now its loading…

screen is stuck… restarting the device

and its back in the sony loop

I’ve tried all of the above 2x, but keep getting the same result… This issue is documented on the PostMarketOS wiki, so it might be unusable unfortunatly.