News for hackers. Stuff that matters.
Re:Install postmarketOS on Android phone and use Docker as a... by jraph on Friday December 06, 2024 @10:08AM (#42340466)
I thought it was about installing Docker on Android, but it's about installing postmarketOS on a phone. Then yes, you have a regular Linux (although based on musl, instead of usual glibc) on which you can install Docker.

If you are going to setup a server on a phone, it might indeed be a good idea to avoid Android, mainly because of how aggressive the OOM killer can be with background apps.

On Android, killing a background app is not so much of an issue (caveat: [1]), they are designed for this. But you don't want your service or even your ssh deamon to be killed by Android.

Now, I don't know how running the phone 24/24 7/7 plugged in is going to last in the long run, especially concerning the battery. Has someone tried this?

[edit: see below comments, the post actually advises removing the battery]

[1] https://dontkillmyapp.com/

Re:Install postmarketOS on Android phone and use Docker as a... by DCKing on Friday December 06, 2024 @10:37AM (#42340732)
> Then yes, you have a regular Linux (although based on musl, instead of usual glibc) on which you can install Docker.

The OnePlus 6/6T are also supported by Mobian [0], which is just regular glibc-and-systemd based Debian, and so a pretty familiar Linux server experience.

> it might indeed be a good idea to avoid Android

It's a good idea to avoid Android because of kernel security as well. Old Android devices always use out of date Linux kernels even when using custom ROMs, and when running (containerized) network services you really depend on the security of your Linux kernel to keep those things properly isolated. Both PostmarketOS and Mobian do bring current mainline Linux support to these devices, so you can be quite a bit more confident in your kernel that way.

It's a shame PostmarketOS and Mobian don't really support many newer devices well. Last I checked the OnePlus 6(T) were still the highest performance devices that had okay support. The Snapdragon 845 - a 2018 flagship SoC - in the Oneplus 6/6T made them real high performance device to repurpose for a long time. In 2024 though it's now beaten in performance by the Raspberry Pi 5 or RK3588 based Armbian based devices. Those SBCs of course already have much better I/O and more straightforward ways to get a supported Linux running on them (and don't require disconnecting the battery with custom soldering). So you need to be really committed to reusing your old hardware to go down this route.

[0]: https://wiki.debian.org/Mobian/Devices

Re:Install postmarketOS on Android phone and use Docker as a... by palata on Friday December 06, 2024 @06:55PM (#42345915)
> It's a good idea to avoid Android because of kernel security as well.

Well it's "just" a matter of updating the kernel, right? Those linux projects like PostmarketOS do a lot of mainlining, which benefits custom Android ROMs.

I agree that if the goal is to use the device as an RPi, then it's better to avoid Android. But I wouldn't say that Android is less secure than Linux in general (on the contrary, Android has an interesting security model).

Re:Install postmarketOS on Android phone and use Docker as a... by jraph on Saturday December 07, 2024 @03:06AM (#42348103)
> (on the contrary, Android has an interesting security model).

Which doesn't really apply to a server use case, does is?

Re:Install postmarketOS on Android phone and use Docker as a... by d3Xt3r on Sunday December 08, 2024 @06:28AM (#42356538)
It's not "just" the kernel. The bigger issue is the firmware - Android devices have a ton of closed-source low-level firmware bits, and you really shouldn't expose them to the Internet after the device has reached end-of-support.

But if you're only using it for limited projects as an RPi replacement, then it's probably alright if you're also putting a firewall in front of it, or having it in an isolated network segment with a reverse proxy.

Re:Install postmarketOS on Android phone and use Docker as a... by palata on Sunday December 08, 2024 @01:58PM (#42359348)
> Android devices have a ton of closed-source low-level firmware bits

Can you elaborate on that? You seem to be suggesting that there are low-level firmwares on Android devices that are exposed to the Internet and do not receive updates. Which ones? And do they receive updates with Linux on mobile OSes? And if yes, why couldn't alternative AOSP-based systems use those firmware updates?

Re:Install postmarketOS on Android phone and use Docker as a... by d3Xt3r on Sunday December 08, 2024 @03:44PM (#42360261)
The important ones - from a security and privacy standpoint - are the baseband (cellular stack), WiFi, Bluetooth, NFC, camera, mic, bootloader and the Trusted Execution Environment. Then there's also minor firmware bits for the sensor hub (accelerometer, ambient light sensor etc), touch controller, audio etc.

You can imagine the consequence if there was a vulnerability in say the WiFi firmware or the microphone. The Bluetooth stack is especially vulnerable, with it being an attack vector many times in the past.

On Android devices, only Android has been able to deliver updates to those firmware blobs. This is mainly because these are closed source binary blobs, and are provided by the OEM (often in conjunction with the respective chipset manufacturer, covered by a license agreement).

AOSP and unofficial Linux based OSes like PostmarketOS do not have a license to obtain and distribute these firmware. But even if they did, it means nothing if the support agreement from the chipset maker has ended. Being closed source bits, you can't do anything about it if the respective manufacturer refuses to provide updated firmware.

Ocassionally, some Android custom ROM makers may extract these blobs from more recent devices having the same chipset but running newer firmware, and of course, it doesn't always work (well), not to mention, it's technically illegal. And of course, an official project like PostmarketOS or LineageOS would never do something like redistribute proprietary firmware bits. Projects like these conveniently ignore the firmware issue, and leave it as an exercise for the end user.

Re:Install postmarketOS on Android phone and use Docker as a... by palata on Monday December 09, 2024 @07:29AM (#42365643)
Thanks for the insights, that's super interesting!
Re:Install postmarketOS on Android phone and use Docker as a... by Tade0 on Friday December 06, 2024 @11:26AM (#42341192)
10 years ago I worked at a company which had a fleet of phones to test mobile browser games we were making and the batteries were in noticeably worse shape after a few months of near constant use.

Nowadays in most phones you can limit charging to e.g. 80%, which is much lighter on the battery.

Additionally, the battery works as a heat sink (or heat store really considering it's just a solid slab of dense material) so expect more throttling when it's not there.

Re:Install postmarketOS on Android phone and use Docker as a... by nine_k on Friday December 06, 2024 @01:14PM (#42342415)
If you have an old phone that would otherwise go to garbage, likely its battery is not in a great shape anyway, and server-like loads are mostly incompatible with being battery-powered. I suppose it's going to be permanently attached to a USB power source.

Thanks for the heads-up about the thermal inertia of the battery! Maybe a stationary phone in the server role could use a glue-on passive radiator.

Re:Install postmarketOS on Android phone and use Docker as a... by close04 on Friday December 06, 2024 @03:24PM (#42343977)
The problem isn’t the performance of the battery but the safety. A dead battery for this always-connected use case is probably a non-issue. A swollen battery that could explode or catch fire is definitely an issue.

You could take it out but many phones won’t work without a battery so you need to find a way to trick them into thinking one is installed.

Re:Install postmarketOS on Android phone and use Docker as a... by squarefoot on Friday December 06, 2024 @12:03PM (#42341618)
> (although based on musl, instead of usual glibc)

For those who never used musl and Alpine Linux (which PostmarketOS is based on), the list of supported architectures and software ported over is quite large; here's a list:

https://pkgs.alpinelinux.org/packages

Alpine is my distro of choice for very small systems and VMs once I make sure there are no compatibility issues with what I need to install/build, which can happen sometimes but is really rare. The amount of saved resources (CPU, storage) is significant, making it ideal for VMs.

Re:Install postmarketOS on Android phone and use Docker as a... by znpy on Friday December 06, 2024 @12:22PM (#42341824)
the main issue i see is musl: they have an history of not acknowledging bugs and disregarding standards

last big issue i remember is they not implementing fallback-on-tcp when getting large dns record replies, so some dns record resolution would fail. the standard clearly says to switch to tcp under certain conditions, but they did not.

the bug was reproduced and reported, they refused to acknowledge it and kept the issue for a lot of people for a long time (at least one year iirc). they eventually relented and and implemented the correct behaviour.

call glibc what you want, but at least they don't have such dumb issues and that attitude.

Re:Install postmarketOS on Android phone and use Docker as a... by 3abiton on Friday December 06, 2024 @01:25PM (#42342550)
You can always install incus and glibc. Went with musl for voidlinux, and for using certain appimage, I needed to have glibc. It was seemless to install incus, a debian image, and you have unlimited deb packages at your disposal.
Re:Install postmarketOS on Android phone and use Docker as a... by NewJazz on Saturday December 07, 2024 @09:25AM (#42350020)
Is it just that one example? And the situation now is they "relented"?

call glibc what you want, but at least they don't have such dumb issues and that attitude.

I... Don't know what to say. You really can't think of one decision that the glibc maintainers have made that caused a lot of pain for users? Pretty sure the musl author has/had a blog post full of them. You don't write c library for no reason at all.

Re:Install postmarketOS on Android phone and use Docker as a... by sofixa on Saturday December 07, 2024 @04:30AM (#42348457)
> The amount of saved resources (CPU, storage) is significant, making it ideal for VMs.

Depends on the workload. Running anything which relies on C libraries under the hood is a minefield. E.g. Python's C libraries are often not compiled for musl, so each Python package installation requires compilation.

Re:Install postmarketOS on Android phone and use Docker as a... by greentea23 on Friday December 06, 2024 @11:58AM (#42341534)
You can run these commands to turn that kill behavior off:

setprop persist.sys.fflag.override.settings_enable_monitor_phantom_procs false

/system/bin/settings put global settings_enable_monitor_phantom_procs false

Termux as an example supports several services that run forever. Works great, sshd and crond don't get killed for example. https://wiki.termux.com/wiki/Termux-services

Battery wise you can use this app to keep it in a healthy range and temperature indefinitely: https://github.com/VR-25/acc

Re:Install postmarketOS on Android phone and use Docker as a... by Oxodao on Monday December 09, 2024 @07:44AM (#42365759)
For having a sshd server on my phone I do really like this magisk module https://gitlab.com/d4rcm4rc/MagiskSSH

This let me ssh into the real android instead of inside termux, which might be preferable depending on the use case

Re:Install postmarketOS on Android phone and use Docker as a... by Suppafly on Friday December 06, 2024 @11:42AM (#42341357)
>I thought it was about installing Docker on Android, but it's about installing postmarketOS on a phone.

That makes the whole thing a lot less interesting. Install linux on a small computer and do linux stuff with it probably wouldn't get clicks.

Re:Install postmarketOS on Android phone and use Docker as a... by jraph on Friday December 06, 2024 @02:51PM (#42343599)
It could be about reusing hardware that would otherwise sleep forever in a drawer. This would be commendable.
Re:Install postmarketOS on Android phone and use Docker as a... by grishka on Friday December 06, 2024 @11:31AM (#42341238)
You have to play by Android rules. If you start your daemons from an app that runs a foreground service, I believe this protection would spread to the app's child processes too. Or if you root your phone, you can bypass the activity manager entirely.
Re:Install postmarketOS on Android phone and use Docker as a... by anybody8824 on Friday December 06, 2024 @10:57AM (#42340933)
With the upcoming Android 16 Terminal VM powered by the Android Virtualisation Framework (AVF), it should also be possible to run Docker in an Aarch64 Debian VM similar to WSL2 or ChromeOS crostini.

However, this may still be constrained by OEMs restricting access to AVF or by battery enhancements that make it virtually unusable.

Re:Install postmarketOS on Android phone and use Docker as a... by kokada on Friday December 06, 2024 @11:03AM (#42340988)
This is one of the things that may make me serious consider another Android tablet (especially one with a nice keyboard+touchpad accessory connected via e.g.: Pogo pins). It would definitely be a game changer, and a high-end Android device could completely replace my current hybrid Chromebook.
Re:Install postmarketOS on Android phone and use Docker as a... by KeplerBoy on Friday December 06, 2024 @04:47PM (#42344859)
Isn't google merging chromeOS and android anyways?
Re:Install postmarketOS on Android phone and use Docker as a... by Brain_Man on Tuesday December 10, 2024 @10:50PM (#42384575)
How close would this be to native performance? Will it use any hardware features to reduce the emulation overhead if both the host and the guest use the same architecture?
Re:Install postmarketOS on Android phone and use Docker as a... by rkagerer on Friday December 06, 2024 @11:23AM (#42341170)
how aggressive the OOM killer can be with background apps

This drives me nuts.

Re:Install postmarketOS on Android phone and use Docker as a... by nurumaik on Friday December 06, 2024 @10:58AM (#42340939)
Had very old android phone (redmi go) with sim running 24/7 to forward sms OTPs for a month or two

Sms forwarder app + tailscale on phone, python script on server that forwarded incoming sms to telegram bot (probably could use webhook to avoid this step though). Worked perfectly with 100% uptime

Re:Install postmarketOS on Android phone and use Docker as a... by dang on Friday December 06, 2024 @11:41AM (#42341354)
Ok, we changed the title in the hope of making that clearer.
Re:Install postmarketOS on Android phone and use Docker as a... by matthewaveryusa on Friday December 06, 2024 @10:33AM (#42340700)
I've heard that it's a terrible idea with the battery still in. Curious why this is a non-issue for a UPS -- is it the scale, type of battery (lithium ion vs lifepo4), quality, charge cycle, a bit of all of the above?
Re:Install postmarketOS on Android phone and use Docker as a... by __MatrixMan__ on Friday December 06, 2024 @10:52AM (#42340871)
I think some devices can now be configured to just charge partially (or come that way by default and then tell you that the partial charge is 100%). So this may not be a an issue in all cases, but...

I dedicated an Nvidia shield K1 to be a Sonos interface. Just mounted it to a monitor arm and left it plugged in for something like four years. The mount was this beefy metal thing, a little steel cage for the tablet, but as soon as I unscrewed it enough to remove the tablet from the mount the tablet undramatically exploded. It ballooned to a width that was thrice the original thickness of the tablet, pushed the plastic apart, and it was clear that the case was never going to come back together again. I was afraid to touch it, lest it rupture.

It seems like it would only be a terrible idea beyond a certain scale. The pillowing battery is just assisted disassembly. And now it's easy to get the battery out.

Re:Install postmarketOS on Android phone and use Docker as a... by ssl-3 on Friday December 06, 2024 @11:02AM (#42340972)
UPSs still typically use lead acid batteries. These don't particularly mind being at ~100% SoC for years at a time (they like staying charged), which is very good for this application.

And it's easy to keep them at around 100%. For instance: For a nominal 12v battery, one can very nearly just feed it 13.8v (plus or minus some temperature compensation) and have results that are actually pretty good and close-enough to 100%.

And when things go very wrong, lead acid batteries tend not to catch on fire.

It's a natural fit for UPS duty.

The lithium batteries in cell phones are a different thing. They hate being at 100% SoC and degrade fairly quickly in that state.

They can be pretty happy at around 50% SoC, but it's hard to actually keep them there because of the way the voltage ramps [don't] work with lithium chemistries: It's almost flat through the middle of the curve.

And cell phones don't let us do that anyway: It'd be great if there was a "Compute mode: Just do your best to keep this battery near 50%" setting to click on, but there is not. (And we could hack that in, except: We don't own our phones.)

And when things go wrong, they can become exothermic in ways that are not exactly ideal for an unattended device sitting on a shelf.

Re:Install postmarketOS on Android phone and use Docker as a... by UniverseHacker on Friday December 06, 2024 @11:12AM (#42341070)
I use a chargie device which is a hardware level charge limiter
Re:Install postmarketOS on Android phone and use Docker as a... by ssl-3 on Friday December 06, 2024 @11:38AM (#42341309)
Cute. I didn't know those existed, and they do make sense.

It's only solving part of the problem though: Sure, it can keep the charge at around a self-reported 50%. But the device itself doesn't necessarily have a good idea of what 50% even means, especially as the months and years tick by and cells age, unless it is allowed go closer to the extremes (closer to 0 and closer to 100, sometimes).

The reasons for this get weird. Near the edges of the curves (0 and 100), the BMS can use voltages to figure out where things are. This works well.

In the middle of the curve, voltages are damn near flat and cease to be an indicator of state-of-charge, so the BMS counts coulombs instead. This works too (for awhile).

Except they're not ideal batteries. They age even if they're not being used at all, and shit happens just as it does for any other non-ideal entity. So on a long-enough timeline, even a perfect coulomb counter doesn't necessarily have any way to accurately report state of charge.

The way that this problem is dealt with on a phone that actually gets used like phones get used is that the BMS can reset the coulomb counter during the peaks and dips of a normal charge cycle, based on voltage.

But charge cycling doesn't happen even with a Chargie-equipped phone sitting on a shelf and running Docker containers, does it?

Re:Install postmarketOS on Android phone and use Docker as a... by actionfromafar on Friday December 06, 2024 @12:08PM (#42341682)
Put a wall plug timer on it, charge it 50% of the time.
Re:Install postmarketOS on Android phone and use Docker as a... by ssl-3 on Friday December 06, 2024 @12:15PM (#42341744)
No.
Re:Install postmarketOS on Android phone and use Docker as a... by freedomben on Friday December 06, 2024 @01:05PM (#42342322)
You should definitely add a /s lest anybody take this seriously. It's quite funny though. Especially recommended if you're hoping to burn your house down.

For people that didn't know, this is probably the fastest and riskiest way to destroy your battery quickly

Re:Install postmarketOS on Android phone and use Docker as a... by sigh_again on Saturday December 07, 2024 @11:53AM (#42350970)
If you're going to do this be sure you swap between charging and discharging as often as possible, go as low as your timer will allow. 30 minutes charging, 30 minutes discharging should allow you to reach house fire in less than a month.
Re:Install postmarketOS on Android phone and use Docker as a... by pomian on Friday December 06, 2024 @01:37PM (#42342683)
Like your comments. Question. How does a BMS count coulombs? I mean what is the technology used?
Re:Install postmarketOS on Android phone and use Docker as a... by Sanzig on Friday December 06, 2024 @03:24PM (#42343981)
Q = ∫idt, so you just need something that regularly samples the current (typically measured via a shunt resistor) and accumulates it over time. This is typically done by a dedicated low power chip with an integrated differential amplifier for reading out the sense resistor, ADC, and nonvolatile memory - these are often referred to as "gas gauge" chips. This functionality can also be found on higher end all-in-one battery management chips.
Re:Install postmarketOS on Android phone and use Docker as a... by pomian on Saturday December 07, 2024 @01:50AM (#42347771)
Great. Thanks.
Re:Install postmarketOS on Android phone and use Docker as a... by UniverseHacker on Friday December 06, 2024 @02:12PM (#42343134)
You can add custom charge cycling on a schedule if using the Chargie app. One could for example have it normally stay at 50% but do a full charge/discharge cycle weekly.

Overall though, it would probably make the most sense to physically remove the battery from any phone used as a dedicated webserver, and then have it connected to an external UPS instead.

Re:Install postmarketOS on Android phone and use Docker as a... by ssl-3 on Friday December 06, 2024 @05:08PM (#42345069)
Also cute. That's pretty excellent. I think I'd like to bring such a rig down to 10% and up to 90% once a month or so, based on what I think I know.

And yes, agreed absolutely: It safer to pull the battery, and not particularly difficult or detrimental to do so for the kinds of applications I'm envisioning here that involve a disused phone doing server-ish stuff.

Re:Install postmarketOS on Android phone and use Docker as a... by selectodude on Friday December 06, 2024 @10:43AM (#42340799)
It’s not a non-issue. UPS batteries have a rather short lifespan.
Re:Install postmarketOS on Android phone and use Docker as a... by HPsquared on Friday December 06, 2024 @10:54AM (#42340888)
That's surprising. My laptop battery is like 10 years old and still fine. Light usage and mild storage conditions. Surely UPS batteries are similar.
Re:Install postmarketOS on Android phone and use Docker as a... by bityard on Friday December 06, 2024 @12:01PM (#42341579)
UPS batteries tend to have lead acid batteries, and the lifespan on those is generally between 3-5 years. Lithium batteries in laptops _can_ last quite a bit longer if made well and under the right care.
Re:Install postmarketOS on Android phone and use Docker as a... by pmontra on Friday December 06, 2024 @11:07AM (#42341023)
My UPS manual says 3 years. They have a different chemistry than phone batteries. On the other side, they should be quite similar to car batteries which could live much longer that 3 years, but they spend most of their time waiting in a parking slot and then a few starts per day or less. An UPS doesn't work like that.
Re:Install postmarketOS on Android phone and use Docker as a... by bityard on Friday December 06, 2024 @12:03PM (#42341612)
A good UPS will perform regular load tests to gauge battery performance/degradation. They switch over to battery power around once a week and measure voltage before, during, and after. So even if the power goes out, they are still being exercised _somewhat_.
Re:Install postmarketOS on Android phone and use Docker as a... by password4321 on Friday December 06, 2024 @05:18PM (#42345173)
Can you link to one of these on Amazon or your preferred vendor which you recommend for home office use?
Re:Install postmarketOS on Android phone and use Docker as a... by TsiCClawOfLight on Sunday December 08, 2024 @04:55AM (#42356180)
Eaton Ellipse Pro is great.
Re:Install postmarketOS on Android phone and use Docker as a... by theanonymousone on Friday December 06, 2024 @10:45AM (#42340808)
Really? I plugged my old phone some days ago and set up a ssh daemon on it, just to see if it stays connected. Should I be worried?
Re:Install postmarketOS on Android phone and use Docker as a... by jraph on Friday December 06, 2024 @10:52AM (#42340873)
Yes, it's potentially hazardous in the long run. You can hope that it only kills the battery fast, and that it doesn't make it swell or something.

(absolutely not an expert, though, this is why I asked for experiences :-))

Re:Install postmarketOS on Android phone and use Docker as a... by z3t4 on Friday December 06, 2024 @11:21AM (#42341154)
It usually take a few years for the battery to swell, but it will happen. I have a phone as GSM modem to send and recieve SMS for automatic tasks. I've had 3/3 batteries on two different phones swell so far.
Re:Install postmarketOS on Android phone and use Docker as a... by mmis1000 on Saturday December 07, 2024 @07:22AM (#42349316)
Well, surprisingly. You actually need to swap the battery in UPS about every 3 years. Or the monitor feature in UPS is going to complain _loudly_.(I have one broken a few months ago) So there is not much difference here.

Although swapping battery of ups is surprisingly easy. Buy a new one from online store with a few dollar. Disconnect the connection to old battery.(a REALLY important step). Remove old one. Slap the new one in. Connect the wire. And pre-charge it for a few hours. Then it can just go back online like a new one.

Re:Install postmarketOS on Android phone and use Docker as a... by excalibur on Friday December 06, 2024 @10:22AM (#42340605)
This post links to a previous post from the same author concerning removing the battery and running the device without one: https://crackoverflow.com/docs/system_administration/contain...
Re:Install postmarketOS on Android phone and use Docker as a... by jraph on Friday December 06, 2024 @10:36AM (#42340721)
Ah, nice. I had skimmed the article and didn't read the intro. This is pretty cool.

I could be interested in using my PinePhone like this. Its battery is removable and the phone can be started without it, but the Wi-Fi / Bluetooth module won't run without it. I had the idea of faking the battery like this, but I don't have the skills to handle hardware like this.

Re:Install postmarketOS on Android phone and use Docker as a... by chainingsolid on Friday December 06, 2024 @02:42PM (#42343498)
You could just plug the phone into a small usb-c hub and plug some usb wifi dongel or ethernet cord into it. Not sure if that would solve your use case.
Re:Install postmarketOS on Android phone and use Docker as a... by jraph on Friday December 06, 2024 @02:49PM (#42343575)
Yep, it could work, and I happen to have such a hub (it came with the PinePhone). I think the PinePhone is able to receive power AND do USB OTG at the same time, to be confirmed.

To be completely honest, what I had in mind was to use it as a Bluetooth receiver to play music using my dumb speakers. I don't have a Bluetooth receiver and at this point if I have to buy something I might be better off buying some off the shelf device to do this. So the status quo is to just plug a laptop the times I want to play music in this room because I don't care that much about it.

Re:Install postmarketOS on Android phone and use Docker as a... by ForHackernews on Friday December 06, 2024 @11:09AM (#42341038)
I guess the idea is that you'd do this with an old phone and already-dying battery. It's like having a small raspberry pi style server + builtin UPS.
Re:Install postmarketOS on Android phone and use Docker as a... by j45 on Friday December 06, 2024 @03:40PM (#42344177)
Removing the battery is ok